]> git.puffer.fish Git - mirror/frr.git/commitdiff
staticd: Install known nexthops upon connection with zebra 18367/head
authorDonald Sharp <sharpd@nvidia.com>
Wed, 12 Mar 2025 12:30:43 +0000 (08:30 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 12 Mar 2025 12:30:43 +0000 (08:30 -0400)
CI tests are showing cases where staticd is connecting to
zebra after config is read in and the nexthops are never
being registered w/ zebra:

2025/03/11 15:39:44 STATIC: [T83RR-8SM5G] staticd 10.4-dev starting: vty@2616
2025/03/11 15:39:45 STATIC: [GH3PB-C7X4Y] Static Route to 13.13.13.13/32 not installed currently because dependent config not fully available
2025/03/11 15:39:45 STATIC: [RHJK1-M5FAR] static_zebra_nht_register: Failure to send nexthop 1.1.1.2/32 for 11.11.11.11/32 to zebra
2025/03/11 15:39:45 STATIC: [M7Q4P-46WDR] vty[14]@> enable

Zebra shows connection time as:

2025/03/11 15:39:45.933343 ZEBRA: [V98V0-MTWPF] client 5 says hello and bids fair to announce only static routes vrf=0

As a result staticd never installs the route because it has no nexthop
tracking to say that the route could be installed.

Modify staticd on startup to go through it's nexthops and dump them to
zebra to allow the staticd state machine to get to work.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
staticd/static_routes.c
staticd/static_routes.h
staticd/static_zebra.c

index 82eabd8d564a3075baf2bb61d189caffd10de0c3..d549df70fef361bca201dad957985cfb009d81e7 100644 (file)
@@ -368,6 +368,36 @@ static void static_ifindex_update_nh(struct interface *ifp, bool up,
        static_install_path(pn);
 }
 
+void static_install_nexthops_on_startup(void)
+{
+       struct route_table *stable;
+       struct route_node *rn;
+       struct static_nexthop *nh;
+       struct static_path *pn;
+       struct static_vrf *svrf;
+       struct static_route_info *si;
+       afi_t afi;
+       safi_t safi;
+
+       RB_FOREACH (svrf, svrf_name_head, &svrfs) {
+               FOREACH_AFI_SAFI (afi, safi) {
+                       stable = static_vrf_static_table(afi, safi, svrf);
+                       if (!stable)
+                               continue;
+                       for (rn = route_top(stable); rn; rn = srcdest_route_next(rn)) {
+                               si = static_route_info_from_rnode(rn);
+                               if (!si)
+                                       continue;
+                               frr_each (static_path_list, &si->path_list, pn) {
+                                       frr_each (static_nexthop_list, &pn->nexthop_list, nh) {
+                                               static_zebra_nht_register(nh, true);
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
 static void static_ifindex_update_af(struct interface *ifp, bool up, afi_t afi,
                                     safi_t safi)
 {
index 2e2e4986c348dcbba9603a14457692f7a266dd91..7f4936e0b9ed2a683a06f9b9823a603ee29ae89f 100644 (file)
@@ -264,6 +264,7 @@ extern void static_bfd_initialize(struct zclient *zc, struct event_loop *tm);
 
 extern void static_bfd_show(struct vty *vty, bool isjson);
 
+extern void static_install_nexthops_on_startup(void);
 #ifdef __cplusplus
 }
 #endif
index a6521cccc6ab95988138c67dcb77b839a25c6a47..3ed525f386fd6159407e5c47bbfd7d9a5ec38a35 100644 (file)
@@ -181,6 +181,12 @@ static void zebra_connected(struct zclient *zclient)
        vrf = vrf_lookup_by_id(VRF_DEFAULT);
        assert(vrf);
        static_fixup_vrf_ids(vrf);
+
+       /*
+        * It's possible that staticd connected after config was read
+        * in.
+        */
+       static_install_nexthops_on_startup();
 }
 
 /* API to check whether the configured nexthop address is