From: Ondrej Zajicek (work) Date: Thu, 16 Jul 2020 13:08:03 +0000 (+0200) Subject: Nest: Keep route ordering during route updates X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00cf501a0a74ee33307deddd0adf59942d634da3;p=thirdparty%2Fbird.git Nest: Keep route ordering during route updates Put new non-best routes to the end of list instead of the second position. Put updated routes to their old position. Position is changed just by best route selection. --- diff --git a/nest/rt-table.c b/nest/rt-table.c index 5983bd4c4..5422997ec 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -1177,6 +1177,9 @@ rte_recalculate(struct channel *c, net *net, rte *new, struct rte_src *src) before_old = old; } + /* Save the last accessed position */ + rte **pos = k; + if (!old) before_old = NULL; @@ -1308,8 +1311,8 @@ rte_recalculate(struct channel *c, net *net, rte *new, struct rte_src *src) /* Add the new route to the list */ if (new) { - new->next = net->routes; - net->routes = new; + new->next = *pos; + *pos = new; } /* Find a new optimal route (if there is any) */ @@ -1332,11 +1335,10 @@ rte_recalculate(struct channel *c, net *net, rte *new, struct rte_src *src) /* The third case - the new route is not better than the old best route (therefore old_best != NULL) and the old best route was not removed (therefore old_best == net->routes). - We just link the new route after the old best route. */ + We just link the new route to the old/last position. */ - ASSERT(net->routes != NULL); - new->next = net->routes->next; - net->routes->next = new; + new->next = *pos; + *pos = new; } /* The fourth (empty) case - suboptimal route was removed, nothing to do */ }