From marck@woozle.rinet.ru  Mon Mar  7 09:39:04 2005
Return-Path: <marck@woozle.rinet.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 779F716A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  7 Mar 2005 09:39:04 +0000 (GMT)
Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9CBE643D1F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  7 Mar 2005 09:39:03 +0000 (GMT)
	(envelope-from marck@woozle.rinet.ru)
Received: from woozle.rinet.ru (localhost [127.0.0.1])
	by woozle.rinet.ru (8.13.1/8.13.1) with ESMTP id j279d2dV080505
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 7 Mar 2005 12:39:02 +0300 (MSK)
	(envelope-from marck@woozle.rinet.ru)
Received: (from marck@localhost)
	by woozle.rinet.ru (8.13.1/8.13.1/Submit) id j279d2jR080504;
	Mon, 7 Mar 2005 12:39:02 +0300 (MSK)
	(envelope-from marck)
Message-Id: <200503070939.j279d2jR080504@woozle.rinet.ru>
Date: Mon, 7 Mar 2005 12:39:02 +0300 (MSK)
From: Dmitry Morozovsky <marck@freebsd.org>
Reply-To: Dmitry Morozovsky <marck@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: net/quagga: defence for time goes backwards
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         78524
>Category:       ports
>Synopsis:       net/quagga: defence for time goes backwards
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pav
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 07 09:40:02 GMT 2005
>Closed-Date:    Wed Mar 09 09:31:48 GMT 2005
>Last-Modified:  Wed Mar 09 09:31:48 GMT 2005
>Originator:     Dmitry Morozovsky
>Release:        FreeBSD 4-STABLE i386
>Organization:
Cronyx Plus LLC (RiNet ISP)
>Environment:
System: FreeBSD 4-STABLE; FreeBSD/i386 and /amd64 5.4-PRERELEASE


>Description:

This PR is analogous to ports/78302 for zebra: when system time goes backwards
for some reasone, it's possible for LSA refresher to enter nearly endless loop,
blocking router from updates and effectively disconnecting from peers.

>How-To-Repeat:

Non-deterministic, but mostly working example:
run quagga's ospfd, slide time backwards. watch for adjacency goes down on other
OSPF router.

>Fix:

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/net/quagga/Makefile,v
retrieving revision 1.25
diff -u -r1.25 Makefile
--- Makefile	7 Feb 2005 10:39:44 -0000	1.25
+++ Makefile	7 Mar 2005 09:33:54 -0000
@@ -7,7 +7,7 @@
 
 PORTNAME=	quagga
 PORTVERSION=	0.98.2
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	net ipv6
 MASTER_SITES=	http://quagga.net/download/
 
Index: files/patch-ospfd_ospf_lsa.c
===================================================================
RCS file: files/patch-ospfd_ospf_lsa.c
diff -N files/patch-ospfd_ospf_lsa.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-ospfd_ospf_lsa.c	7 Mar 2005 09:33:54 -0000
@@ -0,0 +1,37 @@
+--- ospfd/ospf_lsa.c.orig	Wed Dec 22 19:16:02 2004
++++ ospfd/ospf_lsa.c	Mon Mar  7 12:24:04 2005
+@@ -3665,6 +3665,7 @@
+   struct listnode *node;
+   struct ospf *ospf = THREAD_ARG (t);
+   int i;
++  time_t ct;
+   struct list *lsa_to_refresh = list_new ();
+ 
+   if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
+@@ -3672,15 +3673,25 @@
+ 
+   
+   i = ospf->lsa_refresh_queue.index;
++
++  if ((ct = time(NULL)) < ospf->lsa_refresher_started) {
++    zlog_debug ("LSA[Refresh]: ospf_lsa_refresh_walker(): HACK: fixing lsa_refresher_started: %d -> %d", ospf->lsa_refresher_started, ct);
++    ospf->lsa_refresher_started = ct;
++  }
+   
+   ospf->lsa_refresh_queue.index =
+     (ospf->lsa_refresh_queue.index +
+-     (time (NULL) - ospf->lsa_refresher_started) / OSPF_LSA_REFRESHER_GRANULARITY)
++     (ct - ospf->lsa_refresher_started) / OSPF_LSA_REFRESHER_GRANULARITY)
+     % OSPF_LSA_REFRESHER_SLOTS;
+ 
+   if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
+     zlog_debug ("LSA[Refresh]: ospf_lsa_refresh_walker(): next index %d",
+ 	       ospf->lsa_refresh_queue.index);
++
++  if (ospf->lsa_refresh_queue.index >= OSPF_LSA_REFRESHER_SLOTS) {
++    zlog_debug ("LSA[Refresh]: ospf_lsa_refresh_walker(): HACK: fixing index: %hu -> 0", ospf->lsa_refresh_queue.index);
++    ospf->lsa_refresh_queue.index = 0;
++  }
+ 
+   for (;i != ospf->lsa_refresh_queue.index;
+        i = (i + 1) % OSPF_LSA_REFRESHER_SLOTS)

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: pav 
State-Changed-When: Tue Mar 8 23:06:42 GMT 2005 
State-Changed-Why:  
Asked maintainer for approval 


Responsible-Changed-From-To: freebsd-ports-bugs->pav 
Responsible-Changed-By: pav 
Responsible-Changed-When: Tue Mar 8 23:06:42 GMT 2005 
Responsible-Changed-Why:  
Watch 

http://www.freebsd.org/cgi/query-pr.cgi?pr=78524 

From: Pav Lucistnik <pav@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, boris@tagnet.ru
Cc:  
Subject: Re: ports/78524: net/quagga: defence for time goes backwards
Date: Wed, 09 Mar 2005 00:06:36 +0100

 Dear maintainer of FreeBSD port net/quagga, please take a look at
 
 http://www.freebsd.org/cgi/query-pr.cgi?q=78524
 
 Do you approve this patch?
 
 -- 
 Pav Lucistnik <pav@oook.cz>
               <pav@FreeBSD.org>
 
 With sufficient thrust, pigs fly just fine.
   -- RFC 1925
State-Changed-From-To: feedback->closed 
State-Changed-By: pav 
State-Changed-When: Wed Mar 9 09:31:26 GMT 2005 
State-Changed-Why:  
Maintainer rejected the patch 

Pav Lucistnik wrote: 
Hello! 

For the time present - no. I saw this patch in quagga-dev, but,  
imho, it is still unapproved by developers team. I will contact the  
author of the patch and quagga developers team to clarify the situation. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=78524 
>Unformatted:
