Allow 1 sec RIP update.

This commit is contained in:
Ondrej Filip 2013-02-24 00:43:08 +01:00
parent 04ddefb357
commit a9c38203bd
2 changed files with 14 additions and 13 deletions

View file

@ -7,14 +7,13 @@
* Can be freely distributed and used under the terms of the GNU GPL. * Can be freely distributed and used under the terms of the GNU GPL.
* *
FIXME: IpV6 support: packet size FIXME: IpV6 support: packet size
FIXME: (nonurgent) IpV6 support: receive "route using" blocks FIXME: (nonurgent) IPv6 support: receive "route using" blocks
FIXME: (nonurgent) IpV6 support: generate "nexthop" blocks FIXME: (nonurgent) IPv6 support: generate "nexthop" blocks
next hops are only advisory, and they are pretty ugly in IpV6. next hops are only advisory, and they are pretty ugly in IpV6.
I suggest just forgetting about them. I suggest just forgetting about them.
FIXME: (nonurgent): fold rip_connection into rip_interface? 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. 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) { FIB_ITERATE_START(&P->rtable, &c->iter, z) {
struct rip_entry *e = (struct rip_entry *) 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; nullupdate = 0;
i = rip_tx_prepare( p, packet->block + i, e, rif, i ); i = rip_tx_prepare( p, packet->block + i, e, rif, i );
if (i >= maxi) { if (i >= maxi) {
@ -557,17 +556,23 @@ rip_timer(timer *t)
DBG( "RIP: Broadcasting routing tables\n" ); DBG( "RIP: Broadcasting routing tables\n" );
{ {
struct rip_interface *rif; 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 ) { WALK_LIST( rif, P->interfaces ) {
struct iface *iface = rif->iface; struct iface *iface = rif->iface;
if (!iface) continue; if (!iface) continue;
if (rif->mode & IM_QUIET) continue; if (rif->mode & IM_QUIET) continue;
if (!(iface->flags & IF_UP)) 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 ); rip_sendto( p, IPA_NONE, 0, rif );
} }
P->tx_count ++; P->tx_count++;
P->rnd_count--;
} }
DBG( "RIP: tick tock done\n" ); DBG( "RIP: tick tock done\n" );
@ -595,14 +600,9 @@ rip_start(struct proto *p)
init_list( &P->interfaces ); init_list( &P->interfaces );
P->timer = tm_new( p->pool ); P->timer = tm_new( p->pool );
P->timer->data = p; P->timer->data = p;
P->timer->randomize = 2; P->timer->recurrent = 1;
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->hook = rip_timer; 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 */ rif = new_iface(p, NULL, 0, NULL); /* Initialize dummy interface */
add_head( &P->interfaces, NODE rif ); add_head( &P->interfaces, NODE rif );
CHK_MAGIC; CHK_MAGIC;

View file

@ -162,6 +162,7 @@ struct rip_proto {
int magic; int magic;
#endif #endif
int tx_count; /* Do one regular update once in a while */ int tx_count; /* Do one regular update once in a while */
int rnd_count; /* Randomize sending time */
}; };
#ifdef LOCAL_DEBUG #ifdef LOCAL_DEBUG