mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
lib: common debug status output
Implement common code for debug status output and remove daemon-specific code that is duplicated everywhere. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
parent
82e52e0f21
commit
830972cab2
|
@ -17,6 +17,7 @@
|
|||
#include <lib/version.h>
|
||||
|
||||
#include "command.h"
|
||||
#include "debug.h"
|
||||
#include "frrstr.h"
|
||||
#include "memory.h"
|
||||
#include "log.h"
|
||||
|
@ -2463,8 +2464,7 @@ const char *host_config_get(void)
|
|||
void cmd_show_lib_debugs(struct vty *vty)
|
||||
{
|
||||
route_map_show_debug(vty);
|
||||
mgmt_debug_be_client_show_debug(vty);
|
||||
mgmt_debug_fe_client_show_debug(vty);
|
||||
debug_status_write(vty);
|
||||
}
|
||||
|
||||
void install_default(enum node_type node)
|
||||
|
|
10
lib/debug.c
10
lib/debug.c
|
@ -38,6 +38,16 @@ DEFUN_NOSH (debug_all,
|
|||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void debug_status_write(struct vty *vty)
|
||||
{
|
||||
struct debug *debug;
|
||||
|
||||
frr_each (debug_list, &debug_head, debug) {
|
||||
if (DEBUG_MODE_CHECK(debug, DEBUG_MODE_ALL))
|
||||
vty_out(vty, " %s debugging is on\n", debug->desc);
|
||||
}
|
||||
}
|
||||
|
||||
static int config_write_debug(struct vty *vty)
|
||||
{
|
||||
struct debug *debug;
|
||||
|
|
|
@ -199,6 +199,9 @@ struct debug {
|
|||
#define DEBUGN(name, fmt, ...) DEBUG(notice, name, fmt, ##__VA_ARGS__)
|
||||
#define DEBUGD(name, fmt, ...) DEBUG(debug, name, fmt, ##__VA_ARGS__)
|
||||
|
||||
/* Show current debugging status. */
|
||||
void debug_status_write(struct vty *vty);
|
||||
|
||||
/*
|
||||
* Register a debug item.
|
||||
*/
|
||||
|
|
|
@ -1259,12 +1259,6 @@ DEFPY(debug_mgmt_client_be, debug_mgmt_client_be_cmd,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
void mgmt_debug_be_client_show_debug(struct vty *vty)
|
||||
{
|
||||
if (debug_check_be_client())
|
||||
vty_out(vty, "debug mgmt client backend\n");
|
||||
}
|
||||
|
||||
struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
|
||||
struct mgmt_be_client_cbs *cbs,
|
||||
uintptr_t user_data,
|
||||
|
|
|
@ -121,11 +121,6 @@ mgmt_be_client_create(const char *name, struct mgmt_be_client_cbs *cbs,
|
|||
*/
|
||||
extern void mgmt_be_client_lib_vty_init(void);
|
||||
|
||||
/*
|
||||
* Print enabled debugging commands.
|
||||
*/
|
||||
extern void mgmt_debug_be_client_show_debug(struct vty *vty);
|
||||
|
||||
/*
|
||||
* [Un]-subscribe with MGMTD for one or more YANG subtree(s).
|
||||
*
|
||||
|
|
|
@ -806,12 +806,6 @@ DEFPY(debug_mgmt_client_fe, debug_mgmt_client_fe_cmd,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
void mgmt_debug_fe_client_show_debug(struct vty *vty)
|
||||
{
|
||||
if (debug_check_fe_client())
|
||||
vty_out(vty, "debug mgmt client frontend\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize library and try connecting with MGMTD.
|
||||
*/
|
||||
|
|
|
@ -178,11 +178,6 @@ mgmt_fe_client_create(const char *client_name, struct mgmt_fe_client_cbs *cbs,
|
|||
*/
|
||||
extern void mgmt_fe_client_lib_vty_init(void);
|
||||
|
||||
/*
|
||||
* Print enabled debugging commands.
|
||||
*/
|
||||
extern void mgmt_debug_fe_client_show_debug(struct vty *vty);
|
||||
|
||||
/*
|
||||
* Create a new Session for a Frontend Client connection.
|
||||
*
|
||||
|
|
|
@ -557,39 +557,11 @@ DEFPY(mgmt_rollback,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static int write_mgmt_debug_helper(struct vty *vty, bool config)
|
||||
{
|
||||
uint32_t mode = config ? DEBUG_MODE_CONF : DEBUG_MODE_ALL;
|
||||
bool be = DEBUG_MODE_CHECK(&mgmt_debug_be, mode);
|
||||
bool ds = DEBUG_MODE_CHECK(&mgmt_debug_ds, mode);
|
||||
bool fe = DEBUG_MODE_CHECK(&mgmt_debug_fe, mode);
|
||||
bool txn = DEBUG_MODE_CHECK(&mgmt_debug_txn, mode);
|
||||
|
||||
if (!(be || ds || fe || txn))
|
||||
return 0;
|
||||
|
||||
vty_out(vty, "debug mgmt");
|
||||
if (be)
|
||||
vty_out(vty, " backend");
|
||||
if (ds)
|
||||
vty_out(vty, " datastore");
|
||||
if (fe)
|
||||
vty_out(vty, " frontend");
|
||||
if (txn)
|
||||
vty_out(vty, " transaction");
|
||||
|
||||
vty_out(vty, "\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFPY_NOSH(show_debugging_mgmt, show_debugging_mgmt_cmd,
|
||||
"show debugging [mgmt]", SHOW_STR DEBUG_STR "MGMT Information\n")
|
||||
{
|
||||
vty_out(vty, "MGMT debugging status:\n");
|
||||
|
||||
write_mgmt_debug_helper(vty, false);
|
||||
|
||||
cmd_show_lib_debugs(vty);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
|
|
|
@ -1089,9 +1089,7 @@ DEFPY_NOSH(show_debugging_pathd, show_debugging_pathd_cmd,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1952,27 +1952,6 @@ int pcep_cli_pcep_pce_config_write(struct vty *vty)
|
|||
* The param names are taken from the path_pcep_cli_clippy.c generated file.
|
||||
*/
|
||||
|
||||
DEFPY(show_debugging_pathd_pcep,
|
||||
show_debugging_pathd_pcep_cmd,
|
||||
"show debugging pathd-pcep",
|
||||
SHOW_STR
|
||||
"State of each debugging option\n"
|
||||
"pathd pcep module debugging\n")
|
||||
{
|
||||
vty_out(vty, "Pathd pcep debugging status:\n");
|
||||
|
||||
if (DEBUG_MODE_CHECK(&pcep_g->dbg_basic, DEBUG_MODE_ALL))
|
||||
vty_out(vty, "PCEP basic debugging is on\n");
|
||||
if (DEBUG_MODE_CHECK(&pcep_g->dbg_path, DEBUG_MODE_ALL))
|
||||
vty_out(vty, "PCEP path debugging is on\n");
|
||||
if (DEBUG_MODE_CHECK(&pcep_g->dbg_msg, DEBUG_MODE_ALL))
|
||||
vty_out(vty, "PCEP message debugging is on\n");
|
||||
if (DEBUG_MODE_CHECK(&pcep_g->dbg_lib, DEBUG_MODE_ALL))
|
||||
vty_out(vty, "PCEP lib debugging is on\n");
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFPY(pcep_cli_debug,
|
||||
pcep_cli_debug_cmd,
|
||||
"[no] debug pathd pcep [{basic$basic|path$path|message$msg|pceplib$lib}]",
|
||||
|
@ -2369,7 +2348,6 @@ void pcep_cli_init(void)
|
|||
/* Top commands */
|
||||
install_element(CONFIG_NODE, &pcep_cli_debug_cmd);
|
||||
install_element(ENABLE_NODE, &pcep_cli_debug_cmd);
|
||||
install_element(ENABLE_NODE, &show_debugging_pathd_pcep_cmd);
|
||||
install_element(ENABLE_NODE, &pcep_cli_show_srte_pcep_counters_cmd);
|
||||
install_element(ENABLE_NODE, &pcep_cli_show_srte_pcep_pce_config_cmd);
|
||||
install_element(ENABLE_NODE, &pcep_cli_show_srte_pcep_pce_cmd);
|
||||
|
|
|
@ -463,17 +463,6 @@ DEFPY (show_pathd_ted_db,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Config Write functions
|
||||
*/
|
||||
|
||||
|
||||
void path_ted_show_debugging(struct vty *vty)
|
||||
{
|
||||
if (DEBUG_MODE_CHECK(&ted_state_g.dbg, DEBUG_MODE_ALL))
|
||||
vty_out(vty, " Path TED debugging is on\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Help fn to show ted related configuration
|
||||
*
|
||||
|
|
|
@ -81,7 +81,6 @@ int path_ted_segment_list_refresh(void);
|
|||
|
||||
/* TED configuration functions */
|
||||
uint32_t path_ted_config_write(struct vty *vty);
|
||||
void path_ted_show_debugging(struct vty *vty);
|
||||
|
||||
/* TED util functions */
|
||||
/* clang-format off */
|
||||
|
|
|
@ -1279,12 +1279,6 @@ const char *srte_origin2str(enum srte_protocol_origin origin)
|
|||
assert(!"Reached end of function we should never hit");
|
||||
}
|
||||
|
||||
void path_policy_show_debugging(struct vty *vty)
|
||||
{
|
||||
if (DEBUG_MODE_CHECK(&path_policy_debug, DEBUG_MODE_ALL))
|
||||
vty_out(vty, " Path policy debugging is on\n");
|
||||
}
|
||||
|
||||
void pathd_shutdown(void)
|
||||
{
|
||||
path_ted_teardown();
|
||||
|
|
|
@ -435,7 +435,6 @@ void srte_candidate_status_update(struct srte_candidate *candidate, int status);
|
|||
void srte_candidate_unset_segment_list(const char *originator, bool force);
|
||||
const char *srte_origin2str(enum srte_protocol_origin origin);
|
||||
void pathd_shutdown(void);
|
||||
void path_policy_show_debugging(struct vty *vty);
|
||||
|
||||
/* path_cli.c */
|
||||
void path_cli_init(void);
|
||||
|
|
|
@ -19,29 +19,6 @@ struct debug pbr_dbg_zebra = { 0, "debug pbr zebra",
|
|||
struct debug pbr_dbg_nht = { 0, "debug pbr nht", "PBR nexthop tracking" };
|
||||
struct debug pbr_dbg_event = { 0, "debug pbr events", "PBR events" };
|
||||
|
||||
struct debug *pbr_debugs[] = {&pbr_dbg_map, &pbr_dbg_zebra, &pbr_dbg_nht,
|
||||
&pbr_dbg_event};
|
||||
|
||||
const char *pbr_debugs_conflines[] = {
|
||||
"debug pbr map",
|
||||
"debug pbr zebra",
|
||||
"debug pbr nht",
|
||||
"debug pbr events",
|
||||
};
|
||||
|
||||
int pbr_debug_config_write_helper(struct vty *vty, bool config)
|
||||
{
|
||||
uint32_t mode = DEBUG_MODE_ALL;
|
||||
|
||||
if (config)
|
||||
mode = DEBUG_MODE_CONF;
|
||||
|
||||
for (unsigned int i = 0; i < array_size(pbr_debugs); i++)
|
||||
if (DEBUG_MODE_CHECK(pbr_debugs[i], mode))
|
||||
vty_out(vty, "%s\n", pbr_debugs_conflines[i]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pbr_debug_init(void)
|
||||
{
|
||||
debug_install(&pbr_dbg_map);
|
||||
|
|
|
@ -35,18 +35,4 @@ void pbr_debug_init(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);
|
||||
|
||||
#endif /* __PBR_DEBUG_H__ */
|
||||
|
|
|
@ -1993,8 +1993,6 @@ DEFUN_NOSH(show_debugging_pbr,
|
|||
{
|
||||
vty_out(vty, "PBR debugging status:\n");
|
||||
|
||||
pbr_debug_config_write_helper(vty, false);
|
||||
|
||||
cmd_show_lib_debugs(vty);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
|
|
|
@ -22,39 +22,8 @@
|
|||
struct debug static_dbg_events = {0, "debug static events", "Staticd events"};
|
||||
struct debug static_dbg_route = {0, "debug static route", "Staticd route"};
|
||||
struct debug static_dbg_bfd = {0, "debug static bfd", "Staticd bfd"};
|
||||
|
||||
struct debug *static_debug_arr[] = {
|
||||
&static_dbg_events,
|
||||
&static_dbg_route,
|
||||
&static_dbg_bfd
|
||||
};
|
||||
|
||||
const char *static_debugs_conflines[] = {
|
||||
"debug static events",
|
||||
"debug static route",
|
||||
"debug static bfd"
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
static int static_debug_config_write_helper(struct vty *vty, bool config)
|
||||
{
|
||||
uint32_t mode = DEBUG_MODE_ALL;
|
||||
|
||||
if (config)
|
||||
mode = DEBUG_MODE_CONF;
|
||||
|
||||
for (unsigned int i = 0; i < array_size(static_debug_arr); i++)
|
||||
if (DEBUG_MODE_CHECK(static_debug_arr[i], mode))
|
||||
vty_out(vty, "%s\n", static_debugs_conflines[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int static_debug_status_write(struct vty *vty)
|
||||
{
|
||||
return static_debug_config_write_helper(vty, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set debugging status.
|
||||
*
|
||||
|
|
|
@ -28,14 +28,6 @@ extern struct debug static_dbg_bfd;
|
|||
*/
|
||||
void static_debug_init(void);
|
||||
|
||||
/*
|
||||
* Print staticd debugging configuration, human readable form.
|
||||
*
|
||||
* vty
|
||||
* VTY to print debugging configuration to.
|
||||
*/
|
||||
int static_debug_status_write(struct vty *vty);
|
||||
|
||||
/*
|
||||
* Set debugging status.
|
||||
*
|
||||
|
|
|
@ -1639,8 +1639,6 @@ DEFUN_NOSH (show_debugging_static,
|
|||
{
|
||||
vty_out(vty, "Staticd debugging status\n");
|
||||
|
||||
static_debug_status_write(vty);
|
||||
|
||||
cmd_show_lib_debugs(vty);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
|
|
|
@ -20,47 +20,8 @@ struct debug vrrp_dbg_pkt = {0, "debug vrrp packets", "VRRP packets"};
|
|||
struct debug vrrp_dbg_proto = {0, "debug vrrp protocol", "VRRP protocol events"};
|
||||
struct debug vrrp_dbg_sock = {0, "debug vrrp sockets", "VRRP sockets"};
|
||||
struct debug vrrp_dbg_zebra = {0, "debug vrrp zebra", "VRRP Zebra events"};
|
||||
|
||||
struct debug *vrrp_debugs[] = {
|
||||
&vrrp_dbg_arp,
|
||||
&vrrp_dbg_auto,
|
||||
&vrrp_dbg_ndisc,
|
||||
&vrrp_dbg_pkt,
|
||||
&vrrp_dbg_proto,
|
||||
&vrrp_dbg_sock,
|
||||
&vrrp_dbg_zebra
|
||||
};
|
||||
|
||||
const char *vrrp_debugs_conflines[] = {
|
||||
"debug vrrp arp",
|
||||
"debug vrrp autoconfigure",
|
||||
"debug vrrp ndisc",
|
||||
"debug vrrp packets",
|
||||
"debug vrrp protocol",
|
||||
"debug vrrp sockets",
|
||||
"debug vrrp zebra",
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
static int vrrp_debug_config_write_helper(struct vty *vty, bool config)
|
||||
{
|
||||
uint32_t mode = DEBUG_MODE_ALL;
|
||||
|
||||
if (config)
|
||||
mode = DEBUG_MODE_CONF;
|
||||
|
||||
for (unsigned int i = 0; i < array_size(vrrp_debugs); i++)
|
||||
if (DEBUG_MODE_CHECK(vrrp_debugs[i], mode))
|
||||
vty_out(vty, "%s\n", vrrp_debugs_conflines[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vrrp_debug_status_write(struct vty *vty)
|
||||
{
|
||||
return vrrp_debug_config_write_helper(vty, false);
|
||||
}
|
||||
|
||||
void vrrp_debug_set(struct interface *ifp, uint8_t vrid, int vtynode,
|
||||
bool onoff, bool proto, bool autoconf, bool pkt, bool sock,
|
||||
bool ndisc, bool arp, bool zebra)
|
||||
|
|
|
@ -738,8 +738,6 @@ DEFUN_NOSH (show_debugging_vrrp,
|
|||
{
|
||||
vty_out(vty, "VRRP debugging status:\n");
|
||||
|
||||
vrrp_debug_status_write(vty);
|
||||
|
||||
cmd_show_lib_debugs(vty);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
|
|
Loading…
Reference in a new issue