]> git.puffer.fish Git - matthieu/frr.git/commitdiff
sharpd: Allow sharpd to watch nexthops in the mrib
authorDonald Sharp <sharpd@nvidia.com>
Sat, 26 Oct 2024 01:21:32 +0000 (21:21 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 30 Oct 2024 11:45:02 +0000 (07:45 -0400)
Nothing special here, just allow sharpd to ask to watch
nexthops in the mrib.

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

sharpd/sharp_vty.c
sharpd/sharp_zebra.c
sharpd/sharp_zebra.h

index 21c596bf7124abed20d81aa0c7851901a08be1cc..c9211a152ffbdb1c5f50751e87bfb897d16a642c 100644 (file)
@@ -82,7 +82,7 @@ DEFPY(watch_redistribute, watch_redistribute_cmd,
 }
 
 DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
-      "sharp watch [vrf NAME$vrf_name] <nexthop$n X:X::X:X$nhop|import$import X:X::X:X/M$inhop>  [connected$connected]",
+      "sharp watch [vrf NAME$vrf_name] <nexthop$n X:X::X:X$nhop|import$import X:X::X:X/M$inhop>  [connected$connected] [mrib$mrib]",
       "Sharp routing Protocol\n"
       "Watch for changes\n"
       "The vrf we would like to watch if non-default\n"
@@ -91,7 +91,8 @@ DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
       "The v6 nexthop to signal for watching\n"
       "Watch for import check changes\n"
       "The v6 prefix to signal for watching\n"
-      "Should the route be connected\n")
+      "Should the route be connected\n"
+      "In the Multicast rib\n")
 {
        struct vrf *vrf;
        struct prefix p;
@@ -119,14 +120,13 @@ DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
        }
 
        sharp_nh_tracker_get(&p);
-       sharp_zebra_nexthop_watch(&p, vrf->vrf_id, type_import,
-                                 true, !!connected);
+       sharp_zebra_nexthop_watch(&p, vrf->vrf_id, type_import, true, !!connected, !!mrib);
 
        return CMD_SUCCESS;
 }
 
 DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
-      "sharp watch [vrf NAME$vrf_name] <nexthop$n A.B.C.D$nhop|import$import A.B.C.D/M$inhop> [connected$connected]",
+      "sharp watch [vrf NAME$vrf_name] <nexthop$n A.B.C.D$nhop|import$import A.B.C.D/M$inhop> [connected$connected] [mrib$mrib]",
       "Sharp routing Protocol\n"
       "Watch for changes\n"
       "The vrf we would like to watch if non-default\n"
@@ -135,7 +135,8 @@ DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
       "The v4 address to signal for watching\n"
       "Watch for import check changes\n"
       "The v4 prefix for import check to watch\n"
-      "Should the route be connected\n")
+      "Should the route be connected\n"
+      "In the Multicast rib\n")
 {
        struct vrf *vrf;
        struct prefix p;
@@ -164,8 +165,7 @@ DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
        }
 
        sharp_nh_tracker_get(&p);
-       sharp_zebra_nexthop_watch(&p, vrf->vrf_id, type_import,
-                                 true, !!connected);
+       sharp_zebra_nexthop_watch(&p, vrf->vrf_id, type_import, true, !!connected, !!mrib);
 
        return CMD_SUCCESS;
 }
index 1048436b43130b9bc5b1aff9a7cc87246a1cafc1..4447b69bf6199d7abc8a0f3cfc9058338ee26f16 100644 (file)
@@ -618,18 +618,19 @@ void nhg_del(uint32_t id)
        zclient_nhg_send(zclient, ZEBRA_NHG_DEL, &api_nhg);
 }
 
-void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import,
-                              bool watch, bool connected)
+void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import, bool watch,
+                              bool connected, bool mrib)
 {
-       int command;
+       int command = ZEBRA_NEXTHOP_REGISTER;
+       safi_t safi = mrib ? SAFI_MULTICAST : SAFI_UNICAST;
 
        command = ZEBRA_NEXTHOP_REGISTER;
 
        if (!watch)
                command = ZEBRA_NEXTHOP_UNREGISTER;
 
-       if (zclient_send_rnh(zclient, command, p, SAFI_UNICAST, connected,
-                            false, vrf_id) == ZCLIENT_SEND_FAILURE)
+       if (zclient_send_rnh(zclient, command, p, safi, connected, false, vrf_id) ==
+           ZCLIENT_SEND_FAILURE)
                zlog_warn("%s: Failure to send nexthop to zebra", __func__);
 }
 
index 5cbcc146654cc7b2b22c215e08737e03fdf88043..7a86897beb543bb2a85f56b7ce7676f87f4f113c 100644 (file)
@@ -18,8 +18,8 @@ extern void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label);
 extern void nhg_add(uint32_t id, const struct nexthop_group *nhg,
                    const struct nexthop_group *backup_nhg);
 extern void nhg_del(uint32_t id);
-extern void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id,
-                                     bool import, bool watch, bool connected);
+extern void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import, bool watch,
+                                     bool connected, bool mrib);
 
 extern void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id,
                                        uint8_t instance, uint32_t nhgid,