sharpd: add v4 redistribute watching

Add the ability for sharpd to watch v4 redistribution events

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2021-05-03 19:35:36 -04:00
parent 83187b8285
commit 921af54db9
4 changed files with 41 additions and 0 deletions

View File

@ -83,6 +83,11 @@ keyword. At present, no sharp commands will be preserved in the config.
Allow end user to dump associated data with the nexthop tracking that Allow end user to dump associated data with the nexthop tracking that
may have been turned on. may have been turned on.
.. clicmd:: sharp watch [vrf NAME] redistribute ROUTETYPE
Allow end user to monitor redistributed routes of ROUTETYPE
origin.
.. clicmd:: sharp lsp [update] (0-100000) nexthop-group NAME [prefix A.B.C.D/M TYPE [instance (0-255)]] .. clicmd:: sharp lsp [update] (0-100000) nexthop-group NAME [prefix A.B.C.D/M TYPE [instance (0-255)]]
Install an LSP using the specified in-label, with nexthops as Install an LSP using the specified in-label, with nexthops as

View File

@ -39,6 +39,33 @@
#include "sharpd/sharp_vty_clippy.c" #include "sharpd/sharp_vty_clippy.c"
#endif #endif
DEFPY(watch_redistribute, watch_redistribute_cmd,
"sharp watch [vrf NAME$vrf_name] redistribute " FRR_REDIST_STR_SHARPD,
"Sharp routing Protocol\n"
"Watch for changes\n"
"The vrf we would like to watch if non-default\n"
"The NAME of the vrf\n"
"Redistribute into Sharp\n"
FRR_REDIST_HELP_STR_SHARPD)
{
struct vrf *vrf;
int source;
if (!vrf_name)
vrf_name = VRF_DEFAULT_NAME;
vrf = vrf_lookup_by_name(vrf_name);
if (!vrf) {
vty_out(vty, "The vrf NAME specified: %s does not exist\n",
vrf_name);
return CMD_WARNING;
}
source = proto_redistnum(AFI_IP, argv[argc-1]->text);
sharp_redistribute_vrf(vrf, source);
return CMD_SUCCESS;
}
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]",
"Sharp routing Protocol\n" "Sharp routing Protocol\n"
@ -844,6 +871,7 @@ void sharp_vty_init(void)
install_element(ENABLE_NODE, &remove_routes_cmd); install_element(ENABLE_NODE, &remove_routes_cmd);
install_element(ENABLE_NODE, &vrf_label_cmd); install_element(ENABLE_NODE, &vrf_label_cmd);
install_element(ENABLE_NODE, &sharp_nht_data_dump_cmd); install_element(ENABLE_NODE, &sharp_nht_data_dump_cmd);
install_element(ENABLE_NODE, &watch_redistribute_cmd);
install_element(ENABLE_NODE, &watch_nexthop_v6_cmd); install_element(ENABLE_NODE, &watch_nexthop_v6_cmd);
install_element(ENABLE_NODE, &watch_nexthop_v4_cmd); install_element(ENABLE_NODE, &watch_nexthop_v4_cmd);
install_element(ENABLE_NODE, &sharp_lsp_prefix_v4_cmd); install_element(ENABLE_NODE, &sharp_lsp_prefix_v4_cmd);

View File

@ -714,6 +714,12 @@ static int sharp_redistribute_route(ZAPI_CALLBACK_ARGS)
return 0; return 0;
} }
void sharp_redistribute_vrf(struct vrf *vrf, int type)
{
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type,
0, vrf->vrf_id);
}
/* Add a zclient with a specified session id, for testing. */ /* Add a zclient with a specified session id, for testing. */
int sharp_zclient_create(uint32_t session_id) int sharp_zclient_create(uint32_t session_id)
{ {

View File

@ -63,4 +63,6 @@ extern void sharp_zebra_send_arp(const struct interface *ifp,
/* Register Link State Opaque messages */ /* Register Link State Opaque messages */
extern void sharp_zebra_register_te(void); extern void sharp_zebra_register_te(void);
extern void sharp_redistribute_vrf(struct vrf *vrf, int source);
#endif #endif