From a60ffbc98533a642c5e84a5f76c8246b88147888 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 7 Feb 2019 03:03:34 +0000 Subject: [PATCH] sharpd: Allow nhop tracking to specify connected Allow the sharp daemon to specify whether or not a watched nexthop should be connected or not. Signed-off-by: Donald Sharp --- sharpd/sharp_vty.c | 14 ++++++++------ sharpd/sharp_zebra.c | 4 ++-- sharpd/sharp_zebra.h | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 86c8bfe1c2..9ea9ff02d4 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -49,11 +49,12 @@ uint32_t rts; int32_t repeat; DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd, - "sharp watch nexthop X:X::X:X$nhop", + "sharp watch nexthop X:X::X:X$nhop [connected$connected]", "Sharp routing Protocol\n" "Watch for changes\n" "Watch for nexthop changes\n" - "The v6 nexthop to signal for watching\n") + "The v6 nexthop to signal for watching\n" + "Should the route be connected\n") { struct prefix p; @@ -63,17 +64,18 @@ DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd, memcpy(&p.u.prefix6, &nhop, 16); p.family = AF_INET6; - sharp_zebra_nexthop_watch(&p, true); + sharp_zebra_nexthop_watch(&p, true, !!connected); return CMD_SUCCESS; } DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd, - "sharp watch nexthop A.B.C.D$nhop", + "sharp watch nexthop A.B.C.D$nhop [connected$connected]", "Sharp routing Protocol\n" "Watch for changes\n" "Watch for nexthop changes\n" - "The v4 nexthop to signal for watching\n") + "The v4 nexthop to signal for watching\n" + "Should the route be connected\n") { struct prefix p; @@ -83,7 +85,7 @@ DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd, p.u.prefix4 = nhop; p.family = AF_INET; - sharp_zebra_nexthop_watch(&p, true); + sharp_zebra_nexthop_watch(&p, true, !!connected); return CMD_SUCCESS; } diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index c9f333e34b..f6de086c06 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -328,14 +328,14 @@ void route_delete(struct prefix *p, uint8_t instance) return; } -void sharp_zebra_nexthop_watch(struct prefix *p, bool watch) +void sharp_zebra_nexthop_watch(struct prefix *p, bool watch, bool connected) { int command = ZEBRA_NEXTHOP_REGISTER; if (!watch) command = ZEBRA_NEXTHOP_UNREGISTER; - if (zclient_send_rnh(zclient, command, p, true, VRF_DEFAULT) < 0) + if (zclient_send_rnh(zclient, command, p, connected, VRF_DEFAULT) < 0) zlog_warn("%s: Failure to send nexthop to zebra", __PRETTY_FUNCTION__); } diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h index 7326056cae..7e6ac7670b 100644 --- a/sharpd/sharp_zebra.h +++ b/sharpd/sharp_zebra.h @@ -28,7 +28,8 @@ extern void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label); extern void route_add(struct prefix *p, uint8_t instance, struct nexthop_group *nhg); extern void route_delete(struct prefix *p, uint8_t instance); -extern void sharp_zebra_nexthop_watch(struct prefix *p, bool watch); +extern void sharp_zebra_nexthop_watch(struct prefix *p, bool watch, + bool connected); extern void sharp_install_routes_helper(struct prefix *p, uint8_t instance, struct nexthop_group *nhg, -- 2.39.5