[ospfd] Bug #134, ospfd should be more robust to backward time change

2006-08-25 Paul Jakma <paul.jakma@sun.com>

	* (general) Bug #134. Be more robust to backward time changes,
	  use the newly added libzebra time functions.
	  In most cases: recent_time -> recent_relative_time()
	  gettimeofday -> quagga_gettime (QUAGGA_CLK_MONOTONIC, ..)
	  time -> quagga_time.
	  (ospf_make_md5_digest) time() call deliberately not changed.
	  (ospf_external_lsa_refresh) remove useless gettimeofday, LSA
	  tv_orig time was already set in ospf_lsa_new, called via
	  ospf_external_lsa_new.
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 6449e63..d7a3564 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -337,7 +337,9 @@
     return 0;
 
   /* We do this here so when we dup a packet, we don't have to
-     waste CPU rewriting other headers. */
+     waste CPU rewriting other headers.
+     
+     Note that quagga_time /deliberately/ is not used here */
   t = (time(NULL) & 0xFFFFFFFF);
   if (t > oi->crypt_seqnum)
     oi->crypt_seqnum = t;
@@ -444,7 +446,7 @@
 		  fired.  This is a small tweak to what is in the RFC,
 		  but it will cut out out a lot of retransmit traffic
 		  - MAG */
-		if (tv_cmp (tv_sub (recent_time, lsa->tv_recv), 
+		if (tv_cmp (tv_sub (recent_relative_time (), lsa->tv_recv), 
 			    int2tv (retransmit_interval)) >= 0)
 		  listnode_add (update, rn->info);
 	    }
@@ -1363,7 +1365,7 @@
 	  else
 	    {
 	      struct timeval t, now;
-	      gettimeofday (&now, NULL);
+	      quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
 	      t = tv_sub (now, nbr->last_send_ts);
 	      if (tv_cmp (t, int2tv (nbr->v_inactivity)) < 0)
 		{
@@ -1948,7 +1950,7 @@
 	    {
 	      struct timeval now;
 	      
-	      gettimeofday (&now, NULL);
+	      quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
 	      
 	      if (tv_cmp (tv_sub (now, current->tv_orig), 
 			  int2tv (OSPF_MIN_LS_ARRIVAL)) > 0)
@@ -3158,7 +3160,7 @@
   if (nbr->last_send)
     ospf_packet_free (nbr->last_send);
   nbr->last_send = ospf_packet_dup (op);
-  gettimeofday (&nbr->last_send_ts, NULL);
+  quagga_gettime (QUAGGA_CLK_MONOTONIC, &nbr->last_send_ts);
 }
 
 /* Re-send Database Description. */