summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2016-06-21 18:43:40 +0000
committerQuentin Young <qlyoung@cumulusnetworks.com>2016-06-21 18:55:01 +0000
commit556b904e5d83ff9a9050ee9b6d0025cf1b3fbe03 (patch)
treef27aab0352b29efadcc94dec317526d78871bda4
parentbb132d19d7a0f5687911ab2979beb260014c0a8c (diff)
zebra: Add `debug zebra kernel msgdump` functionality
Add command and associated functionality to enable dumping raw netlink messages. Ticket: CM-6568 Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r--zebra/debug.c46
-rw-r--r--zebra/debug.h6
-rw-r--r--zebra/rt_netlink.c16
3 files changed, 63 insertions, 5 deletions
diff --git a/zebra/debug.c b/zebra/debug.c
index 4411be9b99..cdf233879a 100644
--- a/zebra/debug.c
+++ b/zebra/debug.c
@@ -67,6 +67,10 @@ DEFUN (show_debugging_zebra,
if (IS_ZEBRA_DEBUG_KERNEL)
vty_out (vty, " Zebra kernel debugging is on%s", VTY_NEWLINE);
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
+ vty_out (vty, " Zebra kernel netlink message dumps (send) are on%s", VTY_NEWLINE);
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
+ vty_out (vty, " Zebra kernel netlink message dumps (recv) are on%s", VTY_NEWLINE);
/* Check here using flags as the 'macro' does an OR */
if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB))
@@ -162,7 +166,24 @@ DEFUN (debug_zebra_kernel,
"Zebra configuration\n"
"Debug option set for zebra between kernel interface\n")
{
- zebra_debug_kernel = ZEBRA_DEBUG_KERNEL;
+ SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
+ return CMD_SUCCESS;
+}
+
+DEFUN (debug_zebra_kernel_msgdump,
+ debug_zebra_kernel_msgdump_cmd,
+ "debug zebra kernel msgdump {recv|send}",
+ DEBUG_STR
+ "Zebra configuration\n"
+ "Debug option set for zebra between kernel interface\n"
+ "Dump raw netlink messages, sent and received\n"
+ "Dump raw netlink messages received\n"
+ "Dump raw netlink messages sent\n")
+{
+ if (!argv[1] || (argv[0] && strncmp(argv[0], "recv", strlen(argv[0])) == 0))
+ SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
+ if (!argv[0] || (argv[1] && strncmp(argv[1], "send", strlen(argv[1])) == 0))
+ SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
return CMD_SUCCESS;
}
@@ -261,7 +282,24 @@ DEFUN (no_debug_zebra_kernel,
"Zebra configuration\n"
"Debug option set for zebra between kernel interface\n")
{
- zebra_debug_kernel = 0;
+ UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_zebra_kernel_msgdump,
+ no_debug_zebra_kernel_msgdump_cmd,
+ "no debug zebra kernel msgdump {recv|send}",
+ DEBUG_STR
+ "Zebra configuration\n"
+ "Debug option set for zebra between kernel interface\n"
+ "Dump raw netlink messages, sent and received\n"
+ "Dump raw netlink messages received\n"
+ "Dump raw netlink messages sent\n")
+{
+ if (!argv[1] || (argv[0] && strncmp(argv[0], "recv", strlen(argv[0])) == 0))
+ UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
+ if (!argv[0] || (argv[1] && strncmp(argv[1], "send", strlen(argv[1])) == 0))
+ UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
return CMD_SUCCESS;
}
@@ -386,6 +424,7 @@ zebra_debug_init (void)
install_element (ENABLE_NODE, &debug_zebra_packet_direct_cmd);
install_element (ENABLE_NODE, &debug_zebra_packet_detail_cmd);
install_element (ENABLE_NODE, &debug_zebra_kernel_cmd);
+ install_element (ENABLE_NODE, &debug_zebra_kernel_msgdump_cmd);
install_element (ENABLE_NODE, &debug_zebra_rib_cmd);
install_element (ENABLE_NODE, &debug_zebra_rib_detailed_cmd);
install_element (ENABLE_NODE, &debug_zebra_fpm_cmd);
@@ -393,6 +432,7 @@ zebra_debug_init (void)
install_element (ENABLE_NODE, &no_debug_zebra_nht_cmd);
install_element (ENABLE_NODE, &no_debug_zebra_packet_cmd);
install_element (ENABLE_NODE, &no_debug_zebra_kernel_cmd);
+ install_element (ENABLE_NODE, &no_debug_zebra_kernel_msgdump_cmd);
install_element (ENABLE_NODE, &no_debug_zebra_rib_cmd);
install_element (ENABLE_NODE, &no_debug_zebra_rib_detailed_cmd);
install_element (ENABLE_NODE, &no_debug_zebra_fpm_cmd);
@@ -403,6 +443,7 @@ zebra_debug_init (void)
install_element (CONFIG_NODE, &debug_zebra_packet_direct_cmd);
install_element (CONFIG_NODE, &debug_zebra_packet_detail_cmd);
install_element (CONFIG_NODE, &debug_zebra_kernel_cmd);
+ install_element (CONFIG_NODE, &debug_zebra_kernel_msgdump_cmd);
install_element (CONFIG_NODE, &debug_zebra_rib_cmd);
install_element (CONFIG_NODE, &debug_zebra_rib_detailed_cmd);
install_element (CONFIG_NODE, &debug_zebra_fpm_cmd);
@@ -410,6 +451,7 @@ zebra_debug_init (void)
install_element (CONFIG_NODE, &no_debug_zebra_nht_cmd);
install_element (CONFIG_NODE, &no_debug_zebra_packet_cmd);
install_element (CONFIG_NODE, &no_debug_zebra_kernel_cmd);
+ install_element (CONFIG_NODE, &no_debug_zebra_kernel_msgdump_cmd);
install_element (CONFIG_NODE, &no_debug_zebra_rib_cmd);
install_element (CONFIG_NODE, &no_debug_zebra_rib_detailed_cmd);
install_element (CONFIG_NODE, &no_debug_zebra_fpm_cmd);
diff --git a/zebra/debug.h b/zebra/debug.h
index 42af53f0d8..4416068bf2 100644
--- a/zebra/debug.h
+++ b/zebra/debug.h
@@ -32,6 +32,8 @@
#define ZEBRA_DEBUG_DETAIL 0x80
#define ZEBRA_DEBUG_KERNEL 0x01
+#define ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND 0x20
+#define ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV 0x40
#define ZEBRA_DEBUG_RIB 0x01
#define ZEBRA_DEBUG_RIB_DETAILED 0x02
@@ -48,6 +50,10 @@
#define IS_ZEBRA_DEBUG_DETAIL (zebra_debug_packet & ZEBRA_DEBUG_DETAIL)
#define IS_ZEBRA_DEBUG_KERNEL (zebra_debug_kernel & ZEBRA_DEBUG_KERNEL)
+#define IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND \
+ (zebra_debug_kernel & ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
+#define IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV \
+ (zebra_debug_kernel & ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
#define IS_ZEBRA_DEBUG_RIB \
(zebra_debug_rib & (ZEBRA_DEBUG_RIB | ZEBRA_DEBUG_RIB_DETAILED))
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 0e336fe974..72951322ff 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -349,6 +349,12 @@ netlink_parse_info (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *,
return -1;
}
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV)
+ {
+ zlog_debug("%s: << netlink message dump [recv]", __func__);
+ zlog_hexdump(&msg, sizeof(msg));
+ }
+
read_in++;
for (h = (struct nlmsghdr *) buf; NLMSG_OK (h, (unsigned int) status);
h = NLMSG_NEXT (h, status))
@@ -378,9 +384,7 @@ netlink_parse_info (int (*filter) (struct sockaddr_nl *, struct nlmsghdr *,
/* return if not a multipart message, otherwise continue */
if (!(h->nlmsg_flags & NLM_F_MULTI))
- {
- return 0;
- }
+ return 0;
continue;
}
@@ -1650,6 +1654,12 @@ netlink_talk (struct nlmsghdr *n, struct nlsock *nl, struct zebra_ns *zns)
if (zserv_privs.change (ZPRIVS_LOWER))
zlog (NULL, LOG_ERR, "Can't lower privileges");
+ if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND)
+ {
+ zlog_debug("%s: >> netlink message dump [sent]", __func__);
+ zlog_hexdump(&msg, sizeof(msg));
+ }
+
if (status < 0)
{
zlog (NULL, LOG_ERR, "netlink_talk sendmsg() error: %s",