diff options
author | Russ White <russ@riw.us> | 2022-03-16 00:58:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-16 00:58:16 +0100 |
commit | 5d97021ba36666884c7caed69e3565e01f73eaf5 (patch) | |
tree | d27dc8e34ceee6c63b333c91f8c57a7a95ecbe67 /sharpd | |
parent | Merge pull request #10643 from Jafaral/ospf-multi-vrf (diff) | |
parent | zebra: cleanup protodown netlink logs (diff) | |
download | frr-5d97021ba36666884c7caed69e3565e01f73eaf5.tar.xz frr-5d97021ba36666884c7caed69e3565e01f73eaf5.zip |
Merge pull request #10427 from sworleys/Protodown-Reason-Upstream
Add Support for Setting Protodown Reason Code
Diffstat (limited to 'sharpd')
-rw-r--r-- | sharpd/sharp_vty.c | 64 | ||||
-rw-r--r-- | sharpd/sharp_zebra.c | 12 | ||||
-rw-r--r-- | sharpd/sharp_zebra.h | 2 |
3 files changed, 78 insertions, 0 deletions
diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 78cc57cc4..889643f65 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -1258,6 +1258,67 @@ DEFPY (show_sharp_cspf, return CMD_SUCCESS; } +static struct interface *if_lookup_vrf_all(const char *ifname) +{ + struct interface *ifp; + struct vrf *vrf; + + RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name) { + ifp = if_lookup_by_name(ifname, vrf->vrf_id); + if (ifp) + return ifp; + } + + return NULL; +} + +DEFPY (sharp_interface_protodown, + sharp_interface_protodown_cmd, + "sharp interface IFNAME$ifname protodown", + SHARP_STR + INTERFACE_STR + IFNAME_STR + "Set interface protodown\n") +{ + struct interface *ifp; + + ifp = if_lookup_vrf_all(ifname); + + if (!ifp) { + vty_out(vty, "%% Can't find interface %s\n", ifname); + return CMD_WARNING; + } + + if (sharp_zebra_send_interface_protodown(ifp, true) != 0) + return CMD_WARNING; + + return CMD_SUCCESS; +} + +DEFPY (no_sharp_interface_protodown, + no_sharp_interface_protodown_cmd, + "no sharp interface IFNAME$ifname protodown", + NO_STR + SHARP_STR + INTERFACE_STR + IFNAME_STR + "Set interface protodown\n") +{ + struct interface *ifp; + + ifp = if_lookup_vrf_all(ifname); + + if (!ifp) { + vty_out(vty, "%% Can't find interface %s\n", ifname); + return CMD_WARNING; + } + + if (sharp_zebra_send_interface_protodown(ifp, false) != 0) + return CMD_WARNING; + + return CMD_SUCCESS; +} + void sharp_vty_init(void) { install_element(ENABLE_NODE, &install_routes_data_dump_cmd); @@ -1290,5 +1351,8 @@ void sharp_vty_init(void) &sharp_srv6_manager_release_locator_chunk_cmd); install_element(ENABLE_NODE, &show_sharp_segment_routing_srv6_cmd); + install_element(ENABLE_NODE, &sharp_interface_protodown_cmd); + install_element(ENABLE_NODE, &no_sharp_interface_protodown_cmd); + return; } diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 5304b17f0..52364bff4 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -969,6 +969,18 @@ static int sharp_zebra_process_srv6_locator_chunk(ZAPI_CALLBACK_ARGS) return 0; } +int sharp_zebra_send_interface_protodown(struct interface *ifp, bool down) +{ + zlog_debug("Sending zebra to set %s protodown %s", ifp->name, + down ? "on" : "off"); + + if (zclient_send_interface_protodown(zclient, ifp->vrf->vrf_id, ifp, + down) == ZCLIENT_SEND_FAILURE) + return -1; + + return 0; +} + static zclient_handler *const sharp_handlers[] = { [ZEBRA_INTERFACE_ADDRESS_ADD] = interface_address_add, [ZEBRA_INTERFACE_ADDRESS_DELETE] = interface_address_delete, diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h index 49f11a67e..d8ea67979 100644 --- a/sharpd/sharp_zebra.h +++ b/sharpd/sharp_zebra.h @@ -73,4 +73,6 @@ extern void sharp_install_seg6local_route_helper(struct prefix *p, enum seg6local_action_t act, struct seg6local_context *ctx); +extern int sharp_zebra_send_interface_protodown(struct interface *ifp, + bool down); #endif |