Merge pull request #16664 from mjstapp/igor_debug_simplify

*: simplify frrlib debug
This commit is contained in:
Jafar Al-Gharaibeh 2024-08-29 11:51:53 -04:00 committed by GitHub
commit 77e1a26faa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 227 additions and 777 deletions

View file

@ -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)

View file

@ -84,14 +84,12 @@ enum node_type {
CONFIG_NODE, /* Config node. Default mode of config file. */
PREFIX_NODE, /* ip prefix-list node. */
PREFIX_IPV6_NODE, /* ipv6 prefix-list node. */
LIB_DEBUG_NODE, /* frrlib debug node. */
DEBUG_NODE, /* Debug node. */
VRF_DEBUG_NODE, /* Vrf Debug node. */
NORTHBOUND_DEBUG_NODE, /* Northbound Debug node. */
DEBUG_VNC_NODE, /* Debug VNC node. */
RMAP_DEBUG_NODE, /* Route-map debug node */
RESOLVER_DEBUG_NODE, /* Resolver debug node */
MGMT_BE_DEBUG_NODE, /* mgmtd backend-client debug node */
MGMT_FE_DEBUG_NODE, /* mgmtd frontend-client debug node */
AAA_NODE, /* AAA node. */
EXTLOG_NODE, /* RFC5424 & co. extended syslog */
KEYCHAIN_NODE, /* Key-chain node. */

View file

@ -9,42 +9,75 @@
#include "debug.h"
#include "command.h"
static struct debug_cb_list_head cb_head;
static struct debug_list_head debug_head;
DECLARE_LIST(debug_cb_list, struct debug_callbacks, item);
DECLARE_LIST(debug_list, struct debug, item);
/* All code in this section should be reentrant and MT-safe */
DEFUN_NOSH(debug_all, debug_all_cmd, "[no] debug all",
NO_STR DEBUG_STR "Toggle all debugging output\n")
DEFUN_NOSH (debug_all,
debug_all_cmd,
"[no] debug all",
NO_STR DEBUG_STR
"Toggle all debugging output\n")
{
struct debug_callbacks *cb;
struct debug *debug;
bool set = !strmatch(argv[0]->text, "no");
uint32_t mode = DEBUG_NODE2MODE(vty->node);
frr_each (debug_cb_list, &cb_head, cb)
cb->debug_set_all(mode, set);
frr_each (debug_list, &debug_head, debug) {
DEBUG_MODE_SET(debug, mode, set);
/* If all modes have been turned off, don't preserve options. */
if (!DEBUG_MODE_CHECK(debug, DEBUG_MODE_ALL))
DEBUG_CLEAR(debug);
}
return CMD_SUCCESS;
}
/* ------------------------------------------------------------------------- */
void debug_init(struct debug_callbacks *cb)
void debug_status_write(struct vty *vty)
{
static bool inited = false;
struct debug *debug;
if (!inited) {
inited = true;
debug_cb_list_init(&cb_head);
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);
}
debug_cb_list_add_head(&cb_head, cb);
}
void debug_init_cli(void)
static int config_write_debug(struct vty *vty)
{
struct debug *debug;
frr_each (debug_list, &debug_head, debug) {
if (DEBUG_MODE_CHECK(debug, DEBUG_MODE_CONF))
vty_out(vty, "%s\n", debug->conf);
}
return 0;
}
static struct cmd_node debug_node = {
.name = "debug",
.node = LIB_DEBUG_NODE,
.prompt = "",
.config_write = config_write_debug,
};
void debug_install(struct debug *debug)
{
debug_list_add_tail(&debug_head, debug);
}
void debug_init(void)
{
debug_list_init(&debug_head);
install_node(&debug_node);
install_element(ENABLE_NODE, &debug_all_cmd);
install_element(CONFIG_NODE, &debug_all_cmd);
}

View file

@ -34,6 +34,7 @@ extern "C" {
#define DEBUG_OPT_NONE 0x00000000
PREDECL_LIST(debug_list);
/*
* Debugging record.
*
@ -63,37 +64,18 @@ extern "C" {
* manipulate the flags field in a multithreaded environment results in
* undefined behavior.
*
* conf
* The configuration string that will be written to the config file.
*
* desc
* Human-readable description of this debugging record.
*/
struct debug {
atomic_uint_fast32_t flags;
const char *conf;
const char *desc;
};
PREDECL_LIST(debug_cb_list);
/*
* Callback set for debugging code.
*
* debug_set_all
* Function pointer to call when the user requests that all debugs have a
* mode set.
*/
struct debug_callbacks {
/*
* Linked list of Callbacks to call
*/
struct debug_cb_list_item item;
/*
* flags
* flags to set on debug flag fields
*
* set
* true: set flags
* false: unset flags
*/
void (*debug_set_all)(uint32_t flags, bool set);
struct debug_list_item item;
};
/*
@ -217,22 +199,19 @@ struct debug_callbacks {
#define DEBUGN(name, fmt, ...) DEBUG(notice, name, fmt, ##__VA_ARGS__)
#define DEBUGD(name, fmt, ...) DEBUG(debug, name, fmt, ##__VA_ARGS__)
/*
* Optional initializer for debugging. Highly recommended.
*
* This function installs common debugging commands and allows the caller to
* specify callbacks to take when these commands are issued, allowing the
* caller to respond to events such as a request to turn off all debugs.
*
* MT-Safe
*/
void debug_init(struct debug_callbacks *cb);
/* Show current debugging status. */
void debug_status_write(struct vty *vty);
/*
* Turn on the cli to turn on/off debugs.
* Should only be called by libfrr
* Register a debug item.
*/
void debug_init_cli(void);
void debug_install(struct debug *debug);
/*
* Initialize debugging.
* Should only be called by libfrr.
*/
void debug_init(void);
#ifdef __cplusplus
}

View file

@ -809,6 +809,7 @@ struct event_loop *frr_init(void)
vty_init(master, di->log_always);
lib_cmd_init();
debug_init();
frr_pthread_init();
#ifdef HAVE_SCRIPTING
@ -825,8 +826,6 @@ struct event_loop *frr_init(void)
"%s: failed to initialize northbound database",
__func__);
debug_init_cli();
return master;
}

View file

@ -116,6 +116,7 @@ struct mgmt_be_client {
frr_each_safe (mgmt_be_txns, &(client_ctx)->txn_head, (txn))
struct debug mgmt_dbg_be_client = {
.conf = "debug mgmt client backend",
.desc = "Management backend client operations"
};
@ -1258,31 +1259,6 @@ DEFPY(debug_mgmt_client_be, debug_mgmt_client_be_cmd,
return CMD_SUCCESS;
}
static int mgmt_debug_be_client_config_write(struct vty *vty)
{
if (DEBUG_MODE_CHECK(&mgmt_dbg_be_client, DEBUG_MODE_CONF))
vty_out(vty, "debug mgmt client backend\n");
return 1;
}
void mgmt_debug_be_client_show_debug(struct vty *vty)
{
if (debug_check_be_client())
vty_out(vty, "debug mgmt client backend\n");
}
static struct debug_callbacks mgmt_dbg_be_client_cbs = {
.debug_set_all = mgmt_debug_client_be_set
};
static struct cmd_node mgmt_dbg_node = {
.name = "debug mgmt client backend",
.node = MGMT_BE_DEBUG_NODE,
.prompt = "",
.config_write = mgmt_debug_be_client_config_write,
};
struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
struct mgmt_be_client_cbs *cbs,
uintptr_t user_data,
@ -1328,8 +1304,8 @@ struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
void mgmt_be_client_lib_vty_init(void)
{
debug_init(&mgmt_dbg_be_client_cbs);
install_node(&mgmt_dbg_node);
debug_install(&mgmt_dbg_be_client);
install_element(ENABLE_NODE, &debug_mgmt_client_be_cmd);
install_element(CONFIG_NODE, &debug_mgmt_client_be_cmd);
}

View file

@ -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).
*

View file

@ -49,6 +49,7 @@ struct mgmt_fe_client {
frr_each_safe (mgmt_sessions, &(client)->sessions, (session))
struct debug mgmt_dbg_fe_client = {
.conf = "debug mgmt client frontend",
.desc = "Management frontend client operations"
};
@ -805,31 +806,6 @@ DEFPY(debug_mgmt_client_fe, debug_mgmt_client_fe_cmd,
return CMD_SUCCESS;
}
static int mgmt_debug_fe_client_config_write(struct vty *vty)
{
if (DEBUG_MODE_CHECK(&mgmt_dbg_fe_client, DEBUG_MODE_CONF))
vty_out(vty, "debug mgmt client frontend\n");
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");
}
static struct debug_callbacks mgmt_dbg_fe_client_cbs = {
.debug_set_all = mgmt_debug_client_fe_set
};
static struct cmd_node mgmt_dbg_node = {
.name = "debug mgmt client frontend",
.node = MGMT_FE_DEBUG_NODE,
.prompt = "",
.config_write = mgmt_debug_fe_client_config_write,
};
/*
* Initialize library and try connecting with MGMTD.
*/
@ -870,8 +846,8 @@ struct mgmt_fe_client *mgmt_fe_client_create(const char *client_name,
void mgmt_fe_client_lib_vty_init(void)
{
debug_init(&mgmt_dbg_fe_client_cbs);
install_node(&mgmt_dbg_node);
debug_install(&mgmt_dbg_fe_client);
install_element(ENABLE_NODE, &debug_mgmt_client_fe_cmd);
install_element(CONFIG_NODE, &debug_mgmt_client_fe_cmd);
}

View file

@ -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.
*

View file

@ -799,8 +799,6 @@ DECLARE_HOOK(nb_notification_send, (const char *xpath, struct list *arguments),
(xpath, arguments));
DECLARE_HOOK(nb_notification_tree_send,
(const char *xpath, const struct lyd_node *tree), (xpath, tree));
DECLARE_HOOK(nb_client_debug_config_write, (struct vty *vty), (vty));
DECLARE_HOOK(nb_client_debug_set_all, (uint32_t flags, bool set), (flags, set));
/* Northbound debugging records */
extern struct debug nb_dbg_cbs_config;

View file

@ -22,13 +22,19 @@
#include "northbound_db.h"
#include "lib/northbound_cli_clippy.c"
struct debug nb_dbg_cbs_config = {0, "Northbound callbacks: configuration"};
struct debug nb_dbg_cbs_state = {0, "Northbound callbacks: state"};
struct debug nb_dbg_cbs_rpc = {0, "Northbound callbacks: RPCs"};
struct debug nb_dbg_cbs_notify = {0, "Northbound callbacks: notifications"};
struct debug nb_dbg_notif = {0, "Northbound notifications"};
struct debug nb_dbg_events = {0, "Northbound events"};
struct debug nb_dbg_libyang = {0, "libyang debugging"};
struct debug nb_dbg_cbs_config = { 0, "debug northbound callbacks configuration",
"Northbound callbacks: configuration" };
struct debug nb_dbg_cbs_state = { 0, "debug northbound callbacks state",
"Northbound callbacks: state" };
struct debug nb_dbg_cbs_rpc = { 0, "debug northbound callbacks rpc",
"Northbound callbacks: RPCs" };
struct debug nb_dbg_cbs_notify = { 0, "debug northbound callbacks notify",
"Northbound callbacks: notifications" };
struct debug nb_dbg_notif = { 0, "debug northbound notifications",
"Northbound notifications" };
struct debug nb_dbg_events = { 0, "debug northbound events",
"Northbound events" };
struct debug nb_dbg_libyang = { 0, "debug northbound libyang", "libyang" };
struct nb_config *vty_shared_candidate_config;
static struct event_loop *master;
@ -1842,37 +1848,6 @@ DEFPY (rollback_config,
}
/* Debug CLI commands. */
static struct debug *nb_debugs[] = {
&nb_dbg_cbs_config, &nb_dbg_cbs_state, &nb_dbg_cbs_rpc,
&nb_dbg_cbs_notify, &nb_dbg_notif, &nb_dbg_events,
&nb_dbg_libyang,
};
static const char *const nb_debugs_conflines[] = {
"debug northbound callbacks configuration",
"debug northbound callbacks state",
"debug northbound callbacks rpc",
"debug northbound callbacks notify",
"debug northbound notifications",
"debug northbound events",
"debug northbound libyang",
};
DEFINE_HOOK(nb_client_debug_set_all, (uint32_t flags, bool set), (flags, set));
static void nb_debug_set_all(uint32_t flags, bool set)
{
for (unsigned int i = 0; i < array_size(nb_debugs); i++) {
DEBUG_FLAGS_SET(nb_debugs[i], flags, set);
/* If all modes have been turned off, don't preserve options. */
if (!DEBUG_MODE_CHECK(nb_debugs[i], DEBUG_MODE_ALL))
DEBUG_CLEAR(nb_debugs[i]);
}
hook_call(nb_client_debug_set_all, flags, set);
}
DEFPY (debug_nb,
debug_nb_cmd,
"[no] debug northbound\
@ -1895,8 +1870,13 @@ DEFPY (debug_nb,
"libyang debugging\n")
{
uint32_t mode = DEBUG_NODE2MODE(vty->node);
bool all = false;
if (cbs) {
/* no specific debug --> act on all of them */
if (strmatch(argv[argc - 1]->text, "northbound"))
all = true;
if (cbs || all) {
bool none = (!cbs_cfg && !cbs_state && !cbs_rpc && !cbs_notify);
if (none || cbs_cfg)
@ -1908,45 +1888,18 @@ DEFPY (debug_nb,
if (none || cbs_notify)
DEBUG_MODE_SET(&nb_dbg_cbs_notify, mode, !no);
}
if (notifications)
if (notifications || all)
DEBUG_MODE_SET(&nb_dbg_notif, mode, !no);
if (events)
if (events || all)
DEBUG_MODE_SET(&nb_dbg_events, mode, !no);
if (libyang) {
if (libyang || all) {
DEBUG_MODE_SET(&nb_dbg_libyang, mode, !no);
yang_debugging_set(!no);
}
/* no specific debug --> act on all of them */
if (strmatch(argv[argc - 1]->text, "northbound")) {
nb_debug_set_all(mode, !no);
yang_debugging_set(!no);
}
return CMD_SUCCESS;
}
DEFINE_HOOK(nb_client_debug_config_write, (struct vty *vty), (vty));
static int nb_debug_config_write(struct vty *vty)
{
for (unsigned int i = 0; i < array_size(nb_debugs); i++)
if (DEBUG_MODE_CHECK(nb_debugs[i], DEBUG_MODE_CONF))
vty_out(vty, "%s\n", nb_debugs_conflines[i]);
hook_call(nb_client_debug_config_write, vty);
return 1;
}
static struct debug_callbacks nb_dbg_cbs = {.debug_set_all = nb_debug_set_all};
static struct cmd_node nb_debug_node = {
.name = "northbound debug",
.node = NORTHBOUND_DEBUG_NODE,
.prompt = "",
.config_write = nb_debug_config_write,
};
void nb_cli_install_default(int node)
{
_install_element(node, &show_config_candidate_section_cmd);
@ -2007,9 +1960,14 @@ void nb_cli_init(struct event_loop *tm)
/* Initialize the shared candidate configuration. */
vty_shared_candidate_config = nb_config_new(NULL);
debug_init(&nb_dbg_cbs);
debug_install(&nb_dbg_cbs_config);
debug_install(&nb_dbg_cbs_state);
debug_install(&nb_dbg_cbs_rpc);
debug_install(&nb_dbg_cbs_notify);
debug_install(&nb_dbg_notif);
debug_install(&nb_dbg_events);
debug_install(&nb_dbg_libyang);
install_node(&nb_debug_node);
install_element(ENABLE_NODE, &debug_nb_cmd);
install_element(CONFIG_NODE, &debug_nb_cmd);

View file

@ -19,7 +19,9 @@
#include <sysrepo/values.h>
#include <sysrepo/xpath.h>
static struct debug nb_dbg_client_sysrepo = {0, "Northbound client: Sysrepo"};
static struct debug nb_dbg_client_sysrepo = { 0,
"debug northbound client sysrepo",
"Northbound client: Sysrepo" };
static struct event_loop *master;
static sr_session_ctx_t *session;
@ -553,29 +555,9 @@ DEFUN (debug_nb_sr,
return CMD_SUCCESS;
}
static int frr_sr_debug_config_write(struct vty *vty)
{
if (DEBUG_MODE_CHECK(&nb_dbg_client_sysrepo, DEBUG_MODE_CONF))
vty_out(vty, "debug northbound client sysrepo\n");
return 0;
}
static int frr_sr_debug_set_all(uint32_t flags, bool set)
{
DEBUG_FLAGS_SET(&nb_dbg_client_sysrepo, flags, set);
/* If all modes have been turned off, don't preserve options. */
if (!DEBUG_MODE_CHECK(&nb_dbg_client_sysrepo, DEBUG_MODE_ALL))
DEBUG_CLEAR(&nb_dbg_client_sysrepo);
return 0;
}
static void frr_sr_cli_init(void)
{
hook_register(nb_client_debug_config_write, frr_sr_debug_config_write);
hook_register(nb_client_debug_set_all, frr_sr_debug_set_all);
debug_install(&nb_dbg_client_sysrepo);
install_element(ENABLE_NODE, &debug_nb_sr_cmd);
install_element(CONFIG_NODE, &debug_nb_sr_cmd);

View file

@ -15,10 +15,14 @@
#include "mgmtd/mgmt_history.h"
#include "mgmtd/mgmt_memory.h"
struct debug mgmt_debug_be = { .desc = "Management backend adapter" };
struct debug mgmt_debug_ds = {.desc = "Management datastore"};
struct debug mgmt_debug_fe = { .desc = "Management frontend adapter" };
struct debug mgmt_debug_txn = {.desc = "Management transaction"};
struct debug mgmt_debug_be = { .conf = "debug mgmt backend",
.desc = "Management backend adapter" };
struct debug mgmt_debug_ds = { .conf = "debug mgmt datastore",
.desc = "Management datastore" };
struct debug mgmt_debug_fe = { .conf = "debug mgmt frontend",
.desc = "Management frontend adapter" };
struct debug mgmt_debug_txn = { .conf = "debug mgmt transaction",
.desc = "Management transaction" };
/* MGMTD process wide configuration. */
static struct mgmt_master mgmt_master;
@ -39,6 +43,10 @@ void mgmt_master_init(struct event_loop *master, const int buffer_size)
void mgmt_init(void)
{
debug_install(&mgmt_debug_be);
debug_install(&mgmt_debug_ds);
debug_install(&mgmt_debug_fe);
debug_install(&mgmt_debug_txn);
/* Initialize datastores */
mgmt_ds_init(mm);

View file

@ -557,52 +557,11 @@ DEFPY(mgmt_rollback,
return CMD_SUCCESS;
}
int config_write_mgmt_debug(struct vty *vty);
static struct cmd_node debug_node = {
.name = "mgmt debug",
.node = DEBUG_NODE,
.prompt = "",
.config_write = config_write_mgmt_debug,
};
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;
}
int config_write_mgmt_debug(struct vty *vty)
{
return write_mgmt_debug_helper(vty, true);
}
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;
@ -696,7 +655,6 @@ void mgmt_vty_init(void)
event_add_event(mm->master, mgmt_config_read_in, NULL, 0,
&mgmt_daemon_info->read_in);
install_node(&debug_node);
install_node(&mgmtd_node);
install_element(VIEW_NODE, &show_mgmt_be_adapter_cmd);

View file

@ -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;
}
@ -1101,10 +1099,8 @@ DEFPY(debug_path_policy, debug_path_policy_cmd, "[no] debug pathd policy",
"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;
}
@ -1307,33 +1303,9 @@ 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);
debug_install(&path_policy_debug);
install_node(&segment_routing_node);
install_node(&sr_traffic_eng_node);

View file

@ -31,7 +31,12 @@ DEFINE_MTYPE(PATHD, PCEP, "PCEP module");
/*
* Globals.
*/
static struct pcep_glob pcep_glob_space = {.dbg = {0, "pathd module: pcep"}};
static struct pcep_glob pcep_glob_space = {
.dbg_basic = { 0, "debug pathd pcep basic", "PCEP basic" },
.dbg_path = { 0, "debug pathd pcep path", "PCEP path" },
.dbg_msg = { 0, "debug pathd pcep message", "PCEP message" },
.dbg_lib = { 0, "debug pathd pcep pceplib", "PCEP lib" },
};
struct pcep_glob *pcep_g = &pcep_glob_space;
/* Main Thread Even Handler */

View file

@ -27,40 +27,22 @@ DECLARE_MTYPE(PCEP);
#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)) \
DEBUGD(&pcep_g->dbg, "pcep: " fmt, ##__VA_ARGS__); \
} while (0)
DEBUGD(&pcep_g->dbg_basic, "pcep: " fmt, ##__VA_ARGS__)
#define PCEP_DEBUG_PATH(fmt, ...) \
do { \
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PATH)) \
DEBUGD(&pcep_g->dbg, "pcep: " fmt, ##__VA_ARGS__); \
} while (0)
DEBUGD(&pcep_g->dbg_path, "pcep: " fmt, ##__VA_ARGS__)
#define PCEP_DEBUG_PCEP(fmt, ...) \
do { \
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEP)) \
DEBUGD(&pcep_g->dbg, "pcep: " fmt, ##__VA_ARGS__); \
} while (0)
DEBUGD(&pcep_g->dbg_msg, "pcep: " fmt, ##__VA_ARGS__)
#define PCEP_DEBUG_PCEPLIB(priority, fmt, ...) \
do { \
switch (priority) { \
case LOG_DEBUG: \
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, \
PCEP_DEBUG_MODE_PCEPLIB)) \
DEBUGD(&pcep_g->dbg, "pcep: " fmt, \
##__VA_ARGS__); \
DEBUGD(&pcep_g->dbg_lib, "pcep: " fmt, ##__VA_ARGS__); \
break; \
case LOG_INFO: \
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, \
PCEP_DEBUG_MODE_PCEPLIB)) \
DEBUGI(&pcep_g->dbg, "pcep: " fmt, \
##__VA_ARGS__); \
DEBUGI(&pcep_g->dbg_lib, "pcep: " fmt, ##__VA_ARGS__); \
break; \
case LOG_NOTICE: \
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, \
PCEP_DEBUG_MODE_PCEPLIB)) \
DEBUGN(&pcep_g->dbg, "pcep: " fmt, \
##__VA_ARGS__); \
DEBUGN(&pcep_g->dbg_lib, "pcep: " fmt, ##__VA_ARGS__); \
break; \
case LOG_WARNING: \
case LOG_ERR: \
@ -294,7 +276,10 @@ struct path {
};
struct pcep_glob {
struct debug dbg;
struct debug dbg_basic;
struct debug dbg_path;
struct debug dbg_msg;
struct debug dbg_lib;
struct event_loop *master;
struct frr_pthread *fpt;
uint8_t num_pce_opts_cli;

View file

@ -46,8 +46,6 @@
#define BUFFER_PCC_PCE_SIZE 1024
/* CLI Function declarations */
static int pcep_cli_debug_config_write(struct vty *vty);
static int pcep_cli_debug_set_all(uint32_t flags, bool set);
static int pcep_cli_pcep_config_write(struct vty *vty);
static int pcep_cli_pcc_config_write(struct vty *vty);
static int pcep_cli_pce_config_write(struct vty *vty);
@ -110,10 +108,6 @@ static const char PCEP_VTYSH_ARG_DELEGATION_TIMEOUT[] = "delegation-timeout";
static const char PCEP_VTYSH_ARG_SR_DRAFT07[] = "sr-draft07";
static const char PCEP_VTYSH_ARG_PCE_INIT[] = "pce-initiated";
static const char PCEP_VTYSH_ARG_TCP_MD5[] = "tcp-md5-auth";
static const char PCEP_VTYSH_ARG_BASIC[] = "basic";
static const char PCEP_VTYSH_ARG_PATH[] = "path";
static const char PCEP_VTYSH_ARG_MESSAGE[] = "message";
static const char PCEP_VTYSH_ARG_PCEPLIB[] = "pceplib";
static const char PCEP_CLI_CAP_STATEFUL[] = " [Stateful PCE]";
static const char PCEP_CLI_CAP_INCL_DB_VER[] = " [Include DB version]";
static const char PCEP_CLI_CAP_LSP_TRIGGERED[] = " [LSP Triggered Resync]";
@ -463,31 +457,19 @@ 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 *debug_type, bool set)
static int path_pcep_cli_debug(struct vty *vty, bool onoff, bool basic,
bool path, bool message, bool lib)
{
uint32_t mode = DEBUG_NODE2MODE(vty->node);
/* 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);
if (basic)
DEBUG_MODE_SET(&pcep_g->dbg_basic, mode, onoff);
if (path)
DEBUG_MODE_SET(&pcep_g->dbg_path, mode, onoff);
if (message)
DEBUG_MODE_SET(&pcep_g->dbg_msg, mode, onoff);
if (lib)
DEBUG_MODE_SET(&pcep_g->dbg_lib, mode, onoff);
return CMD_SUCCESS;
}
@ -1712,42 +1694,6 @@ static int path_pcep_cli_clear_srte_pcep_session(struct vty *vty,
* Config Write functions
*/
int pcep_cli_debug_config_write(struct vty *vty)
{
char buff[128] = "";
if (DEBUG_MODE_CHECK(&pcep_g->dbg, DEBUG_MODE_CONF)) {
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_BASIC))
csnprintfrr(buff, sizeof(buff), " %s",
PCEP_VTYSH_ARG_BASIC);
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PATH))
csnprintfrr(buff, sizeof(buff), " %s",
PCEP_VTYSH_ARG_PATH);
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEP))
csnprintfrr(buff, sizeof(buff), " %s",
PCEP_VTYSH_ARG_MESSAGE);
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEPLIB))
csnprintfrr(buff, sizeof(buff), " %s",
PCEP_VTYSH_ARG_PCEPLIB);
vty_out(vty, "debug pathd pcep%s\n", buff);
buff[0] = 0;
return 1;
}
return 0;
}
int pcep_cli_debug_set_all(uint32_t flags, bool set)
{
DEBUG_FLAGS_SET(&pcep_g->dbg, flags, set);
/* If all modes have been turned off, don't preserve options. */
if (!DEBUG_MODE_CHECK(&pcep_g->dbg, DEBUG_MODE_ALL))
DEBUG_CLEAR(&pcep_g->dbg);
return 0;
}
int pcep_cli_pcep_config_write(struct vty *vty)
{
vty_out(vty, " pcep\n");
@ -2006,36 +1952,9 @@ 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, DEBUG_MODE_CONF)) {
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_BASIC))
vty_out(vty, " Pathd pcep %s debugging is on\n",
PCEP_VTYSH_ARG_BASIC);
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PATH))
vty_out(vty, " Pathd pcep %s debugging is on\n",
PCEP_VTYSH_ARG_PATH);
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEP))
vty_out(vty, " Pathd pcep %s debugging is on\n",
PCEP_VTYSH_ARG_MESSAGE);
if (DEBUG_FLAGS_CHECK(&pcep_g->dbg, PCEP_DEBUG_MODE_PCEPLIB))
vty_out(vty, " Pathd pcep %s debugging is on\n",
PCEP_VTYSH_ARG_PCEPLIB);
}
return CMD_SUCCESS;
}
DEFPY(pcep_cli_debug,
pcep_cli_debug_cmd,
"[no] debug pathd pcep [<basic|path|message|pceplib>$debug_type]",
"[no] debug pathd pcep [{basic$basic|path$path|message$msg|pceplib$lib}]",
NO_STR DEBUG_STR
"pathd debugging\n"
"pcep module debugging\n"
@ -2044,7 +1963,11 @@ DEFPY(pcep_cli_debug,
"pcep message debugging\n"
"pceplib debugging\n")
{
return path_pcep_cli_debug(vty, debug_type, !no);
if (strmatch(argv[argc - 1]->text, "pcep"))
return path_pcep_cli_debug(vty, !no, true, true, true, true);
else
return path_pcep_cli_debug(vty, !no, !!basic, !!path, !!msg,
!!lib);
}
DEFPY(pcep_cli_show_srte_pcep_counters,
@ -2372,9 +2295,11 @@ DEFPY(pcep_cli_clear_srte_pcep_session,
void pcep_cli_init(void)
{
hook_register(pathd_srte_config_write, pcep_cli_pcep_config_write);
hook_register(nb_client_debug_config_write,
pcep_cli_debug_config_write);
hook_register(nb_client_debug_set_all, pcep_cli_debug_set_all);
debug_install(&pcep_g->dbg_basic);
debug_install(&pcep_g->dbg_path);
debug_install(&pcep_g->dbg_msg);
debug_install(&pcep_g->dbg_lib);
memset(&pce_connections_g, 0, sizeof(pce_connections_g));
@ -2423,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);

View file

@ -30,12 +30,11 @@ static uint32_t path_ted_stop_importing_igp(void);
static enum zclient_send_status path_ted_link_state_sync(void);
static void path_ted_timer_handler_sync(struct event *thread);
static void path_ted_timer_handler_refresh(struct event *thread);
static int path_ted_cli_debug_config_write(struct vty *vty);
static int path_ted_cli_debug_set_all(uint32_t flags, bool set);
extern struct zclient *zclient;
struct ted_state ted_state_g = {};
struct ted_state ted_state_g = { .dbg = { .conf = "debug pathd mpls-te",
.desc = "Pathd TED" } };
/*
* path_path_ted public API function implementations
@ -335,10 +334,8 @@ DEFPY (debug_path_ted,
"ted debugging\n")
{
uint32_t mode = DEBUG_NODE2MODE(vty->node);
bool no_debug = (no != NULL);
DEBUG_MODE_SET(&ted_state_g.dbg, mode, !no);
DEBUG_FLAGS_SET(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC, !no_debug);
return CMD_SUCCESS;
}
@ -466,37 +463,6 @@ DEFPY (show_pathd_ted_db,
return CMD_SUCCESS;
}
/*
* Config Write functions
*/
int path_ted_cli_debug_config_write(struct vty *vty)
{
if (DEBUG_MODE_CHECK(&ted_state_g.dbg, DEBUG_MODE_CONF)) {
if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC))
vty_out(vty, "debug pathd mpls-te\n");
return 1;
}
return 0;
}
void path_ted_show_debugging(struct vty *vty)
{
if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC))
vty_out(vty, " Path TED debugging is on\n");
}
int path_ted_cli_debug_set_all(uint32_t flags, bool set)
{
DEBUG_FLAGS_SET(&ted_state_g.dbg, flags, set);
/* If all modes have been turned off, don't preserve options. */
if (!DEBUG_MODE_CHECK(&ted_state_g.dbg, DEBUG_MODE_ALL))
DEBUG_CLEAR(&ted_state_g.dbg);
return 0;
}
/**
* Help fn to show ted related configuration
*
@ -543,9 +509,7 @@ static void path_ted_register_vty(void)
install_element(CONFIG_NODE, &debug_path_ted_cmd);
install_element(ENABLE_NODE, &debug_path_ted_cmd);
hook_register(nb_client_debug_config_write,
path_ted_cli_debug_config_write);
hook_register(nb_client_debug_set_all, path_ted_cli_debug_set_all);
debug_install(&ted_state_g.dbg);
}
/**

View file

@ -59,28 +59,17 @@ struct ted_state {
struct debug dbg;
};
/* Debug flags. */
#define PATH_TED_DEBUG_BASIC 0x01
#define PATH_TED_DEBUG(fmt, ...) \
do { \
if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
DEBUGD(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
} while (0)
DEBUGD(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__)
#define PATH_TED_ERROR(fmt, ...) \
do { \
if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
DEBUGE(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
} while (0)
DEBUGE(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__)
#define PATH_TED_WARN(fmt, ...) \
do { \
if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
DEBUGW(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
} while (0)
DEBUGW(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__)
#define PATH_TED_INFO(fmt, ...) \
do { \
if (DEBUG_FLAGS_CHECK(&ted_state_g.dbg, PATH_TED_DEBUG_BASIC)) \
DEBUGI(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__); \
} while (0)
DEBUGI(&ted_state_g.dbg, "mpls-te: " fmt, ##__VA_ARGS__)
/* TED management functions */
bool path_ted_is_initialized(void);
@ -92,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 */

View file

@ -33,15 +33,13 @@ DEFINE_HOOK(pathd_candidate_updated, (struct srte_candidate * candidate),
DEFINE_HOOK(pathd_candidate_removed, (struct srte_candidate * candidate),
(candidate));
struct debug path_policy_debug;
struct debug path_policy_debug = {
.conf = "debug pathd policy",
.desc = "Pathd policy",
};
#define PATH_POLICY_DEBUG(fmt, ...) \
do { \
if (DEBUG_FLAGS_CHECK(&path_policy_debug, \
PATH_POLICY_DEBUG_BASIC)) \
DEBUGD(&path_policy_debug, "policy: " fmt, \
##__VA_ARGS__); \
} while (0)
DEBUGD(&path_policy_debug, "policy: " fmt, ##__VA_ARGS__)
static void trigger_pathd_candidate_created(struct srte_candidate *candidate);
@ -1281,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_FLAGS_CHECK(&path_policy_debug, PATH_POLICY_DEBUG_BASIC))
vty_out(vty, " Path policy debugging is on\n");
}
void pathd_shutdown(void)
{
path_ted_teardown();

View file

@ -32,8 +32,6 @@ enum srte_protocol_origin {
extern struct debug path_policy_debug;
#define PATH_POLICY_DEBUG_BASIC 0x01
enum srte_policy_status {
SRTE_POLICY_STATUS_UNKNOWN = 0,
SRTE_POLICY_STATUS_DOWN = 1,
@ -437,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);

View file

@ -13,53 +13,16 @@
#include "pbrd/pbr_debug_clippy.c"
#include "pbrd/pbr_debug.h"
struct debug pbr_dbg_map = {0, "PBR map"};
struct debug pbr_dbg_zebra = {0, "PBR Zebra communications"};
struct debug pbr_dbg_nht = {0, "PBR nexthop tracking"};
struct debug pbr_dbg_event = {0, "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",
};
void pbr_debug_set_all(uint32_t flags, bool set)
{
for (unsigned int i = 0; i < array_size(pbr_debugs); i++) {
DEBUG_FLAGS_SET(pbr_debugs[i], flags, set);
/* if all modes have been turned off, don't preserve options */
if (!DEBUG_MODE_CHECK(pbr_debugs[i], DEBUG_MODE_ALL))
DEBUG_CLEAR(pbr_debugs[i]);
}
}
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;
}
int pbr_debug_config_write(struct vty *vty)
{
return pbr_debug_config_write_helper(vty, true);
}
struct debug_callbacks pbr_dbg_cbs = {.debug_set_all = pbr_debug_set_all};
struct debug pbr_dbg_map = { 0, "debug pbr map", "PBR map" };
struct debug pbr_dbg_zebra = { 0, "debug pbr zebra",
"PBR Zebra communications" };
struct debug pbr_dbg_nht = { 0, "debug pbr nht", "PBR nexthop tracking" };
struct debug pbr_dbg_event = { 0, "debug pbr events", "PBR events" };
void pbr_debug_init(void)
{
debug_init(&pbr_dbg_cbs);
debug_install(&pbr_dbg_map);
debug_install(&pbr_dbg_zebra);
debug_install(&pbr_dbg_nht);
debug_install(&pbr_dbg_event);
}

View file

@ -35,26 +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);
/*
* Print PBR debugging configuration.
*
* vty
* VTY to print debugging configuration to.
*/
int pbr_debug_config_write(struct vty *vty);
#endif /* __PBR_DEBUG_H__ */

View file

@ -1954,13 +1954,6 @@ DEFPY (show_pbr_interface,
/* PBR debugging CLI ------------------------------------------------------- */
static struct cmd_node debug_node = {
.name = "debug",
.node = DEBUG_NODE,
.prompt = "",
.config_write = pbr_debug_config_write,
};
DEFPY(debug_pbr,
debug_pbr_cmd,
"[no] debug pbr [{map$map|zebra$zebra|nht$nht|events$events}]",
@ -1973,19 +1966,20 @@ DEFPY(debug_pbr,
"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);
bool all = false;
/* no specific debug --> act on all of them */
if (strmatch(argv[argc - 1]->text, "pbr"))
pbr_debug_set_all(mode, !no);
all = true;
if (map || all)
DEBUG_MODE_SET(&pbr_dbg_map, mode, !no);
if (zebra || all)
DEBUG_MODE_SET(&pbr_dbg_zebra, mode, !no);
if (nht || all)
DEBUG_MODE_SET(&pbr_dbg_nht, mode, !no);
if (events || all)
DEBUG_MODE_SET(&pbr_dbg_event, mode, !no);
return CMD_SUCCESS;
}
@ -1999,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;
@ -2194,7 +2186,6 @@ void pbr_vty_init(void)
install_node(&pbr_map_node);
/* debug */
install_node(&debug_node);
install_element(ENABLE_NODE, &debug_pbr_cmd);
install_element(CONFIG_NODE, &debug_pbr_cmd);
install_element(ENABLE_NODE, &show_debugging_pbr_cmd);

View file

@ -19,68 +19,11 @@
*/
/* clang-format off */
struct debug static_dbg_events = {0, "Staticd events"};
struct debug static_dbg_route = {0, "Staticd route"};
struct debug static_dbg_bfd = {0, "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"
};
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"};
/* clang-format on */
/*
* Set or unset all staticd debugs
*
* flags
* The flags to set
*
* set
* Whether to set or unset the specified flags
*/
static void static_debug_set_all(uint32_t flags, bool set)
{
for (unsigned int i = 0; i < array_size(static_debug_arr); i++) {
DEBUG_FLAGS_SET(static_debug_arr[i], flags, set);
/* if all modes have been turned off, don't preserve options */
if (!DEBUG_MODE_CHECK(static_debug_arr[i], DEBUG_MODE_ALL))
DEBUG_CLEAR(static_debug_arr[i]);
}
}
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_config_write_debug(struct vty *vty)
{
return static_debug_config_write_helper(vty, true);
}
int static_debug_status_write(struct vty *vty)
{
return static_debug_config_write_helper(vty, false);
}
/*
* Set debugging status.
*
@ -113,11 +56,9 @@ void static_debug_set(int vtynode, bool onoff, bool events, bool route,
* Debug lib initialization
*/
struct debug_callbacks static_dbg_cbs = {
.debug_set_all = static_debug_set_all
};
void static_debug_init(void)
{
debug_init(&static_dbg_cbs);
debug_install(&static_dbg_events);
debug_install(&static_dbg_route);
debug_install(&static_dbg_bfd);
}

View file

@ -28,22 +28,6 @@ extern struct debug static_dbg_bfd;
*/
void static_debug_init(void);
/*
* Print staticd debugging configuration.
*
* vty
* VTY to print debugging configuration to.
*/
int static_config_write_debug(struct vty *vty);
/*
* 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.
*

View file

@ -1639,26 +1639,16 @@ 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;
}
static struct cmd_node debug_node = {
.name = "debug",
.node = DEBUG_NODE,
.prompt = "",
.config_write = static_config_write_debug,
};
#endif /* ifndef INCLUDE_MGMTD_CMDDEFS_ONLY */
void static_vty_init(void)
{
#ifndef INCLUDE_MGMTD_CMDDEFS_ONLY
install_node(&debug_node);
install_element(ENABLE_NODE, &debug_staticd_cmd);
install_element(CONFIG_NODE, &debug_staticd_cmd);
install_element(ENABLE_NODE, &show_debugging_static_cmd);

View file

@ -5,6 +5,7 @@
*/
#include <zebra.h>
#include "debug.h"
#include "memory.h"
#include "plist.h"
#include "printfrr.h"
@ -1348,6 +1349,7 @@ static void test_peer_attr(struct test *test, struct test_peer_attr *pa)
static void bgp_startup(void)
{
cmd_init(1);
debug_init();
zlog_aux_init("NONE: ", LOG_DEBUG);
zprivs_preinit(&bgpd_privs);
zprivs_init(&bgpd_privs);

View file

@ -6,6 +6,7 @@
#include <sys/stat.h>
#include <lib/version.h>
#include "debug.h"
#include "getopt.h"
#include "frrevent.h"
#include "vty.h"
@ -141,6 +142,7 @@ int main(int argc, char **argv)
cmd_init(1);
vty_init(master, false);
lib_cmd_init();
debug_init();
nb_init(master, NULL, 0, false);
/* OSPF vty inits. */

View file

@ -9,6 +9,7 @@
#include <zebra.h>
#include <sys/stat.h>
#include "debug.h"
#include "frrevent.h"
#include "vty.h"
#include "command.h"
@ -71,6 +72,7 @@ int main(int argc, char **argv)
vty_init(master, false);
lib_cmd_init();
debug_init();
for (yangcount = 0; test_yang_modules && test_yang_modules[yangcount];
yangcount++)

View file

@ -409,7 +409,6 @@ domainname test.domain
!
!
!
!
end
test# conf t
test(config)# hostname foohost
@ -425,7 +424,6 @@ domainname test.domain
!
!
!
!
end
foohost(config)#
end.

View file

@ -21,6 +21,7 @@
#include <stdlib.h>
#include <unistd.h>
#include "debug.h"
#include "command.h"
#include "memory.h"
#include "vector.h"
@ -195,6 +196,7 @@ static void test_init(void)
struct cmd_element *cmd;
cmd_init(1);
debug_init();
nb_init(master, NULL, 0, false);
install_node(&bgp_node);

View file

@ -7,6 +7,7 @@
#include <zebra.h>
#include <sys/stat.h>
#include "debug.h"
#include "frrevent.h"
#include "vty.h"
#include "command.h"
@ -459,6 +460,7 @@ int main(int argc, char **argv)
cmd_hostname_set("test");
vty_init(master, false);
lib_cmd_init();
debug_init();
nb_init(master, modules, array_size(modules), false);
install_element(ENABLE_NODE, &test_rpc_cmd);

View file

@ -9,6 +9,7 @@
#include <unistd.h>
#include <zebra.h>
#include "debug.h"
#include "filter.h"
#include "frr_pthread.h"
#include "libfrr.h"
@ -79,6 +80,7 @@ static void static_startup(void)
// static struct option_chain *oc;
cmd_init(1);
debug_init();
zlog_aux_init("NONE: ", LOG_DEBUG);
zprivs_preinit(&static_privs);

View file

@ -13,79 +13,15 @@
#include "vrrp_debug.h"
/* clang-format off */
struct debug vrrp_dbg_arp = {0, "VRRP ARP"};
struct debug vrrp_dbg_auto = {0, "VRRP autoconfiguration events"};
struct debug vrrp_dbg_ndisc = {0, "VRRP Neighbor Discovery"};
struct debug vrrp_dbg_pkt = {0, "VRRP packets"};
struct debug vrrp_dbg_proto = {0, "VRRP protocol events"};
struct debug vrrp_dbg_sock = {0, "VRRP sockets"};
struct debug vrrp_dbg_zebra = {0, "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",
};
struct debug vrrp_dbg_arp = {0, "debug vrrp arp", "VRRP ARP"};
struct debug vrrp_dbg_auto = {0, "debug vrrp autoconfigure", "VRRP autoconfiguration events"};
struct debug vrrp_dbg_ndisc = {0, "debug vrrp ndisc", "VRRP Neighbor Discovery"};
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"};
/* clang-format on */
/*
* Set or unset flags on all debugs for vrrpd.
*
* flags
* The flags to set
*
* set
* Whether to set or unset the specified flags
*/
static void vrrp_debug_set_all(uint32_t flags, bool set)
{
for (unsigned int i = 0; i < array_size(vrrp_debugs); i++) {
DEBUG_FLAGS_SET(vrrp_debugs[i], flags, set);
/* if all modes have been turned off, don't preserve options */
if (!DEBUG_MODE_CHECK(vrrp_debugs[i], DEBUG_MODE_ALL))
DEBUG_CLEAR(vrrp_debugs[i]);
}
}
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_config_write_debug(struct vty *vty)
{
return vrrp_debug_config_write_helper(vty, true);
}
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)
@ -110,9 +46,13 @@ void vrrp_debug_set(struct interface *ifp, uint8_t vrid, int vtynode,
/* ------------------------------------------------------------------------- */
struct debug_callbacks vrrp_dbg_cbs = {.debug_set_all = vrrp_debug_set_all};
void vrrp_debug_init(void)
{
debug_init(&vrrp_dbg_cbs);
debug_install(&vrrp_dbg_arp);
debug_install(&vrrp_dbg_auto);
debug_install(&vrrp_dbg_ndisc);
debug_install(&vrrp_dbg_pkt);
debug_install(&vrrp_dbg_proto);
debug_install(&vrrp_dbg_sock);
debug_install(&vrrp_dbg_zebra);
}

View file

@ -27,14 +27,6 @@ extern struct debug vrrp_dbg_zebra;
*/
void vrrp_debug_init(void);
/*
* Print VRRP debugging configuration.
*
* vty
* VTY to print debugging configuration to.
*/
int vrrp_config_write_debug(struct vty *vty);
/*
* Print VRRP debugging configuration, human readable form.
*

View file

@ -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;
@ -747,13 +745,6 @@ DEFUN_NOSH (show_debugging_vrrp,
/* clang-format on */
static struct cmd_node debug_node = {
.name = "debug",
.node = DEBUG_NODE,
.prompt = "",
.config_write = vrrp_config_write_debug,
};
static struct cmd_node vrrp_node = {
.name = "vrrp",
.node = VRRP_NODE,
@ -763,7 +754,6 @@ static struct cmd_node vrrp_node = {
void vrrp_vty_init(void)
{
install_node(&debug_node);
install_node(&vrrp_node);
vrf_cmd_init(NULL);
if_cmd_init_default();

View file

@ -453,10 +453,6 @@ void vtysh_config_parse_line(void *arg, const char *line)
config = config_get(FORWARDING_NODE, line);
else if (strncmp(line, "debug vrf", strlen("debug vrf")) == 0)
config = config_get(VRF_DEBUG_NODE, line);
else if (strncmp(line, "debug northbound",
strlen("debug northbound"))
== 0)
config = config_get(NORTHBOUND_DEBUG_NODE, line);
else if (strncmp(line, "debug route-map",
strlen("debug route-map"))
== 0)
@ -464,12 +460,6 @@ void vtysh_config_parse_line(void *arg, const char *line)
else if (strncmp(line, "debug resolver",
strlen("debug resolver")) == 0)
config = config_get(RESOLVER_DEBUG_NODE, line);
else if (strncmp(line, "debug mgmt client frontend",
strlen("debug mgmt client frontend")) == 0)
config = config_get(MGMT_FE_DEBUG_NODE, line);
else if (strncmp(line, "debug mgmt client backend",
strlen("debug mgmt client backend")) == 0)
config = config_get(MGMT_BE_DEBUG_NODE, line);
else if (strncmp(line, "debug", strlen("debug")) == 0)
config = config_get(DEBUG_NODE, line);
else if (strncmp(line, "password", strlen("password")) == 0
@ -537,9 +527,8 @@ void vtysh_config_parse_line(void *arg, const char *line)
(I) == ACCESS_IPV6_NODE || (I) == ACCESS_MAC_NODE || \
(I) == PREFIX_IPV6_NODE || (I) == FORWARDING_NODE || \
(I) == DEBUG_NODE || (I) == AAA_NODE || (I) == VRF_DEBUG_NODE || \
(I) == NORTHBOUND_DEBUG_NODE || (I) == RMAP_DEBUG_NODE || \
(I) == RESOLVER_DEBUG_NODE || (I) == MPLS_NODE || \
(I) == KEYCHAIN_KEY_NODE)
(I) == RMAP_DEBUG_NODE || (I) == RESOLVER_DEBUG_NODE || \
(I) == MPLS_NODE || (I) == KEYCHAIN_KEY_NODE)
static void configvec_dump(vector vec, bool nested)
{