Browse Source

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>
Timo Teräs 6 years ago
parent
commit
7e73eb740f
2 changed files with 12 additions and 7 deletions
  1. 10 6
      zebra/zebra_rib.c
  2. 2 1
      zebra/zebra_vty.c

+ 10 - 6
zebra/zebra_rib.c

@@ -1078,7 +1078,6 @@ nexthop_active_update (struct route_node *rn, struct rib *rib, int set)
   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 @@ rib_update_kernel (struct route_node *rn, struct rib *old, struct rib *new)
 
   /* 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 @@ rib_process (struct route_node *rn)
 
   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 @@ rib_process (struct route_node *rn)
   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

+ 2 - 1
zebra/zebra_vty.c

@@ -1341,7 +1341,8 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
 
       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 ? "  " : "");