From 2eebb680c20bbf22246f43f5b6516cf0b4d1f96d Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Sun, 7 Apr 2024 13:23:59 +0200 Subject: [PATCH] Fixed best route announcements after NHU When more routes in one net changed at once, the best route announcements were inconsistent which confused exporters. --- nest/rt-table.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/nest/rt-table.c b/nest/rt-table.c index d374bb0b..f1b13872 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -3464,20 +3464,55 @@ rt_next_hop_update_net(struct rtable_private *tab, struct netindex *ni, net *n) n->routes = new; } + /* Now we have to announce the routes the right way, to not cause any + * strange problems with consistency. */ + + ASSERT_DIE(updates[0].old == old_best); + + /* Find new best route original position */ + uint nbpos = ~0; + for (uint i=0; ireq, &updates[nbpos].new, + best_indicator[1][0]); + rte_announce(tab, ni, n, + &updates[nbpos].new_stored->rte, &updates[nbpos].old->rte, + &new->rte, &old_best->rte); + } + else + nbpos = 0; + uint total = 0; /* Announce the changes */ for (uint i=0; irte.src == updates[i].new.src), ob = (i == 0); - const char *best_indicator[2][2] = { - { "autoupdated", "autoupdated [-best]" }, - { "autoupdated [+best]", "autoupdated [best]" } - }; rt_rte_trace_in(D_ROUTES, updates[i].new.sender->req, &updates[i].new, best_indicator[nb][ob]); - rte_announce(tab, ni, n, &updates[i].new_stored->rte, &updates[i].old->rte, &new->rte, &old_best->rte); + rte_announce(tab, ni, n, + &updates[i].new_stored->rte, &updates[i].old->rte, + &new->rte, (!nbpos && !i) ? &old_best->rte : &new->rte); total++; }