]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Properly note that a nhg's nexthop has gone down
authorDonald Sharp <sharpd@nvidia.com>
Wed, 7 Feb 2024 19:56:15 +0000 (14:56 -0500)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Tue, 23 Jul 2024 14:50:46 +0000 (14:50 +0000)
Current code when a link is set down is to just mark the
nexthop group as not properly setup.  Leaving situations
where when an interface goes down and show output is
entered we see incorrect state.  This is true for anything
that would be checking those flags at that point in time.

Modify the interface down nexthop group code to notice the
nexthops appropriately ( and I mean set the appropriate flags )
and to allow a `show ip route` command to actually display
what is going on with the nexthops.

eva# show ip route 1.0.0.0
Routing entry for 1.0.0.0/32
  Known via "sharp", distance 150, metric 0, best
  Last update 00:00:06 ago
  * 192.168.44.33, via dummy1, weight 1
  * 192.168.45.33, via dummy2, weight 1

sharpd@eva:~/frr1$ sudo ip link set dummy2 down

eva# show ip route 1.0.0.0
Routing entry for 1.0.0.0/32
  Known via "sharp", distance 150, metric 0, best
  Last update 00:00:12 ago
  * 192.168.44.33, via dummy1, weight 1
    192.168.45.33, via dummy2 inactive, weight 1

Notice now that the 1.0.0.0/32 route now correctly
displays the route for the nexthop group entry.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 266b0619942edd8d838235e14dc0cb71a772f585)

tests/topotests/isis_tilfa_topo1/rt5/step10/show_ip_route.ref
zebra/zebra_nhg.c
zebra/zebra_vty.c

index 06f432c455de0e13b9c94e46c192705370eab8ed..ff8ace25be5d84d55e172ade4776b8a81a744ce3 100644 (file)
           "fib":true,
           "ip":"10.0.8.6",
           "afi":"ipv4",
-          "interfaceName":"eth-rt6",
-          "active":true
+          "interfaceName":"eth-rt6"
         }
       ]
     }
index 1246e4dba22bb981934f2579f2d347734e74b005..9971b198369f4e24dbab144dd9eb9dbc81b56e4e 100644 (file)
@@ -1050,8 +1050,27 @@ static void zebra_nhg_set_valid(struct nhg_hash_entry *nhe, bool valid)
        }
 
        /* Update validity of nexthops depending on it */
-       frr_each(nhg_connected_tree, &nhe->nhg_dependents, rb_node_dep)
+       frr_each (nhg_connected_tree, &nhe->nhg_dependents, rb_node_dep) {
+               if (!valid) {
+                       /*
+                        * Grab the first nexthop from the depending nexthop group
+                        * then let's find the nexthop in that group that matches
+                        * my individual nexthop and mark it as no longer ACTIVE
+                        */
+                       struct nexthop *nexthop = rb_node_dep->nhe->nhg.nexthop;
+
+                       while (nexthop) {
+                               if (nexthop_same(nexthop, nhe->nhg.nexthop))
+                                       break;
+
+                               nexthop = nexthop->next;
+                       }
+
+                       if (nexthop)
+                               UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
+               }
                zebra_nhg_set_valid(rb_node_dep->nhe, valid);
+       }
 }
 
 void zebra_nhg_check_valid(struct nhg_hash_entry *nhe)
@@ -1059,6 +1078,13 @@ void zebra_nhg_check_valid(struct nhg_hash_entry *nhe)
        struct nhg_connected *rb_node_dep = NULL;
        bool valid = false;
 
+       /*
+        * If I have other nhe's depending on me, then this is a
+        * singleton nhe so set this nexthops flag as appropriate.
+        */
+       if (nhg_connected_tree_count(&nhe->nhg_depends))
+               UNSET_FLAG(nhe->nhg.nexthop->flags, NEXTHOP_FLAG_ACTIVE);
+
        /* If anthing else in the group is valid, the group is valid */
        frr_each(nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) {
                if (CHECK_FLAG(rb_node_dep->nhe->flags, NEXTHOP_GROUP_VALID)) {
index c31218a7c367487d90eaf122d0f01eb5c028d303..ae82d20141832b0cdbfa6d25b5ac6790107b0fa5 100644 (file)
@@ -215,7 +215,7 @@ static char re_status_output_char(const struct route_entry *re,
                        if (is_fib) {
                                star_p = !!CHECK_FLAG(nhop->flags,
                                                      NEXTHOP_FLAG_FIB);
-                       } else
+                       } else if (CHECK_FLAG(nhop->flags, NEXTHOP_FLAG_ACTIVE))
                                star_p = true;
                }