]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/debug.c
Merge pull request #468 from qlyoung/fix-list-perm
[mirror_frr.git] / zebra / debug.c
index 175029b8a2e20626b4b14c38e6ed6695ec2c3c17..a42d5aa3ef98763887c70bb74f19aea428db5e74 100644 (file)
@@ -29,13 +29,16 @@ unsigned long zebra_debug_event;
 unsigned long zebra_debug_packet;
 unsigned long zebra_debug_kernel;
 unsigned long zebra_debug_rib;
+unsigned long zebra_debug_fpm;
+unsigned long zebra_debug_nht;
+unsigned long zebra_debug_mpls;
 
 DEFUN (show_debugging_zebra,
        show_debugging_zebra_cmd,
        "show debugging zebra",
        SHOW_STR
-       "Zebra configuration\n"
-       "Debugging information\n")
+       "Debugging information\n"
+       "Zebra configuration\n")
 {
   vty_out (vty, "Zebra debugging status:%s", VTY_NEWLINE);
 
@@ -65,11 +68,23 @@ 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);
 
-  if (IS_ZEBRA_DEBUG_RIB)
+  /* Check here using flags as the 'macro' does an OR */
+  if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB))
     vty_out (vty, "  Zebra RIB debugging is on%s", VTY_NEWLINE);
-  if (IS_ZEBRA_DEBUG_RIB_Q)
-    vty_out (vty, "  Zebra RIB queue debugging is on%s", VTY_NEWLINE);
+  if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED))
+    vty_out (vty, "  Zebra RIB detailed debugging is on%s", VTY_NEWLINE);
+
+  if (IS_ZEBRA_DEBUG_FPM)
+    vty_out (vty, "  Zebra FPM debugging is on%s", VTY_NEWLINE);
+  if (IS_ZEBRA_DEBUG_NHT)
+    vty_out (vty, "  Zebra next-hop tracking debugging is on%s", VTY_NEWLINE);
+  if (IS_ZEBRA_DEBUG_MPLS)
+    vty_out (vty, "  Zebra MPLS debugging is on%s", VTY_NEWLINE);
 
   return CMD_SUCCESS;
 }
@@ -85,53 +100,55 @@ DEFUN (debug_zebra_events,
   return CMD_WARNING;
 }
 
-DEFUN (debug_zebra_packet,
-       debug_zebra_packet_cmd,
-       "debug zebra packet",
+DEFUN (debug_zebra_nht,
+       debug_zebra_nht_cmd,
+       "debug zebra nht",
        DEBUG_STR
        "Zebra configuration\n"
-       "Debug option set for zebra packet\n")
+       "Debug option set for zebra next hop tracking\n")
 {
-  zebra_debug_packet = ZEBRA_DEBUG_PACKET;
-  zebra_debug_packet |= ZEBRA_DEBUG_SEND;
-  zebra_debug_packet |= ZEBRA_DEBUG_RECV;
-  return CMD_SUCCESS;
+  zebra_debug_nht = ZEBRA_DEBUG_NHT;
+  return CMD_WARNING;
 }
 
-DEFUN (debug_zebra_packet_direct,
-       debug_zebra_packet_direct_cmd,
-       "debug zebra packet (recv|send)",
+DEFUN (debug_zebra_mpls,
+       debug_zebra_mpls_cmd,
+       "debug zebra mpls",
        DEBUG_STR
        "Zebra configuration\n"
-       "Debug option set for zebra packet\n"
-       "Debug option set for receive packet\n"
-       "Debug option set for send packet\n")
+       "Debug option set for zebra MPLS LSPs\n")
 {
-  zebra_debug_packet = ZEBRA_DEBUG_PACKET;
-  if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
-    zebra_debug_packet |= ZEBRA_DEBUG_SEND;
-  if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
-    zebra_debug_packet |= ZEBRA_DEBUG_RECV;
-  zebra_debug_packet &= ~ZEBRA_DEBUG_DETAIL;
-  return CMD_SUCCESS;
+  zebra_debug_mpls = ZEBRA_DEBUG_MPLS;
+  return CMD_WARNING;
 }
 
-DEFUN (debug_zebra_packet_detail,
-       debug_zebra_packet_detail_cmd,
-       "debug zebra packet (recv|send) detail",
+DEFUN (debug_zebra_packet,
+       debug_zebra_packet_cmd,
+       "debug zebra packet [<recv|send>] [detail]",
        DEBUG_STR
        "Zebra configuration\n"
        "Debug option set for zebra packet\n"
        "Debug option set for receive packet\n"
        "Debug option set for send packet\n"
-       "Debug option set detaied information\n")
+       "Debug option set for detailed info\n")
 {
+  int idx = 0;
   zebra_debug_packet = ZEBRA_DEBUG_PACKET;
-  if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
-    zebra_debug_packet |= ZEBRA_DEBUG_SEND;
-  if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
-    zebra_debug_packet |= ZEBRA_DEBUG_RECV;
-  zebra_debug_packet |= ZEBRA_DEBUG_DETAIL;
+
+  if (argv_find (argv, argc, "send", &idx))
+    SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
+  idx = 0;
+  if (argv_find (argv, argc, "recv", &idx))
+    SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
+  idx = 0;
+  if (argv_find (argv, argc, "detail", &idx))
+    SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL);
+
+  if (!(zebra_debug_packet & ZEBRA_DEBUG_SEND & ZEBRA_DEBUG_RECV))
+  {
+    SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
+    SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
+  }
   return CMD_SUCCESS;
 }
 
@@ -142,7 +159,26 @@ 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")
+{
+  int idx = 0;
+  if (argc == 4 || argv_find (argv, argc, "recv", &idx))
+    SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
+  if (argc == 4 || argv_find (argv, argc, "send", &idx))
+    SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
+
   return CMD_SUCCESS;
 }
 
@@ -157,15 +193,26 @@ DEFUN (debug_zebra_rib,
   return CMD_SUCCESS;
 }
 
-DEFUN (debug_zebra_rib_q,
-       debug_zebra_rib_q_cmd,
-       "debug zebra rib queue",
+DEFUN (debug_zebra_rib_detailed,
+       debug_zebra_rib_detailed_cmd,
+       "debug zebra rib detailed",
        DEBUG_STR
        "Zebra configuration\n"
        "Debug RIB events\n"
-       "Debug RIB queueing\n")
+       "Detailed debugs\n")
 {
-  SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_Q);
+  SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED);
+  return CMD_SUCCESS;
+}
+
+DEFUN (debug_zebra_fpm,
+       debug_zebra_fpm_cmd,
+       "debug zebra fpm",
+       DEBUG_STR
+       "Zebra configuration\n"
+       "Debug zebra FPM events\n")
+{
+  SET_FLAG (zebra_debug_fpm, ZEBRA_DEBUG_FPM);
   return CMD_SUCCESS;
 }
 
@@ -181,21 +228,33 @@ DEFUN (no_debug_zebra_events,
   return CMD_SUCCESS;
 }
 
-DEFUN (no_debug_zebra_packet,
-       no_debug_zebra_packet_cmd,
-       "no debug zebra packet",
+DEFUN (no_debug_zebra_nht,
+       no_debug_zebra_nht_cmd,
+       "no debug zebra nht",
        NO_STR
        DEBUG_STR
        "Zebra configuration\n"
-       "Debug option set for zebra packet\n")
+       "Debug option set for zebra next hop tracking\n")
 {
-  zebra_debug_packet = 0;
+  zebra_debug_nht = 0;
   return CMD_SUCCESS;
 }
 
-DEFUN (no_debug_zebra_packet_direct,
-       no_debug_zebra_packet_direct_cmd,
-       "no debug zebra packet (recv|send)",
+DEFUN (no_debug_zebra_mpls,
+       no_debug_zebra_mpls_cmd,
+       "no debug zebra mpls",
+       NO_STR
+       DEBUG_STR
+       "Zebra configuration\n"
+       "Debug option set for zebra MPLS LSPs\n")
+{
+  zebra_debug_mpls = 0;
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_zebra_packet,
+       no_debug_zebra_packet_cmd,
+       "no debug zebra packet [<recv|send>]",
        NO_STR
        DEBUG_STR
        "Zebra configuration\n"
@@ -203,10 +262,11 @@ DEFUN (no_debug_zebra_packet_direct,
        "Debug option set for receive packet\n"
        "Debug option set for send packet\n")
 {
-  if (strncmp ("send", argv[0], strlen (argv[0])) == 0)
-    zebra_debug_packet &= ~ZEBRA_DEBUG_SEND;
-  if (strncmp ("recv", argv[0], strlen (argv[0])) == 0)
-    zebra_debug_packet &= ~ZEBRA_DEBUG_RECV;
+  int idx = 0;
+  if (argc == 4 || argv_find (argv, argc, "send", &idx))
+    UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND);
+  if (argc == 4 || argv_find (argv, argc, "recv", &idx))
+    UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV);
   return CMD_SUCCESS;
 }
 
@@ -218,7 +278,27 @@ 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>]",
+       NO_STR
+       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")
+{
+  int idx = 0;
+  if (argc == 5 || argv_find (argv, argc, "recv", &idx))
+    UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV);
+  if (argc == 5 || argv_find (argv, argc, "send", &idx))
+    UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND);
+
   return CMD_SUCCESS;
 }
 
@@ -234,16 +314,28 @@ DEFUN (no_debug_zebra_rib,
   return CMD_SUCCESS;
 }
 
-DEFUN (no_debug_zebra_rib_q,
-       no_debug_zebra_rib_q_cmd,
-       "no debug zebra rib queue",
+DEFUN (no_debug_zebra_rib_detailed,
+       no_debug_zebra_rib_detailed_cmd,
+       "no debug zebra rib detailed",
        NO_STR
        DEBUG_STR
        "Zebra configuration\n"
        "Debug zebra RIB\n"
-       "Debug RIB queueing\n")
+       "Detailed debugs\n")
 {
-  UNSET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_Q);
+  UNSET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED);
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_zebra_fpm,
+       no_debug_zebra_fpm_cmd,
+       "no debug zebra fpm",
+       NO_STR
+       DEBUG_STR
+       "Zebra configuration\n"
+       "Debug zebra FPM events\n")
+{
+  zebra_debug_fpm = 0;
   return CMD_SUCCESS;
 }
 
@@ -292,14 +384,30 @@ config_write_debug (struct vty *vty)
       vty_out (vty, "debug zebra kernel%s", VTY_NEWLINE);
       write++;
     }
-  if (IS_ZEBRA_DEBUG_RIB)
+  /* Check here using flags as the 'macro' does an OR */
+  if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB))
     {
       vty_out (vty, "debug zebra rib%s", VTY_NEWLINE);
       write++;
     }
-  if (IS_ZEBRA_DEBUG_RIB_Q)
+  if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_DETAILED))
+    {
+      vty_out (vty, "debug zebra rib detailed%s", VTY_NEWLINE);
+      write++;
+    }
+  if (IS_ZEBRA_DEBUG_FPM)
+    {
+      vty_out (vty, "debug zebra fpm%s", VTY_NEWLINE);
+      write++;
+    }
+  if (IS_ZEBRA_DEBUG_NHT)
+    {
+      vty_out (vty, "debug zebra nht%s", VTY_NEWLINE);
+      write++;
+    }
+  if (IS_ZEBRA_DEBUG_MPLS)
     {
-      vty_out (vty, "debug zebra rib queue%s", VTY_NEWLINE);
+      vty_out (vty, "debug zebra mpls%s", VTY_NEWLINE);
       write++;
     }
   return write;
@@ -312,35 +420,48 @@ zebra_debug_init (void)
   zebra_debug_packet = 0;
   zebra_debug_kernel = 0;
   zebra_debug_rib = 0;
+  zebra_debug_fpm = 0;
+  zebra_debug_mpls = 0;
 
   install_node (&debug_node, config_write_debug);
 
   install_element (VIEW_NODE, &show_debugging_zebra_cmd);
 
-  install_element (ENABLE_NODE, &show_debugging_zebra_cmd);
   install_element (ENABLE_NODE, &debug_zebra_events_cmd);
+  install_element (ENABLE_NODE, &debug_zebra_nht_cmd);
+  install_element (ENABLE_NODE, &debug_zebra_mpls_cmd);
   install_element (ENABLE_NODE, &debug_zebra_packet_cmd);
-  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_q_cmd);
+  install_element (ENABLE_NODE, &debug_zebra_rib_detailed_cmd);
+  install_element (ENABLE_NODE, &debug_zebra_fpm_cmd);
   install_element (ENABLE_NODE, &no_debug_zebra_events_cmd);
+  install_element (ENABLE_NODE, &no_debug_zebra_nht_cmd);
+  install_element (ENABLE_NODE, &no_debug_zebra_mpls_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_q_cmd);
+  install_element (ENABLE_NODE, &no_debug_zebra_rib_detailed_cmd);
+  install_element (ENABLE_NODE, &no_debug_zebra_fpm_cmd);
 
   install_element (CONFIG_NODE, &debug_zebra_events_cmd);
+  install_element (CONFIG_NODE, &debug_zebra_nht_cmd);
+  install_element (CONFIG_NODE, &debug_zebra_mpls_cmd);
   install_element (CONFIG_NODE, &debug_zebra_packet_cmd);
-  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_q_cmd);
+  install_element (CONFIG_NODE, &debug_zebra_rib_detailed_cmd);
+  install_element (CONFIG_NODE, &debug_zebra_fpm_cmd);
   install_element (CONFIG_NODE, &no_debug_zebra_events_cmd);
+  install_element (CONFIG_NODE, &no_debug_zebra_nht_cmd);
+  install_element (CONFIG_NODE, &no_debug_zebra_mpls_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_q_cmd);
+  install_element (CONFIG_NODE, &no_debug_zebra_rib_detailed_cmd);
+  install_element (CONFIG_NODE, &no_debug_zebra_fpm_cmd);
 }