diff options
| author | Farid Mihoub <farid.mihoub@6wind.com> | 2023-11-03 13:53:43 +0100 | 
|---|---|---|
| committer | Farid Mihoub <farid.mihoub@6wind.com> | 2023-11-03 17:09:11 +0100 | 
| commit | a9ba982472caaceb88ac5bee6cb8312579898cb3 (patch) | |
| tree | ec54732bfa407258fc72e05e71dff2c3ac845f2e | |
| parent | ad44b541ef84adfdfb97460ea0de50371328675b (diff) | |
pathd: rework debug pathd pcep command
Rework "debug pathd pcep [...]" command to support the following
configurations:
  - configure one debugging log type at a time.
  - deconfigure one debugging log type at a time.
  - configure all debugging logs in one shot.
  - deconfigure all debugging logs in one shot.
Signed-off-by: Farid Mihoub <farid.mihoub@6wind.com>
| -rw-r--r-- | pathd/path_pcep.h | 1 | ||||
| -rw-r--r-- | pathd/path_pcep_cli.c | 43 | 
2 files changed, 24 insertions, 20 deletions
diff --git a/pathd/path_pcep.h b/pathd/path_pcep.h index 5c6a02372f..d6dbcb5c08 100644 --- a/pathd/path_pcep.h +++ b/pathd/path_pcep.h @@ -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))    \ diff --git a/pathd/path_pcep_cli.c b/pathd/path_pcep_cli.c index c46649b0db..ab61abc02d 100644 --- a/pathd/path_pcep_cli.c +++ b/pathd/path_pcep_cli.c @@ -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;  } @@ -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" @@ -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,  | 
