sharpd: Allow sharpd to watch nexthops in the mrib

Nothing special here, just allow sharpd to ask to watch
nexthops in the mrib.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2024-10-25 21:21:32 -04:00
parent ea0b8a0364
commit aff8eaa4a2
3 changed files with 16 additions and 15 deletions

View file

@ -82,7 +82,7 @@ DEFPY(watch_redistribute, watch_redistribute_cmd,
} }
DEFPY(watch_nexthop_v6, watch_nexthop_v6_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" "Sharp routing Protocol\n"
"Watch for changes\n" "Watch for changes\n"
"The vrf we would like to watch if non-default\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" "The v6 nexthop to signal for watching\n"
"Watch for import check changes\n" "Watch for import check changes\n"
"The v6 prefix to signal for watching\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 vrf *vrf;
struct prefix p; struct prefix p;
@ -119,14 +120,13 @@ DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
} }
sharp_nh_tracker_get(&p); sharp_nh_tracker_get(&p);
sharp_zebra_nexthop_watch(&p, vrf->vrf_id, type_import, sharp_zebra_nexthop_watch(&p, vrf->vrf_id, type_import, true, !!connected, !!mrib);
true, !!connected);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd, 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" "Sharp routing Protocol\n"
"Watch for changes\n" "Watch for changes\n"
"The vrf we would like to watch if non-default\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" "The v4 address to signal for watching\n"
"Watch for import check changes\n" "Watch for import check changes\n"
"The v4 prefix for import check to watch\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 vrf *vrf;
struct prefix p; struct prefix p;
@ -164,8 +165,7 @@ DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
} }
sharp_nh_tracker_get(&p); sharp_nh_tracker_get(&p);
sharp_zebra_nexthop_watch(&p, vrf->vrf_id, type_import, sharp_zebra_nexthop_watch(&p, vrf->vrf_id, type_import, true, !!connected, !!mrib);
true, !!connected);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View file

@ -618,18 +618,19 @@ void nhg_del(uint32_t id)
zclient_nhg_send(zclient, ZEBRA_NHG_DEL, &api_nhg); zclient_nhg_send(zclient, ZEBRA_NHG_DEL, &api_nhg);
} }
void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import, void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import, bool watch,
bool watch, bool connected) bool connected, bool mrib)
{ {
int command; int command = ZEBRA_NEXTHOP_REGISTER;
safi_t safi = mrib ? SAFI_MULTICAST : SAFI_UNICAST;
command = ZEBRA_NEXTHOP_REGISTER; command = ZEBRA_NEXTHOP_REGISTER;
if (!watch) if (!watch)
command = ZEBRA_NEXTHOP_UNREGISTER; command = ZEBRA_NEXTHOP_UNREGISTER;
if (zclient_send_rnh(zclient, command, p, SAFI_UNICAST, connected, if (zclient_send_rnh(zclient, command, p, safi, connected, false, vrf_id) ==
false, vrf_id) == ZCLIENT_SEND_FAILURE) ZCLIENT_SEND_FAILURE)
zlog_warn("%s: Failure to send nexthop to zebra", __func__); zlog_warn("%s: Failure to send nexthop to zebra", __func__);
} }

View 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, extern void nhg_add(uint32_t id, const struct nexthop_group *nhg,
const struct nexthop_group *backup_nhg); const struct nexthop_group *backup_nhg);
extern void nhg_del(uint32_t id); extern void nhg_del(uint32_t id);
extern void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, extern void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import, bool watch,
bool import, bool watch, bool connected); bool connected, bool mrib);
extern void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id, extern void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id,
uint8_t instance, uint32_t nhgid, uint8_t instance, uint32_t nhgid,