diff options
Diffstat (limited to 'proto/rip')
-rw-r--r-- | proto/rip/rip.c | 40 | ||||
-rw-r--r-- | proto/rip/rip.h | 1 |
2 files changed, 18 insertions, 23 deletions
diff --git a/proto/rip/rip.c b/proto/rip/rip.c index ad285bb3..5cc40403 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -263,16 +263,18 @@ find_interface(struct proto *p, struct iface *what) * This part is responsible for any updates that come from network */ +static int rip_rte_better(struct rte *new, struct rte *old); + static void rip_rte_update_if_better(rtable *tab, net *net, struct proto *p, rte *new) { rte *old; - old = rte_find(net, p); - if (!old || p->rte_better(new, old) || + old = rte_find(net, p->main_source); + if (!old || rip_rte_better(new, old) || (ipa_equal(old->attrs->from, new->attrs->from) && (old->u.rip.metric != new->u.rip.metric)) ) - rte_update(tab, net, p, p, new); + rte_update(p, net, new); else rte_free(new); } @@ -295,7 +297,7 @@ advertise_entry( struct proto *p, struct rip_block *b, ip_addr whotoldme, struct int pxlen; bzero(&A, sizeof(A)); - A.proto = p; + A.src= p->main_source; A.source = RTS_RIP; A.scope = SCOPE_UNIVERSE; A.cast = RTC_UNICAST; @@ -614,20 +616,10 @@ rip_start(struct proto *p) add_head( &P->interfaces, NODE rif ); CHK_MAGIC; - rip_init_instance(p); - DBG( "RIP: ...done\n"); return PS_UP; } -static struct proto * -rip_init(struct proto_config *cfg) -{ - struct proto *p = proto_new(cfg, sizeof(struct rip_proto)); - - return p; -} - static void rip_dump(struct proto *p) { @@ -855,7 +847,7 @@ rip_gen_attrs(struct linpool *pool, int metric, u16 tag) static int rip_import_control(struct proto *p, struct rte **rt, struct ea_list **attrs, struct linpool *pool) { - if ((*rt)->attrs->proto == p) /* My own must not be touched */ + if ((*rt)->attrs->src->proto == p) /* My own must not be touched */ return 1; if ((*rt)->attrs->source != RTS_RIP) { @@ -907,7 +899,7 @@ rip_rt_notify(struct proto *p, struct rtable *table UNUSED, struct network *net, if (e->metric > P_CF->infinity) e->metric = P_CF->infinity; - if (new->attrs->proto == p) + if (new->attrs->src->proto == p) e->whotoldme = new->attrs->from; if (!e->metric) /* That's okay: this way user can set his own value for external @@ -929,7 +921,7 @@ rip_rte_same(struct rte *new, struct rte *old) static int rip_rte_better(struct rte *new, struct rte *old) { - struct proto *p = new->attrs->proto; + struct proto *p = new->attrs->src->proto; if (ipa_equal(old->attrs->from, new->attrs->from)) return 1; @@ -940,7 +932,7 @@ rip_rte_better(struct rte *new, struct rte *old) if (old->u.rip.metric > new->u.rip.metric) return 1; - if (old->attrs->proto == new->attrs->proto) /* This does not make much sense for different protocols */ + if (old->attrs->src->proto == new->attrs->src->proto) /* This does not make much sense for different protocols */ if ((old->u.rip.metric == new->u.rip.metric) && ((now - old->lastmod) > (P_CF->timeout_time / 2))) return 1; @@ -956,7 +948,7 @@ rip_rte_better(struct rte *new, struct rte *old) static void rip_rte_insert(net *net UNUSED, rte *rte) { - struct proto *p = rte->attrs->proto; + struct proto *p = rte->attrs->src->proto; CHK_MAGIC; DBG( "rip_rte_insert: %p\n", rte ); add_head( &P->garbage, &rte->u.rip.garbage ); @@ -969,16 +961,18 @@ static void rip_rte_remove(net *net UNUSED, rte *rte) { #ifdef LOCAL_DEBUG - struct proto *p = rte->attrs->proto; + struct proto *p = rte->attrs->src->proto; CHK_MAGIC; DBG( "rip_rte_remove: %p\n", rte ); #endif rem_node( &rte->u.rip.garbage ); } -void -rip_init_instance(struct proto *p) +static struct proto * +rip_init(struct proto_config *cfg) { + struct proto *p = proto_new(cfg, sizeof(struct rip_proto)); + p->accept_ra_types = RA_OPTIMAL; p->if_notify = rip_if_notify; p->rt_notify = rip_rt_notify; @@ -989,6 +983,8 @@ rip_init_instance(struct proto *p) p->rte_same = rip_rte_same; p->rte_insert = rip_rte_insert; p->rte_remove = rip_rte_remove; + + return p; } void diff --git a/proto/rip/rip.h b/proto/rip/rip.h index 6e0d5aad..2a327260 100644 --- a/proto/rip/rip.h +++ b/proto/rip/rip.h @@ -177,7 +177,6 @@ struct rip_proto { #endif -void rip_init_instance(struct proto *p); void rip_init_config(struct rip_proto_config *c); /* Authentication functions */ |