From 2003a1840731bd57365876e48c96c5a1ea0348cb Mon Sep 17 00:00:00 2001 From: Jan Moskyto Matejka Date: Fri, 8 Apr 2016 13:08:03 +0200 Subject: 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. --- nest/rt-table.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'nest/rt-table.c') 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; -- cgit v1.2.3