diff --git a/doc/user/sharp.rst b/doc/user/sharp.rst index bef2748afa..0542a593ae 100644 --- a/doc/user/sharp.rst +++ b/doc/user/sharp.rst @@ -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 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)]] Install an LSP using the specified in-label, with nexthops as diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 8306aca9ee..1ff0591d5e 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -39,6 +39,33 @@ #include "sharpd/sharp_vty_clippy.c" #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, "sharp watch [vrf NAME$vrf_name] [connected$connected]", "Sharp routing Protocol\n" @@ -844,6 +871,7 @@ void sharp_vty_init(void) install_element(ENABLE_NODE, &remove_routes_cmd); install_element(ENABLE_NODE, &vrf_label_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_v4_cmd); install_element(ENABLE_NODE, &sharp_lsp_prefix_v4_cmd); diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 0f2c634049..128cfe2de6 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -714,6 +714,12 @@ static int sharp_redistribute_route(ZAPI_CALLBACK_ARGS) 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. */ int sharp_zclient_create(uint32_t session_id) { diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h index ffddb9e780..4355f49a2f 100644 --- a/sharpd/sharp_zebra.h +++ b/sharpd/sharp_zebra.h @@ -63,4 +63,6 @@ extern void sharp_zebra_send_arp(const struct interface *ifp, /* Register Link State Opaque messages */ extern void sharp_zebra_register_te(void); +extern void sharp_redistribute_vrf(struct vrf *vrf, int source); + #endif