diff options
| author | Russ White <russ@riw.us> | 2022-11-16 21:41:33 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-16 21:41:33 -0500 |
| commit | 54b3d90a4bb537607b5d16337ba3d1e56e271f12 (patch) | |
| tree | f1f1f2e7df4ca77d1dfe2816827ccf7ac11515c1 /pathd/path_cli.c | |
| parent | e0f7fc58a2bb2feef6149a494b9456eabc38f920 (diff) | |
| parent | ec139f60f19088611a2fa177c1f81dd64f97d744 (diff) | |
Merge pull request #11992 from pguibert6WIND/pathd_debug
Pathd debug
Diffstat (limited to 'pathd/path_cli.c')
| -rw-r--r-- | pathd/path_cli.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/pathd/path_cli.c b/pathd/path_cli.c index a6540cc84a..b88453c68f 100644 --- a/pathd/path_cli.c +++ b/pathd/path_cli.c @@ -126,7 +126,7 @@ DEFPY(show_srte_policy, ttable_rowseps(tt, 0, BOTTOM, true, '-'); RB_FOREACH (policy, srte_policy_head, &srte_policies) { - char endpoint[46]; + char endpoint[ENDPOINT_STR_LENGTH]; char binding_sid[16] = "-"; ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint)); @@ -173,7 +173,7 @@ DEFPY(show_srte_policy_detail, vty_out(vty, "\n"); RB_FOREACH (policy, srte_policy_head, &srte_policies) { struct srte_candidate *candidate; - char endpoint[46]; + char endpoint[ENDPOINT_STR_LENGTH]; char binding_sid[16] = "-"; char *segment_list_info; static char undefined_info[] = "(undefined)"; @@ -1091,8 +1091,25 @@ DEFPY_NOSH(show_debugging_pathd, show_debugging_pathd_cmd, "pathd module debugging\n") { + vty_out(vty, "Path debugging status:\n"); + cmd_show_lib_debugs(vty); /* nothing to do here */ + path_ted_show_debugging(vty); + path_policy_show_debugging(vty); + return CMD_SUCCESS; +} + +DEFPY(debug_path_policy, debug_path_policy_cmd, "[no] debug pathd policy", + NO_STR DEBUG_STR + "path debugging\n" + "policy debugging\n") +{ + uint32_t mode = DEBUG_NODE2MODE(vty->node); + bool no_debug = no; + + DEBUG_MODE_SET(&path_policy_debug, mode, !no); + DEBUG_FLAGS_SET(&path_policy_debug, PATH_POLICY_DEBUG_BASIC, !no_debug); return CMD_SUCCESS; } @@ -1291,8 +1308,34 @@ int config_write_segment_routing(struct vty *vty) return 1; } +static int path_policy_cli_debug_config_write(struct vty *vty) +{ + if (DEBUG_MODE_CHECK(&path_policy_debug, DEBUG_MODE_CONF)) { + if (DEBUG_FLAGS_CHECK(&path_policy_debug, + PATH_POLICY_DEBUG_BASIC)) + vty_out(vty, "debug pathd policy\n"); + return 1; + } + return 0; +} + +static int path_policy_cli_debug_set_all(uint32_t flags, bool set) +{ + DEBUG_FLAGS_SET(&path_policy_debug, flags, set); + + /* If all modes have been turned off, don't preserve options. */ + if (!DEBUG_MODE_CHECK(&path_policy_debug, DEBUG_MODE_ALL)) + DEBUG_CLEAR(&path_policy_debug); + + return 0; +} + void path_cli_init(void) { + hook_register(nb_client_debug_config_write, + path_policy_cli_debug_config_write); + hook_register(nb_client_debug_set_all, path_policy_cli_debug_set_all); + install_node(&segment_routing_node); install_node(&sr_traffic_eng_node); install_node(&srte_segment_list_node); @@ -1308,6 +1351,9 @@ void path_cli_init(void) install_element(ENABLE_NODE, &show_srte_policy_cmd); install_element(ENABLE_NODE, &show_srte_policy_detail_cmd); + install_element(ENABLE_NODE, &debug_path_policy_cmd); + install_element(CONFIG_NODE, &debug_path_policy_cmd); + install_element(CONFIG_NODE, &segment_routing_cmd); install_element(SEGMENT_ROUTING_NODE, &sr_traffic_eng_cmd); install_element(SR_TRAFFIC_ENG_NODE, &srte_segment_list_cmd); |
