diff options
author | Donald Sharp <sharpd@nvidia.com> | 2021-05-04 01:35:36 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2021-05-04 01:38:38 +0200 |
commit | 921af54db946f0f62fc4579850872ef71384bfde (patch) | |
tree | efd60d40e37971316563fa5431f54058c19ce485 /sharpd | |
parent | Merge pull request #8601 from Fredi-raspall/pr_fix_lfa_debug (diff) | |
download | frr-921af54db946f0f62fc4579850872ef71384bfde.tar.xz frr-921af54db946f0f62fc4579850872ef71384bfde.zip |
sharpd: add v4 redistribute watching
Add the ability for sharpd to watch v4 redistribution events
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'sharpd')
-rw-r--r-- | sharpd/sharp_vty.c | 28 | ||||
-rw-r--r-- | sharpd/sharp_zebra.c | 6 | ||||
-rw-r--r-- | sharpd/sharp_zebra.h | 2 |
3 files changed, 36 insertions, 0 deletions
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 8306aca9e..1ff0591d5 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] <nexthop$n X:X::X:X$nhop|import$import X:X::X:X/M$inhop> [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 0f2c63404..128cfe2de 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 ffddb9e78..4355f49a2 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 |