mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 03:28:31 +00:00
pbrd: move debug vty into pbr_vty.c
Dev docs say that CLI goes in _vty.c files Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
0f03639ded
commit
e14f43ccae
@ -43,16 +43,7 @@ const char *pbr_debugs_conflines[] = {
|
|||||||
"debug pbr events",
|
"debug pbr events",
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
void pbr_debug_set_all(uint32_t flags, bool set)
|
||||||
* Set or unset flags on all debugs for pbrd.
|
|
||||||
*
|
|
||||||
* flags
|
|
||||||
* The flags to set
|
|
||||||
*
|
|
||||||
* set
|
|
||||||
* Whether to set or unset the specified flags
|
|
||||||
*/
|
|
||||||
static void pbr_debug_set_all(uint32_t flags, bool set)
|
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < array_size(pbr_debugs); i++) {
|
for (unsigned int i = 0; i < array_size(pbr_debugs); i++) {
|
||||||
DEBUG_FLAGS_SET(pbr_debugs[i], flags, set);
|
DEBUG_FLAGS_SET(pbr_debugs[i], flags, set);
|
||||||
@ -81,7 +72,7 @@ static uint32_t pbr_debug_check_all(uint32_t flags)
|
|||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pbr_debug_config_write_helper(struct vty *vty, bool config)
|
int pbr_debug_config_write_helper(struct vty *vty, bool config)
|
||||||
{
|
{
|
||||||
uint32_t mode = DEBUG_MODE_ALL;
|
uint32_t mode = DEBUG_MODE_ALL;
|
||||||
|
|
||||||
@ -104,70 +95,9 @@ int pbr_debug_config_write(struct vty *vty)
|
|||||||
return pbr_debug_config_write_helper(vty, true);
|
return pbr_debug_config_write_helper(vty, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PBR debugging CLI ------------------------------------------------------- */
|
|
||||||
/* clang-format off */
|
|
||||||
|
|
||||||
DEFPY(debug_pbr,
|
|
||||||
debug_pbr_cmd,
|
|
||||||
"[no] debug pbr [{map$map|zebra$zebra|nht$nht|events$events}]",
|
|
||||||
NO_STR
|
|
||||||
DEBUG_STR
|
|
||||||
"Policy Based Routing\n"
|
|
||||||
"Policy maps\n"
|
|
||||||
"PBRD <-> Zebra communications\n"
|
|
||||||
"Nexthop tracking\n"
|
|
||||||
"Events\n")
|
|
||||||
{
|
|
||||||
uint32_t mode = DEBUG_NODE2MODE(vty->node);
|
|
||||||
|
|
||||||
if (map)
|
|
||||||
DEBUG_MODE_SET(&pbr_dbg_map, mode, !no);
|
|
||||||
if (zebra)
|
|
||||||
DEBUG_MODE_SET(&pbr_dbg_zebra, mode, !no);
|
|
||||||
if (nht)
|
|
||||||
DEBUG_MODE_SET(&pbr_dbg_nht, mode, !no);
|
|
||||||
if (events)
|
|
||||||
DEBUG_MODE_SET(&pbr_dbg_event, mode, !no);
|
|
||||||
|
|
||||||
/* no specific debug --> act on all of them */
|
|
||||||
if (strmatch(argv[argc - 1]->text, "pbr"))
|
|
||||||
pbr_debug_set_all(mode, !no);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFUN_NOSH(show_debugging_pbr,
|
|
||||||
show_debugging_pbr_cmd,
|
|
||||||
"show debugging [pbr]",
|
|
||||||
SHOW_STR
|
|
||||||
DEBUG_STR
|
|
||||||
"Policy Based Routing\n")
|
|
||||||
{
|
|
||||||
vty_out(vty, "PBR debugging status:\n");
|
|
||||||
|
|
||||||
pbr_debug_config_write_helper(vty, false);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* clang-format on */
|
|
||||||
/* ------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static struct cmd_node debug_node = {DEBUG_NODE, "", 1};
|
|
||||||
|
|
||||||
struct debug_callbacks pbr_dbg_cbs = {.debug_set_all = pbr_debug_set_all};
|
struct debug_callbacks pbr_dbg_cbs = {.debug_set_all = pbr_debug_set_all};
|
||||||
|
|
||||||
void pbr_debug_init(void)
|
void pbr_debug_init(void)
|
||||||
{
|
{
|
||||||
debug_init(&pbr_dbg_cbs);
|
debug_init(&pbr_dbg_cbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pbr_debug_init_vty(void)
|
|
||||||
{
|
|
||||||
install_node(&debug_node, pbr_debug_config_write);
|
|
||||||
|
|
||||||
install_element(VIEW_NODE, &debug_pbr_cmd);
|
|
||||||
install_element(CONFIG_NODE, &debug_pbr_cmd);
|
|
||||||
|
|
||||||
install_element(VIEW_NODE, &show_debugging_pbr_cmd);
|
|
||||||
}
|
|
||||||
|
@ -38,9 +38,29 @@ extern struct debug pbr_dbg_event;
|
|||||||
void pbr_debug_init(void);
|
void pbr_debug_init(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Install PBR debugging VTY commands.
|
* Set or unset flags on all debugs for pbrd.
|
||||||
|
*
|
||||||
|
* flags
|
||||||
|
* The flags to set
|
||||||
|
*
|
||||||
|
* set
|
||||||
|
* Whether to set or unset the specified flags
|
||||||
*/
|
*/
|
||||||
void pbr_debug_init_vty(void);
|
void pbr_debug_set_all(uint32_t flags, bool set);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Config write helper.
|
||||||
|
*
|
||||||
|
* vty
|
||||||
|
* Vty to write to
|
||||||
|
*
|
||||||
|
* config
|
||||||
|
* Whether we are writing to show run or saving config file
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* 0 for convenience
|
||||||
|
*/
|
||||||
|
int pbr_debug_config_write_helper(struct vty *vty, bool config);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print PBR debugging configuration.
|
* Print PBR debugging configuration.
|
||||||
|
@ -489,6 +489,58 @@ DEFPY (show_pbr_interface,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* PBR debugging CLI ------------------------------------------------------- */
|
||||||
|
/* clang-format off */
|
||||||
|
|
||||||
|
static struct cmd_node debug_node = {DEBUG_NODE, "", 1};
|
||||||
|
|
||||||
|
DEFPY(debug_pbr,
|
||||||
|
debug_pbr_cmd,
|
||||||
|
"[no] debug pbr [{map$map|zebra$zebra|nht$nht|events$events}]",
|
||||||
|
NO_STR
|
||||||
|
DEBUG_STR
|
||||||
|
"Policy Based Routing\n"
|
||||||
|
"Policy maps\n"
|
||||||
|
"PBRD <-> Zebra communications\n"
|
||||||
|
"Nexthop tracking\n"
|
||||||
|
"Events\n")
|
||||||
|
{
|
||||||
|
uint32_t mode = DEBUG_NODE2MODE(vty->node);
|
||||||
|
|
||||||
|
if (map)
|
||||||
|
DEBUG_MODE_SET(&pbr_dbg_map, mode, !no);
|
||||||
|
if (zebra)
|
||||||
|
DEBUG_MODE_SET(&pbr_dbg_zebra, mode, !no);
|
||||||
|
if (nht)
|
||||||
|
DEBUG_MODE_SET(&pbr_dbg_nht, mode, !no);
|
||||||
|
if (events)
|
||||||
|
DEBUG_MODE_SET(&pbr_dbg_event, mode, !no);
|
||||||
|
|
||||||
|
/* no specific debug --> act on all of them */
|
||||||
|
if (strmatch(argv[argc - 1]->text, "pbr"))
|
||||||
|
pbr_debug_set_all(mode, !no);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFUN_NOSH(show_debugging_pbr,
|
||||||
|
show_debugging_pbr_cmd,
|
||||||
|
"show debugging [pbr]",
|
||||||
|
SHOW_STR
|
||||||
|
DEBUG_STR
|
||||||
|
"Policy Based Routing\n")
|
||||||
|
{
|
||||||
|
vty_out(vty, "PBR debugging status:\n");
|
||||||
|
|
||||||
|
pbr_debug_config_write_helper(vty, false);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* clang-format on */
|
||||||
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
static struct cmd_node interface_node = {
|
static struct cmd_node interface_node = {
|
||||||
INTERFACE_NODE, "%s(config-if)# ", 1 /* vtysh ? yes */
|
INTERFACE_NODE, "%s(config-if)# ", 1 /* vtysh ? yes */
|
||||||
};
|
};
|
||||||
@ -573,6 +625,12 @@ void pbr_vty_init(void)
|
|||||||
install_node(&pbr_map_node,
|
install_node(&pbr_map_node,
|
||||||
pbr_vty_map_config_write);
|
pbr_vty_map_config_write);
|
||||||
|
|
||||||
|
/* debug */
|
||||||
|
install_node(&debug_node, pbr_debug_config_write);
|
||||||
|
install_element(VIEW_NODE, &debug_pbr_cmd);
|
||||||
|
install_element(CONFIG_NODE, &debug_pbr_cmd);
|
||||||
|
install_element(VIEW_NODE, &show_debugging_pbr_cmd);
|
||||||
|
|
||||||
install_default(PBRMAP_NODE);
|
install_default(PBRMAP_NODE);
|
||||||
|
|
||||||
install_element(CONFIG_NODE, &pbr_map_cmd);
|
install_element(CONFIG_NODE, &pbr_map_cmd);
|
||||||
@ -586,6 +644,4 @@ void pbr_vty_init(void)
|
|||||||
install_element(VIEW_NODE, &show_pbr_map_cmd);
|
install_element(VIEW_NODE, &show_pbr_map_cmd);
|
||||||
install_element(VIEW_NODE, &show_pbr_interface_cmd);
|
install_element(VIEW_NODE, &show_pbr_interface_cmd);
|
||||||
install_element(VIEW_NODE, &show_pbr_nexthop_group_cmd);
|
install_element(VIEW_NODE, &show_pbr_nexthop_group_cmd);
|
||||||
|
|
||||||
pbr_debug_init_vty();
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user