mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-29 12:18:12 +00:00
sharpd: add support for setting protodown
Add support for setting protodown via sharpd. This is just useful for testing. We can make use of this in topotests. Signed-off-by: Stephen Worley <sworley@nvidia.com>
This commit is contained in:
parent
5d41413833
commit
f9a1140c9a
@ -1258,6 +1258,67 @@ DEFPY (show_sharp_cspf,
|
|||||||
return CMD_SUCCESS;
|
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)
|
void sharp_vty_init(void)
|
||||||
{
|
{
|
||||||
install_element(ENABLE_NODE, &install_routes_data_dump_cmd);
|
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);
|
&sharp_srv6_manager_release_locator_chunk_cmd);
|
||||||
install_element(ENABLE_NODE, &show_sharp_segment_routing_srv6_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;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -968,6 +968,18 @@ static int sharp_zebra_process_srv6_locator_chunk(ZAPI_CALLBACK_ARGS)
|
|||||||
return 0;
|
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[] = {
|
static zclient_handler *const sharp_handlers[] = {
|
||||||
[ZEBRA_INTERFACE_ADDRESS_ADD] = interface_address_add,
|
[ZEBRA_INTERFACE_ADDRESS_ADD] = interface_address_add,
|
||||||
[ZEBRA_INTERFACE_ADDRESS_DELETE] = interface_address_delete,
|
[ZEBRA_INTERFACE_ADDRESS_DELETE] = interface_address_delete,
|
||||||
|
@ -73,4 +73,6 @@ extern void sharp_install_seg6local_route_helper(struct prefix *p,
|
|||||||
enum seg6local_action_t act,
|
enum seg6local_action_t act,
|
||||||
struct seg6local_context *ctx);
|
struct seg6local_context *ctx);
|
||||||
|
|
||||||
|
extern int sharp_zebra_send_interface_protodown(struct interface *ifp,
|
||||||
|
bool down);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user