summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/northbound_cli.c16
-rw-r--r--lib/northbound_grpc.cpp5
-rw-r--r--lib/yang.c15
-rw-r--r--lib/yang.h8
-rw-r--r--vtysh/vtysh.c18
5 files changed, 47 insertions, 15 deletions
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c
index 61919f0229..d3e788d5d3 100644
--- a/lib/northbound_cli.c
+++ b/lib/northbound_cli.c
@@ -40,6 +40,7 @@ struct debug nb_dbg_cbs_state = {0, "Northbound callbacks: state"};
struct debug nb_dbg_cbs_rpc = {0, "Northbound callbacks: RPCs"};
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 nb_config *vty_shared_candidate_config;
static struct thread_master *master;
@@ -1581,7 +1582,7 @@ 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_notif, &nb_dbg_events,
+ &nb_dbg_notif, &nb_dbg_events, &nb_dbg_libyang,
};
static const char *const nb_debugs_conflines[] = {
@@ -1590,6 +1591,7 @@ static const char *const nb_debugs_conflines[] = {
"debug northbound callbacks rpc",
"debug northbound notifications",
"debug northbound events",
+ "debug northbound libyang",
};
DEFINE_HOOK(nb_client_debug_set_all, (uint32_t flags, bool set), (flags, set));
@@ -1614,6 +1616,7 @@ DEFPY (debug_nb,
callbacks$cbs [{configuration$cbs_cfg|state$cbs_state|rpc$cbs_rpc}]\
|notifications$notifications\
|events$events\
+ |libyang$libyang\
>]",
NO_STR
DEBUG_STR
@@ -1623,7 +1626,8 @@ DEFPY (debug_nb,
"State\n"
"RPC\n"
"Notifications\n"
- "Events\n")
+ "Events\n"
+ "libyang debugging\n")
{
uint32_t mode = DEBUG_NODE2MODE(vty->node);
@@ -1641,10 +1645,16 @@ DEFPY (debug_nb,
DEBUG_MODE_SET(&nb_dbg_notif, mode, !no);
if (events)
DEBUG_MODE_SET(&nb_dbg_events, mode, !no);
+ if (libyang) {
+ 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"))
+ if (strmatch(argv[argc - 1]->text, "northbound")) {
nb_debug_set_all(mode, !no);
+ yang_debugging_set(!no);
+ }
return CMD_SUCCESS;
}
diff --git a/lib/northbound_grpc.cpp b/lib/northbound_grpc.cpp
index 218cae4e74..089899368d 100644
--- a/lib/northbound_grpc.cpp
+++ b/lib/northbound_grpc.cpp
@@ -616,6 +616,11 @@ class NorthboundImpl final : public frr::Northbound::Service
return LYD_JSON;
case frr::XML:
return LYD_XML;
+ default:
+ flog_err(EC_LIB_DEVELOPMENT,
+ "%s: unknown data encoding format (%u)",
+ __func__, encoding);
+ exit(1);
}
}
diff --git a/lib/yang.c b/lib/yang.c
index 5470762ea6..d153f75530 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -616,6 +616,17 @@ static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path)
zlog(priority, "libyang: %s", msg);
}
+void yang_debugging_set(bool enable)
+{
+ if (enable) {
+ ly_verb(LY_LLDBG);
+ ly_verb_dbg(0xFF);
+ } else {
+ ly_verb(LY_LLERR);
+ ly_verb_dbg(0);
+ }
+}
+
struct ly_ctx *yang_ctx_new_setup(void)
{
struct ly_ctx *ctx;
@@ -645,10 +656,6 @@ void yang_init(void)
ly_set_log_clb(ly_log_cb, 1);
ly_log_options(LY_LOLOG | LY_LOSTORE);
- /* Let libyang log everything possible. */
- ly_verb(LY_LLDBG);
- ly_verb_dbg(0xFF);
-
/* Initialize libyang container for native models. */
ly_native_ctx = yang_ctx_new_setup();
if (!ly_native_ctx) {
diff --git a/lib/yang.h b/lib/yang.h
index 322c74c76a..6892e36019 100644
--- a/lib/yang.h
+++ b/lib/yang.h
@@ -486,6 +486,14 @@ extern struct yang_data *yang_data_list_find(const struct list *list,
extern struct ly_ctx *yang_ctx_new_setup(void);
/*
+ * Enable or disable libyang verbose debugging.
+ *
+ * enable
+ * When set to true, enable libyang verbose debugging, otherwise disable it.
+ */
+extern void yang_debugging_set(bool enable);
+
+/*
* Initialize the YANG subsystem. Should be called only once during the
* daemon initialization process.
*/
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 0c7a7471b1..9f339f58b3 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -1339,7 +1339,7 @@ DEFUNSH(VTYSH_REALLYALL, vtysh_end_all, vtysh_end_all_cmd, "end",
}
DEFUNSH(VTYSH_BGPD, router_bgp, router_bgp_cmd,
- "router bgp [(1-4294967295)$instasn [<view|vrf> WORD]]",
+ "router bgp [(1-4294967295) [<view|vrf> WORD]]",
ROUTER_STR BGP_STR AS_STR
"BGP view\nBGP VRF\n"
"View/VRF name\n")
@@ -2427,10 +2427,10 @@ DEFUN (vtysh_show_error_code,
/* Northbound. */
DEFUN (show_yang_operational_data,
show_yang_operational_data_cmd,
- "show yang operational-data XPATH$xpath\
+ "show yang operational-data XPATH\
[{\
- format <json$json|xml$xml>\
- |translate WORD$translator_family\
+ format <json|xml>\
+ |translate WORD\
}]" DAEMONS_LIST,
SHOW_STR
"YANG information\n"
@@ -2454,9 +2454,10 @@ DEFUNSH(VTYSH_ALL, debug_nb,
debug_nb_cmd,
"[no] debug northbound\
[<\
- callbacks$cbs [{configuration$cbs_cfg|state$cbs_state|rpc$cbs_rpc}]\
- |notifications$notifications\
- |events$events\
+ callbacks [{configuration|state|rpc}]\
+ |notifications\
+ |events\
+ |libyang\
>]",
NO_STR
DEBUG_STR
@@ -2466,7 +2467,8 @@ DEFUNSH(VTYSH_ALL, debug_nb,
"State\n"
"RPC\n"
"Notifications\n"
- "Events\n")
+ "Events\n"
+ "libyang debugging\n")
{
return CMD_SUCCESS;
}