diff options
author | Jan Moskyto Matejka <mq@ucw.cz> | 2016-04-08 13:08:03 +0200 |
---|---|---|
committer | Jan Moskyto Matejka <mq@ucw.cz> | 2016-04-08 13:09:06 +0200 |
commit | 2003a1840731bd57365876e48c96c5a1ea0348cb (patch) | |
tree | c473a93f4027ea2706ccac3502ccef36736fbb6d /proto | |
parent | 4bdf1881dc6230b742d7efcaad8eeac4ed25f445 (diff) |
Route update: move table lookup from protocols into rte_update2().
Many protocols do almost the same when creating a rte_update request
before calling rte_update2(). This commit should simplify the protocol
side of the route-creation routine.
Diffstat (limited to 'proto')
-rw-r--r-- | proto/ospf/rt.c | 7 | ||||
-rw-r--r-- | proto/pipe/pipe.c | 5 | ||||
-rw-r--r-- | proto/rip/rip.c | 8 | ||||
-rw-r--r-- | proto/static/static.c | 10 |
4 files changed, 7 insertions, 23 deletions
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; } |