diff options
Diffstat (limited to 'pbrd/pbr_vty.c')
-rw-r--r-- | pbrd/pbr_vty.c | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index ae051ca96..bf3accae9 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -489,6 +489,58 @@ DEFPY (show_pbr_interface, 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 = { INTERFACE_NODE, "%s(config-if)# ", 1 /* vtysh ? yes */ }; @@ -573,6 +625,12 @@ void pbr_vty_init(void) install_node(&pbr_map_node, 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_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_interface_cmd); install_element(VIEW_NODE, &show_pbr_nexthop_group_cmd); - - pbr_debug_init_vty(); } |