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@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2019-02-07 03:03:34 +00:00
parent ecc4d697cd
commit a60ffbc985
3 changed files with 12 additions and 9 deletions

View File

@ -49,11 +49,12 @@ uint32_t rts;
int32_t repeat; int32_t repeat;
DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd, 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" "Sharp routing Protocol\n"
"Watch for changes\n" "Watch for changes\n"
"Watch for nexthop 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; struct prefix p;
@ -63,17 +64,18 @@ DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
memcpy(&p.u.prefix6, &nhop, 16); memcpy(&p.u.prefix6, &nhop, 16);
p.family = AF_INET6; p.family = AF_INET6;
sharp_zebra_nexthop_watch(&p, true); sharp_zebra_nexthop_watch(&p, 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 nexthop A.B.C.D$nhop", "sharp watch nexthop A.B.C.D$nhop [connected$connected]",
"Sharp routing Protocol\n" "Sharp routing Protocol\n"
"Watch for changes\n" "Watch for changes\n"
"Watch for nexthop 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; struct prefix p;
@ -83,7 +85,7 @@ DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
p.u.prefix4 = nhop; p.u.prefix4 = nhop;
p.family = AF_INET; p.family = AF_INET;
sharp_zebra_nexthop_watch(&p, true); sharp_zebra_nexthop_watch(&p, true, !!connected);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -328,14 +328,14 @@ void route_delete(struct prefix *p, uint8_t instance)
return; 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; int command = ZEBRA_NEXTHOP_REGISTER;
if (!watch) if (!watch)
command = ZEBRA_NEXTHOP_UNREGISTER; 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", zlog_warn("%s: Failure to send nexthop to zebra",
__PRETTY_FUNCTION__); __PRETTY_FUNCTION__);
} }

View File

@ -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, extern void route_add(struct prefix *p, uint8_t instance,
struct nexthop_group *nhg); struct nexthop_group *nhg);
extern void route_delete(struct prefix *p, uint8_t instance); 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, extern void sharp_install_routes_helper(struct prefix *p, uint8_t instance,
struct nexthop_group *nhg, struct nexthop_group *nhg,