Skip to content

Commit

Permalink
Merge pull request FRRouting#14728 from FRIDM636/rework_debug_pathd_pcep
Browse files Browse the repository at this point in the history
pathd: rework debug pathd pcep command
  • Loading branch information
donaldsharp authored Nov 3, 2023
2 parents 4f32148 + a9ba982 commit d4c596d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
1 change: 1 addition & 0 deletions pathd/path_pcep.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ DECLARE_MTYPE(PCEP);
#define PCEP_DEBUG_MODE_PATH 0x02
#define PCEP_DEBUG_MODE_PCEP 0x04
#define PCEP_DEBUG_MODE_PCEPLIB 0x08
#define PCEP_DEBUG_MODE_ALL 0x0F
#define PCEP_DEBUG(fmt, ...) \
do { \
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_BASIC)) \
Expand Down
43 changes: 23 additions & 20 deletions pathd/path_pcep_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,28 +458,32 @@ static void pcep_cli_remove_pce_connection(struct pce_opts *pce_opts)
* VTY command implementations
*/

static int path_pcep_cli_debug(struct vty *vty, const char *no_str,
const char *basic_str, const char *path_str,
const char *message_str, const char *pceplib_str)
static int path_pcep_cli_debug(struct vty *vty, const char *debug_type, bool set)
{
uint32_t mode = DEBUG_NODE2MODE(vty->node);
bool no = (no_str != NULL);

DEBUG_MODE_SET(&pcep_g->dbg, mode, !no);

if (basic_str != NULL) {
DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_BASIC, !no);
}
if (path_str != NULL) {
DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_PATH, !no);
}
if (message_str != NULL) {
DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEP, !no);
}
if (pceplib_str != NULL) {
DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEPLIB, !no);
/* Global Set */
if (debug_type == NULL) {
DEBUG_MODE_SET(&pcep_g->dbg, mode, set);
DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_ALL, set);
return CMD_SUCCESS;
}

DEBUG_MODE_SET(&pcep_g->dbg, mode, true);

if (strcmp(debug_type, "basic") == 0)
DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_BASIC, set);
else if (strcmp(debug_type, "path") == 0)
DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_PATH, set);
else if (strcmp(debug_type, "message") == 0)
DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEP, set);
else if (strcmp(debug_type, "pceplib") == 0)
DEBUG_FLAGS_SET(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEPLIB, set);

/* Unset the pcep debug mode if there is no flag at least set*/
if (!DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_ALL))
DEBUG_MODE_SET(&pcep_g->dbg, mode, false);

return CMD_SUCCESS;
}

Expand Down Expand Up @@ -1788,7 +1792,7 @@ DEFPY(show_debugging_pathd_pcep,

DEFPY(pcep_cli_debug,
pcep_cli_debug_cmd,
"[no] debug pathd pcep [basic]$basic_str [path]$path_str [message]$message_str [pceplib]$pceplib_str",
"[no] debug pathd pcep [<basic|path|message|pceplib>$debug_type]",
NO_STR DEBUG_STR
"pathd debugging\n"
"pcep module debugging\n"
Expand All @@ -1797,8 +1801,7 @@ DEFPY(pcep_cli_debug,
"pcep message debugging\n"
"pceplib debugging\n")
{
return path_pcep_cli_debug(vty, no, basic_str, path_str, message_str,
pceplib_str);
return path_pcep_cli_debug(vty, debug_type, !no);
}

DEFPY(pcep_cli_show_srte_pcep_counters,
Expand Down

0 comments on commit d4c596d

Please sign in to comment.