0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 17:51:53 +00:00

Rip now tries to lock interface.

Fixed fatal errors which caused segfault at startup.

Fixed fatal errors in rip which caused it not to send more than first
update.
This commit is contained in:
Pavel Machek 2000-03-22 14:26:03 +00:00
parent ba4466701a
commit ff8ed63285
2 changed files with 41 additions and 12 deletions

View File

@ -5,8 +5,6 @@
* *
* 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: lock interface so we are not started twice on same interface.
FIXME: IpV6 support: packet size FIXME: IpV6 support: packet size
FIXME: IpV6 support: use right address for broadcasts FIXME: IpV6 support: use right address for broadcasts
FIXME: IpV6 support: receive "route using" blocks FIXME: IpV6 support: receive "route using" blocks
@ -119,6 +117,7 @@ rip_tx( sock *s )
do { do {
if (c->done) { if (c->done) {
im_done:
DBG( "Looks like I'm" ); DBG( "Looks like I'm" );
c->rif->busy = NULL; c->rif->busy = NULL;
rem_node(NODE c); rem_node(NODE c);
@ -157,8 +156,11 @@ rip_tx( sock *s )
if (i == !!P_CF->authtype) if (i == !!P_CF->authtype)
continue; continue;
#endif #endif
if (!i) if (!i) {
DBG( "not sending NULL update\n" ); DBG( "not sending NULL update\n" );
c->done = 1;
goto im_done;
}
else { else {
if (ipa_nonzero(c->daddr)) if (ipa_nonzero(c->daddr))
i = sk_send_to( s, packetlen, c->daddr, c->dport ); i = sk_send_to( s, packetlen, c->daddr, c->dport );
@ -579,6 +581,7 @@ new_iface(struct proto *p, struct iface *new, unsigned long flags, struct iface_
rif->sock->ttl = 30; rif->sock->ttl = 30;
rif->sock->tos = IP_PREC_INTERNET_CONTROL; rif->sock->tos = IP_PREC_INTERNET_CONTROL;
if (new) {
rif->sock->daddr = new->addr->brd; rif->sock->daddr = new->addr->brd;
if (new->addr->flags & IA_UNNUMBERED) if (new->addr->flags & IA_UNNUMBERED)
log( L_WARN "%s: rip is not defined over unnumbered links", P_NAME ); log( L_WARN "%s: rip is not defined over unnumbered links", P_NAME );
@ -586,6 +589,7 @@ new_iface(struct proto *p, struct iface *new, unsigned long flags, struct iface_
rif->sock->daddr = ipa_from_u32(0xe0000009); rif->sock->daddr = ipa_from_u32(0xe0000009);
rif->sock->saddr = ipa_from_u32(0xe0000009); rif->sock->saddr = ipa_from_u32(0xe0000009);
} }
}
if (!ipa_nonzero(rif->sock->daddr)) { if (!ipa_nonzero(rif->sock->daddr)) {
log( L_WARN "%s: interface %s is too strange for me", P_NAME, rif->iface ? rif->iface->name : "(dummy)" ); log( L_WARN "%s: interface %s is too strange for me", P_NAME, rif->iface ? rif->iface->name : "(dummy)" );
@ -601,6 +605,22 @@ new_iface(struct proto *p, struct iface *new, unsigned long flags, struct iface_
return rif; return rif;
} }
static void
rip_real_if_add(struct object_lock *lock)
{
struct iface *iface = lock->iface;
struct proto *p = lock->data;
struct rip_interface *rif;
struct iface_patt *k = iface_patt_match(&P_CF->iface_list, iface);
if (!k)
bug("This can not happen! It existed few seconds ago!" );
DBG("adding interface %s\n", iface->name );
rif = new_iface(p, iface, iface->flags, k);
add_head( &P->interfaces, NODE rif );
rif->lock = lock;
}
static void static void
rip_if_notify(struct proto *p, unsigned c, struct iface *iface) rip_if_notify(struct proto *p, unsigned c, struct iface *iface)
{ {
@ -613,16 +633,23 @@ rip_if_notify(struct proto *p, unsigned c, struct iface *iface)
if (i) { if (i) {
rem_node(NODE i); rem_node(NODE i);
kill_iface(p, i); kill_iface(p, i);
rfree(i->lock);
} }
} }
if (c & IF_CHANGE_UP) { if (c & IF_CHANGE_UP) {
struct rip_interface *rif; struct rip_interface *rif;
struct iface_patt *k = iface_patt_match(&P_CF->iface_list, iface); struct iface_patt *k = iface_patt_match(&P_CF->iface_list, iface);
struct object_lock *lock;
if (!k) return; /* We are not interested in this interface */ if (!k) return; /* We are not interested in this interface */
DBG("adding interface %s\n", iface->name );
rif = new_iface(p, iface, iface->flags, k); lock = olock_new( p->pool );
add_head( &P->interfaces, NODE rif ); lock->addr = IPA_NONE; /* FIXME: how to set this? */
lock->port = P_CF->port;
lock->iface = iface;
lock->hook = rip_real_if_add;
lock->data = p;
olock_acquire(lock);
} }
} }

View File

@ -6,6 +6,7 @@
#include "nest/route.h" #include "nest/route.h"
#include "nest/password.h" #include "nest/password.h"
#include "nest/locks.h"
#define EA_RIP_TAG EA_CODE(EAP_RIP, 0) #define EA_RIP_TAG EA_CODE(EAP_RIP, 0)
#define EA_RIP_METRIC EA_CODE(EAP_RIP, 1) #define EA_RIP_METRIC EA_CODE(EAP_RIP, 1)
@ -102,6 +103,7 @@ struct rip_interface {
struct rip_connection *busy; struct rip_connection *busy;
struct rip_patt *patt; struct rip_patt *patt;
int triggered; int triggered;
struct object_lock *lock;
}; };
struct rip_patt { struct rip_patt {