[zebra] Add 'debug zebra rib' commands

2006-07-27 Paul Jakma <paul.jakma@sun.com>

	* debug.{c,h}: Add 'debug zebra rib' and 'debug zebra rib queue'.
diff --git a/zebra/ChangeLog b/zebra/ChangeLog
index 2e9328d..a9bb0d0 100644
--- a/zebra/ChangeLog
+++ b/zebra/ChangeLog
@@ -9,6 +9,7 @@
 	* Makefile.am: Build testzebra using above.
 	* zebra_rib.c: Add a global for the workqueue hold time, useful
 	  for testing.
+	* debug.{c,h}: Add 'debug zebra rib' and 'debug zebra rib queue'.
 
 2006-07-27 Rumen Svobodnikov <rumen@telecoms.bg>
 
diff --git a/zebra/debug.c b/zebra/debug.c
index 8575a66..23c4de3 100644
--- a/zebra/debug.c
+++ b/zebra/debug.c
@@ -28,6 +28,7 @@
 unsigned long zebra_debug_event;
 unsigned long zebra_debug_packet;
 unsigned long zebra_debug_kernel;
+unsigned long zebra_debug_rib;
 
 DEFUN (show_debugging_zebra,
        show_debugging_zebra_cmd,
@@ -65,6 +66,11 @@
   if (IS_ZEBRA_DEBUG_KERNEL)
     vty_out (vty, "  Zebra kernel debugging is on%s", VTY_NEWLINE);
 
+  if (IS_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);
+
   return CMD_SUCCESS;
 }
 
@@ -140,6 +146,29 @@
   return CMD_SUCCESS;
 }
 
+DEFUN (debug_zebra_rib,
+       debug_zebra_rib_cmd,
+       "debug zebra rib",
+       DEBUG_STR
+       "Zebra configuration\n"
+       "Debug RIB events\n")
+{
+  SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB);
+  return CMD_SUCCESS;
+}
+
+DEFUN (debug_zebra_rib_q,
+       debug_zebra_rib_q_cmd,
+       "debug zebra rib queue",
+       DEBUG_STR
+       "Zebra configuration\n"
+       "Debug RIB events\n"
+       "Debug RIB queueing\n")
+{
+  SET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_Q);
+  return CMD_SUCCESS;
+}
+
 DEFUN (no_debug_zebra_events,
        no_debug_zebra_events_cmd,
        "no debug zebra events",
@@ -193,6 +222,31 @@
   return CMD_SUCCESS;
 }
 
+DEFUN (no_debug_zebra_rib,
+       no_debug_zebra_rib_cmd,
+       "no debug zebra rib",
+       NO_STR
+       DEBUG_STR
+       "Zebra configuration\n"
+       "Debug zebra RIB\n")
+{
+  zebra_debug_rib = 0;
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_zebra_rib_q,
+       no_debug_zebra_rib_q_cmd,
+       "no debug zebra rib queueu",
+       NO_STR
+       DEBUG_STR
+       "Zebra configuration\n"
+       "Debug zebra RIB\n"
+       "Debug RIB queueing\n")
+{
+  UNSET_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB_Q);
+  return CMD_SUCCESS;
+}
+
 /* Debug node. */
 struct cmd_node debug_node =
 {
@@ -238,6 +292,16 @@
       vty_out (vty, "debug zebra kernel%s", VTY_NEWLINE);
       write++;
     }
+  if (IS_ZEBRA_DEBUG_RIB)
+    {
+      vty_out (vty, "debug zebra rib%s", VTY_NEWLINE);
+      write++;
+    }
+  if (IS_ZEBRA_DEBUG_RIB_Q)
+    {
+      vty_out (vty, "debug zebra rib queue%s", VTY_NEWLINE);
+      write++;
+    }
   return write;
 }
 
@@ -246,6 +310,8 @@
 {
   zebra_debug_event = 0;
   zebra_debug_packet = 0;
+  zebra_debug_kernel = 0;
+  zebra_debug_rib = 0;
 
   install_node (&debug_node, config_write_debug);
 
@@ -257,16 +323,24 @@
   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_rib_cmd);
+  install_element (ENABLE_NODE, &debug_zebra_rib_q_cmd);
   install_element (ENABLE_NODE, &no_debug_zebra_events_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_rib_cmd);
+  install_element (ENABLE_NODE, &no_debug_zebra_rib_q_cmd);
 
   install_element (CONFIG_NODE, &debug_zebra_events_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_rib_cmd);
+  install_element (CONFIG_NODE, &debug_zebra_rib_q_cmd);
   install_element (CONFIG_NODE, &no_debug_zebra_events_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_rib_cmd);
+  install_element (CONFIG_NODE, &no_debug_zebra_rib_q_cmd);
 }
diff --git a/zebra/debug.h b/zebra/debug.h
index 96b7d8f..9d9412b 100644
--- a/zebra/debug.h
+++ b/zebra/debug.h
@@ -33,6 +33,9 @@
 
 #define ZEBRA_DEBUG_KERNEL  0x01
 
+#define ZEBRA_DEBUG_RIB     0x01
+#define ZEBRA_DEBUG_RIB_Q   0x02
+
 /* Debug related macro. */
 #define IS_ZEBRA_DEBUG_EVENT  (zebra_debug_event & ZEBRA_DEBUG_EVENT)
 
@@ -43,9 +46,13 @@
 
 #define IS_ZEBRA_DEBUG_KERNEL (zebra_debug_kernel & ZEBRA_DEBUG_KERNEL)
 
+#define IS_ZEBRA_DEBUG_RIB  (zebra_debug_rib & ZEBRA_DEBUG_RIB)
+#define IS_ZEBRA_DEBUG_RIB_Q  (zebra_debug_rib & ZEBRA_DEBUG_RIB_Q)
+
 extern unsigned long zebra_debug_event;
 extern unsigned long zebra_debug_packet;
 extern unsigned long zebra_debug_kernel;
+extern unsigned long zebra_debug_rib;
 
 extern void zebra_debug_init (void);