summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nest/protocol.h2
-rw-r--r--nest/route.h2
-rw-r--r--nest/rt-dev.c15
-rw-r--r--nest/rt-table.c14
-rw-r--r--proto/ospf/rt.c7
-rw-r--r--proto/pipe/pipe.c5
-rw-r--r--proto/rip/rip.c8
-rw-r--r--proto/static/static.c10
-rw-r--r--sysdep/unix/krt.c7
9 files changed, 22 insertions, 48 deletions
diff --git a/nest/protocol.h b/nest/protocol.h
index 19f5d070..68f0d5c5 100644
--- a/nest/protocol.h
+++ b/nest/protocol.h
@@ -271,7 +271,7 @@ proto_get_router_id(struct proto_config *pc)
}
/* Moved from route.h to avoid dependency conflicts */
-static inline void rte_update(struct proto *p, net *net, rte *new) { rte_update2(p->main_channel, net, new, p->main_source); }
+static inline void rte_update(struct proto *p, net_addr *n, rte *new) { rte_update2(p->main_channel, n, new, p->main_source); }
extern list proto_list;
diff --git a/nest/route.h b/nest/route.h
index 22fca331..5f34d47a 100644
--- a/nest/route.h
+++ b/nest/route.h
@@ -276,7 +276,7 @@ static inline net *net_get(rtable *tab, const net_addr *addr) { return (net *) f
rte *rte_find(net *net, struct rte_src *src);
rte *rte_get_temp(struct rta *);
-void rte_update2(struct channel *c, net *net, rte *new, struct rte_src *src);
+void rte_update2(struct channel *c, net_addr *n, rte *new, struct rte_src *src);
/* rte_update() moved to protocol.h to avoid dependency conflicts */
void rte_discard(rtable *tab, rte *old);
int rt_examine(rtable *t, net_addr *a, struct proto *p, struct filter *filter);
diff --git a/nest/rt-dev.c b/nest/rt-dev.c
index a996f4fc..098885b9 100644
--- a/nest/rt-dev.c
+++ b/nest/rt-dev.c
@@ -55,24 +55,15 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad)
if (flags & IF_CHANGE_DOWN)
{
- net *n;
-
DBG("dev_if_notify: %s:%I going down\n", ad->iface->name, ad->ip);
- n = net_find(c->table, &ad->prefix);
- if (!n)
- {
- DBG("dev_if_notify: device shutdown: prefix not found\n");
- return;
- }
/* Use iface ID as local source ID */
struct rte_src *src = rt_get_source(P, ad->iface->index);
- rte_update2(c, n, NULL, src);
+ rte_update2(c, &ad->prefix, NULL, src);
}
else if (flags & IF_CHANGE_UP)
{
rta *a;
- net *n;
rte *e;
DBG("dev_if_notify: %s:%I going up\n", ad->iface->name, ad->ip);
@@ -90,11 +81,9 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad)
};
a = rta_lookup(&a0);
- n = net_get(c->table, &ad->prefix);
e = rte_get_temp(a);
- e->net = n;
e->pflags = 0;
- rte_update2(c, n, e, src);
+ rte_update2(c, &ad->prefix, e, src);
}
}
diff --git a/nest/rt-table.c b/nest/rt-table.c
index 03ab3b92..9614d9ef 100644
--- a/nest/rt-table.c
+++ b/nest/rt-table.c
@@ -1267,19 +1267,23 @@ rte_unhide_dummy_routes(net *net, rte **dummy)
*/
void
-rte_update2(struct channel *c, net *net, rte *new, struct rte_src *src)
+rte_update2(struct channel *c, net_addr *n, rte *new, struct rte_src *src)
{
struct proto *p = c->proto;
struct proto_stats *stats = &c->stats;
struct filter *filter = c->in_filter;
ea_list *tmpa = NULL;
rte *dummy = NULL;
+ net *nn;
ASSERT(c->channel_state == CS_UP);
rte_update_lock();
if (new)
{
+ nn = net_get(c->table, n);
+
+ new->net = nn;
new->sender = c;
if (!new->pref)
@@ -1333,7 +1337,7 @@ rte_update2(struct channel *c, net *net, rte *new, struct rte_src *src)
{
stats->imp_withdraws_received++;
- if (!net || !src)
+ if (!(nn = net_find(c->table, n)) || !src)
{
stats->imp_withdraws_ignored++;
rte_update_unlock();
@@ -1342,9 +1346,9 @@ rte_update2(struct channel *c, net *net, rte *new, struct rte_src *src)
}
recalc:
- rte_hide_dummy_routes(net, &dummy);
- rte_recalculate(c, net, new, src);
- rte_unhide_dummy_routes(net, &dummy);
+ rte_hide_dummy_routes(nn, &dummy);
+ rte_recalculate(c, nn, new, src);
+ rte_unhide_dummy_routes(nn, &dummy);
rte_update_unlock();
return;
diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c
index 0855f21f..5538f4c8 100644
--- a/proto/ospf/rt.c
+++ b/proto/ospf/rt.c
@@ -1973,7 +1973,6 @@ again1:
if (reload || ort_changed(nf, &a0))
{
- net *ne = net_get(p->p.main_channel->table, nf->fn.addr);
rta *a = rta_lookup(&a0);
rte *e = rte_get_temp(a);
@@ -1984,11 +1983,10 @@ again1:
e->u.ospf.tag = nf->old_tag = nf->n.tag;
e->u.ospf.router_id = nf->old_rid = nf->n.rid;
e->pflags = 0;
- e->net = ne;
DBG("Mod rte type %d - %N via %I on iface %s, met %d\n",
a0.source, nf->fn.addr, a0.gw, a0.iface ? a0.iface->name : "(none)", nf->n.metric1);
- rte_update(&p->p, ne, e);
+ rte_update(&p->p, nf->fn.addr, e);
}
}
else if (nf->old_rta)
@@ -1997,8 +1995,7 @@ again1:
rta_free(nf->old_rta);
nf->old_rta = NULL;
- net *ne = net_get(p->p.main_channel->table, nf->fn.addr);
- rte_update(&p->p, ne, NULL);
+ rte_update(&p->p, nf->fn.addr, NULL);
}
/* Remove unused rt entry, some special entries are persistent */
diff --git a/proto/pipe/pipe.c b/proto/pipe/pipe.c
index f3df3e71..d40b3f91 100644
--- a/proto/pipe/pipe.c
+++ b/proto/pipe/pipe.c
@@ -50,7 +50,6 @@ pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *o
struct channel *dst = (src_ch == p->pri) ? p->sec : p->pri;
struct rte_src *src;
- net *nn;
rte *e;
rta a;
@@ -64,7 +63,6 @@ pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *o
return;
}
- nn = net_get(dst->table, n->n.addr);
if (new)
{
memcpy(&a, new->attrs, sizeof(rta));
@@ -73,7 +71,6 @@ pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *o
a.eattrs = attrs;
a.hostentry = NULL;
e = rte_get_temp(&a);
- e->net = nn;
e->pflags = 0;
/* Copy protocol specific embedded attributes. */
@@ -90,7 +87,7 @@ pipe_rt_notify(struct proto *P, struct channel *src_ch, net *n, rte *new, rte *o
}
src_ch->table->pipe_busy = 1;
- rte_update2(dst, nn, e, src);
+ rte_update2(dst, n->n.addr, e, src);
src_ch->table->pipe_busy = 0;
}
diff --git a/proto/rip/rip.c b/proto/rip/rip.c
index 22023279..131c09ce 100644
--- a/proto/rip/rip.c
+++ b/proto/rip/rip.c
@@ -143,8 +143,6 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en)
if (rt)
{
/* Update */
- net *n = net_get(p->p.main_channel->table, en->n.addr);
-
rta a0 = {
.src = p->p.main_source,
.source = RTS_RIP,
@@ -204,16 +202,14 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en)
e->u.rip.metric = rt_metric;
e->u.rip.tag = rt_tag;
- e->net = n;
e->pflags = 0;
- rte_update(&p->p, n, e);
+ rte_update(&p->p, en->n.addr, e);
}
else
{
/* Withdraw */
- net *n = net_find(p->p.main_channel->table, en->n.addr);
- rte_update(&p->p, n, NULL);
+ rte_update(&p->p, en->n.addr, NULL);
}
}
diff --git a/proto/static/static.c b/proto/static/static.c
index 6239fccb..28cb1e77 100644
--- a/proto/static/static.c
+++ b/proto/static/static.c
@@ -60,7 +60,6 @@ p_igp_table(struct proto *p)
static void
static_install(struct proto *p, struct static_route *r, struct iface *ifa)
{
- net *n;
rta a;
rte *e;
@@ -112,15 +111,13 @@ static_install(struct proto *p, struct static_route *r, struct iface *ifa)
/* We skip rta_lookup() here */
- n = net_get(p->main_channel->table, r->net);
e = rte_get_temp(&a);
- e->net = n;
e->pflags = 0;
if (r->cmds)
f_eval_rte(r->cmds, &e, static_lp);
- rte_update(p, n, e);
+ rte_update(p, r->net, e);
r->installed = 1;
if (r->cmds)
@@ -130,14 +127,11 @@ static_install(struct proto *p, struct static_route *r, struct iface *ifa)
static void
static_remove(struct proto *p, struct static_route *r)
{
- net *n;
-
if (!r->installed)
return;
DBG("Removing static route %N via %I\n", r->net, r->via);
- n = net_find(p->main_channel->table, r->net);
- rte_update(p, n, NULL);
+ rte_update(p, r->net, NULL);
r->installed = 0;
}
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c
index 6b3b4eee..fe8af1c0 100644
--- a/sysdep/unix/krt.c
+++ b/sysdep/unix/krt.c
@@ -345,18 +345,15 @@ krt_learn_announce_update(struct krt_proto *p, rte *e)
net *n = e->net;
rta *aa = rta_clone(e->attrs);
rte *ee = rte_get_temp(aa);
- net *nn = net_get(p->p.main_channel->table, n->n.addr);
- ee->net = nn;
ee->pflags = 0;
ee->u.krt = e->u.krt;
- rte_update(&p->p, nn, ee);
+ rte_update(&p->p, n->n.addr, ee);
}
static void
krt_learn_announce_delete(struct krt_proto *p, net *n)
{
- n = net_find(p->p.main_channel->table, n->n.addr);
- rte_update(&p->p, n, NULL);
+ rte_update(&p->p, n->n.addr, NULL);
}
/* Called when alien route is discovered during scan */