]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Allow 1 sec RIP update.
authorOndrej Filip <feela@network.cz>
Sat, 23 Feb 2013 23:43:08 +0000 (00:43 +0100)
committerOndrej Filip <feela@network.cz>
Sat, 23 Feb 2013 23:43:08 +0000 (00:43 +0100)
proto/rip/rip.c
proto/rip/rip.h

index 35a151ad7c2868b35b3b0d84606c0e2169f1301f..5007715d62611d4f809741826db50c8ca0fe4d16 100644 (file)
@@ -7,14 +7,13 @@
  *     Can be freely distributed and used under the terms of the GNU GPL.
  *
        FIXME: IpV6 support: packet size
-       FIXME: (nonurgent) IpV6 support: receive "route using" blocks
-       FIXME: (nonurgent) IpV6 support: generate "nexthop" blocks
+       FIXME: (nonurgent) IPv6 support: receive "route using" blocks
+       FIXME: (nonurgent) IPv6 support: generate "nexthop" blocks
                next hops are only advisory, and they are pretty ugly in IpV6.
                I suggest just forgetting about them.
 
        FIXME: (nonurgent): fold rip_connection into rip_interface?
 
-       FIXME: (nonurgent) allow bigger frequencies than 1 regular update in 6 seconds (?)
        FIXME: propagation of metric=infinity into main routing table may or may not be good idea.
  */
 
@@ -162,7 +161,7 @@ rip_tx( sock *s )
     FIB_ITERATE_START(&P->rtable, &c->iter, z) {
       struct rip_entry *e = (struct rip_entry *) z;
 
-      if (!rif->triggered || (!(e->updated < now-5))) {
+      if (!rif->triggered || (!(e->updated < now-2))) {                /* FIXME: Should be probably 1 or some different algorithm */
        nullupdate = 0;
        i = rip_tx_prepare( p, packet->block + i, e, rif, i );
        if (i >= maxi) {
@@ -557,17 +556,23 @@ rip_timer(timer *t)
   DBG( "RIP: Broadcasting routing tables\n" );
   {
     struct rip_interface *rif;
+
+    if ( P_CF->period > 2 ) {          /* Bring some randomness into sending times */
+      if (! (P->tx_count % P_CF->period)) P->rnd_count = random_u32() % 2;
+    } else P->rnd_count = P->tx_count % P_CF->period;
+
     WALK_LIST( rif, P->interfaces ) {
       struct iface *iface = rif->iface;
 
       if (!iface) continue;
       if (rif->mode & IM_QUIET) continue;
       if (!(iface->flags & IF_UP)) continue;
+      rif->triggered = P->rnd_count;
 
-      rif->triggered = (P->tx_count % 6);
       rip_sendto( p, IPA_NONE, 0, rif );
     }
-    P->tx_count ++;
+    P->tx_count++;
+    P->rnd_count--;
   }
 
   DBG( "RIP: tick tock done\n" );
@@ -595,14 +600,9 @@ rip_start(struct proto *p)
   init_list( &P->interfaces );
   P->timer = tm_new( p->pool );
   P->timer->data = p;
-  P->timer->randomize = 2;
-  P->timer->recurrent = (P_CF->period / 6) - 1; 
-  if (P_CF->period < 12) {
-    log(L_WARN "Period %d is too low. So I am using 12 which is the lowest possible value.", P_CF->period);
-    P->timer->recurrent = 1;
-  }
+  P->timer->recurrent = 1;
   P->timer->hook = rip_timer;
-  tm_start( P->timer, 5 );
+  tm_start( P->timer, 2 );
   rif = new_iface(p, NULL, 0, NULL);   /* Initialize dummy interface */
   add_head( &P->interfaces, NODE rif );
   CHK_MAGIC;
index 896fab649995b5114545a867e871826582625abd..e0816d0e03f833053b59d648a4bad0d73ab60833 100644 (file)
@@ -162,6 +162,7 @@ struct rip_proto {
   int magic;
 #endif
   int tx_count;                /* Do one regular update once in a while */
+  int rnd_count;       /* Randomize sending time */
 };
 
 #ifdef LOCAL_DEBUG