Inlined metric and mode into struct rip_interface to make reconfig

work.

reconfigure is conservative but should work.
This commit is contained in:
Pavel Machek 2000-05-10 13:23:21 +00:00
parent 30aa02d70d
commit 3e47419274
2 changed files with 17 additions and 10 deletions

View file

@ -297,7 +297,7 @@ advertise_entry( struct proto *p, struct rip_block *b, ip_addr whotoldme )
} }
n = net_get( p->table, b->network, pxlen ); n = net_get( p->table, b->network, pxlen );
r = rte_get_temp(a); r = rte_get_temp(a);
r->u.rip.metric = ntohl(b->metric) + rif->patt->metric; r->u.rip.metric = ntohl(b->metric) + rif->metric;
if (r->u.rip.metric > P_CF->infinity) r->u.rip.metric = P_CF->infinity; if (r->u.rip.metric > P_CF->infinity) r->u.rip.metric = P_CF->infinity;
r->u.rip.tag = ntohl(b->tag); r->u.rip.tag = ntohl(b->tag);
r->net = n; r->net = n;
@ -468,7 +468,7 @@ rip_timer(timer *t)
struct iface *iface = rif->iface; struct iface *iface = rif->iface;
if (!iface) continue; if (!iface) continue;
if (rif->patt->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->tx_count % 6); rif->triggered = (P->tx_count % 6);
@ -577,15 +577,17 @@ static struct rip_interface *
new_iface(struct proto *p, struct iface *new, unsigned long flags, struct iface_patt *patt ) new_iface(struct proto *p, struct iface *new, unsigned long flags, struct iface_patt *patt )
{ {
struct rip_interface *rif; struct rip_interface *rif;
struct rip_patt *PATT = (struct rip_patt *) patt;
rif = mb_allocz(p->pool, sizeof( struct rip_interface )); rif = mb_allocz(p->pool, sizeof( struct rip_interface ));
rif->iface = new; rif->iface = new;
rif->proto = p; rif->proto = p;
rif->busy = NULL; rif->busy = NULL;
rif->patt = (struct rip_patt *) patt; if (PATT) {
rif->mode = PATT->mode;
if (rif->patt) rif->metric = PATT->metric;
rif->multicast = (!(rif->patt->mode & IM_BROADCAST)) && (flags & IF_MULTICAST); rif->multicast = (!(PATT->mode & IM_BROADCAST)) && (flags & IF_MULTICAST);
}
/* lookup multicasts over unnumbered links - no: rip is not defined over unnumbered links */ /* lookup multicasts over unnumbered links - no: rip is not defined over unnumbered links */
if (rif->multicast) if (rif->multicast)
@ -627,7 +629,7 @@ new_iface(struct proto *p, struct iface *new, unsigned long flags, struct iface_
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)" );
} else } else
if (!(rif->patt->mode & IM_NOLISTEN)) if (!(rif->mode & IM_NOLISTEN))
if (sk_open(rif->sock)<0) { if (sk_open(rif->sock)<0) {
log( L_ERR "%s: could not listen on %s", P_NAME, rif->iface ? rif->iface->name : "(dummy)" ); log( L_ERR "%s: could not listen on %s", P_NAME, rif->iface ? rif->iface->name : "(dummy)" );
/* Don't try to transmit into this one? Well, why not? This should not happen, anyway :-) */ /* Don't try to transmit into this one? Well, why not? This should not happen, anyway :-) */
@ -868,8 +870,12 @@ static int
rip_reconfigure(struct proto *p, struct proto_config *c) rip_reconfigure(struct proto *p, struct proto_config *c)
{ {
struct rip_config *new = (struct rip_config *) c; struct rip_config *new = (struct rip_config *) c;
int generic = sizeof(struct proto_config) + sizeof(list); int generic = sizeof(struct proto_config) + sizeof(list) /* + sizeof(struct password_item *) */;
#if 0
if (!password_same())
return 0;
#endif
return !memcmp(((byte *) P_CF) + generic, return !memcmp(((byte *) P_CF) + generic,
((byte *) new) + generic, ((byte *) new) + generic,
sizeof(struct rip_proto_config) - generic); sizeof(struct rip_proto_config) - generic);

View file

@ -101,7 +101,8 @@ struct rip_interface {
struct iface *iface; struct iface *iface;
sock *sock; sock *sock;
struct rip_connection *busy; struct rip_connection *busy;
struct rip_patt *patt; int metric; /* You don't want to put struct rip_patt *patt here -- think about reconfigure */
int mode;
int triggered; int triggered;
struct object_lock *lock; struct object_lock *lock;
int multicast; int multicast;
@ -121,6 +122,7 @@ struct rip_patt {
struct rip_proto_config { struct rip_proto_config {
struct proto_config c; struct proto_config c;
list iface_list; /* Patterns configured -- keep it first; see rip_reconfigure why */ list iface_list; /* Patterns configured -- keep it first; see rip_reconfigure why */
struct password_item *passwords; /* Passwords, keep second */
int infinity; /* User configurable data */ int infinity; /* User configurable data */
int port; int port;
@ -128,7 +130,6 @@ struct rip_proto_config {
int garbage_time; int garbage_time;
int timeout_time; int timeout_time;
struct password_item *passwords;
int authtype; int authtype;
#define AT_NONE 0 #define AT_NONE 0
#define AT_PLAINTEXT 2 #define AT_PLAINTEXT 2