zebra: handle multihop nexthop changes properly
The rib entries are normally added and deleted when they are
changed. However, they are modified in placae when the nexthop
reachability changes. This fixes to:
- properly detect nexthop changes from nexthop_active_update()
calls from rib_process()
- rib_update_kernel() to not reset FIB flags when a RIB entry
is being modifed (old and new RIB are same)
- improves the "show ip route <prefix>" output to display
both ACTIVE and FIB flags for each nexthop
Fixes: 325823a5 "zebra: support FIB override routes"
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Reported-By: Igor Ryzhov <iryzhov@nfware.com>
Tested-by: NetDEF CI System <cisystem@netdef.org>
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 1650dab..18eece8 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -1078,7 +1078,6 @@
ifindex_t prev_index;
rib->nexthop_active_num = 0;
- UNSET_FLAG (rib->status, RIB_ENTRY_CHANGED);
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
{
@@ -1124,12 +1123,15 @@
/* This condition is never met, if we are using rt_socket.c */
if (ret < 0 && new)
+ {
for (ALL_NEXTHOPS_RO(new->nexthop, nexthop, tnexthop, recursing))
UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
-
- if (old)
- for (ALL_NEXTHOPS_RO(old->nexthop, nexthop, tnexthop, recursing))
- UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
+ }
+ else if (old && old != new)
+ {
+ for (ALL_NEXTHOPS_RO(old->nexthop, nexthop, tnexthop, recursing))
+ UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB);
+ }
return ret;
}
@@ -1275,6 +1277,8 @@
RNODE_FOREACH_RIB (rn, rib)
{
+ UNSET_FLAG (rib->status, RIB_ENTRY_CHANGED);
+
/* Currently installed rib. */
if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
{
@@ -1323,7 +1327,7 @@
if (new_fib)
nexthop_active_update (rn, new_fib, 1);
if (new_selected && new_selected != new_fib)
- nexthop_active_update (rn, new_selected, 1);
+ nexthop_active_update (rn, new_selected, 1);
/* Update kernel if FIB entry has changed */
if (old_fib != new_fib
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 21b92ea..028b744 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -1341,7 +1341,8 @@
for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
{
- vty_out (vty, " %c%s",
+ vty_out (vty, " %c%c%s",
+ CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE) ? '>' : ' ',
CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
recursing ? " " : "");