]> git.proxmox.com Git - mirror_frr.git/commitdiff
babeld: justify "running-config" meaning in CLI
authorDenis Ovsienko <infrastation@yandex.ru>
Sat, 11 Feb 2012 17:06:16 +0000 (21:06 +0400)
committerPaul Jakma <paul@quagga.net>
Sun, 25 Mar 2012 16:06:54 +0000 (17:06 +0100)
The primary focus of this commit is to make "show running-config"
command display more current configuration, including some of the bits
previously seen in the output of "show babel running-config". Besides
that, the following commands were renamed for consistency with the
syntax of other components:

"debug *" to "debug babel *" (and moved to top level)
"show babel running-config" to "show babel parameters"

* babel_interface.c
  * show_babel_running_config(): rename to show_babel_parameters(),
    update syntax pattern, don't call show_babeld_configuration()
  * babel_if_init(): update respectively
  * babel_enable_if_config_write(): new VTY helper for static
    babel_enable_if
* babel_interface.h: add extern declaration
* babel_main.c: unset all debug options by default
  * show_babel_main_configuration(): remove debug options decoder
* babel_zebra.c
  * babel_debug(): rename to debug_babel(), update syntax pattern
  * no_babel_debug(): rename to no_debug_babel(), update syntax pattern
  * babelz_zebra_init(): update respectively
  * debug_babel_config_write() new VTY helper for static debug_type
* babel_zebra.h: add extern declaration
* babeld.c
  * babel_config_write(): add the code to output "debug babel *",
    "router babel", "redistribute *" and "network *" statements
  * show_babeld_configuration(): dismiss
* babeld.h: remove extern declaration
* babeld.texi: update for renamed commands
* babeld.conf.sample: idem, add debug statements block

babeld/babel_interface.c
babeld/babel_interface.h
babeld/babel_main.c
babeld/babel_zebra.c
babeld/babel_zebra.h
babeld/babeld.c
babeld/babeld.conf.sample
babeld/babeld.h
doc/babeld.texi

index 588fea708d536b7ae7650073f8b1b3e2cfe37263..404be7a253691d5c14fea9eee4092217710054b1 100644 (file)
@@ -877,9 +877,9 @@ DEFUN (show_babel_database,
     return CMD_SUCCESS;
 }
 
-DEFUN (show_babel_running_config,
-       show_babel_running_config_cmd,
-       "show babel running-config",
+DEFUN (show_babel_parameters,
+       show_babel_parameters_cmd,
+       "show babel parameters",
        SHOW_STR
        IP_STR
        "Babel information\n"
@@ -888,7 +888,6 @@ DEFUN (show_babel_running_config,
 {
     vty_out(vty, "    -- Babel running configuration --%s", VTY_NEWLINE);
     show_babel_main_configuration(vty);
-    show_babeld_configuration(vty);
     vty_out(vty, "    -- distribution lists --%s", VTY_NEWLINE);
     config_show_distribute(vty);
 
@@ -931,8 +930,8 @@ babel_if_init ()
     install_element(ENABLE_NODE, &show_babel_neighbour_cmd);
     install_element(VIEW_NODE, &show_babel_database_cmd);
     install_element(ENABLE_NODE, &show_babel_database_cmd);
-    install_element(VIEW_NODE, &show_babel_running_config_cmd);
-    install_element(ENABLE_NODE, &show_babel_running_config_cmd);
+    install_element(VIEW_NODE, &show_babel_parameters_cmd);
+    install_element(ENABLE_NODE, &show_babel_parameters_cmd);
 }
 
 /* hooks: functions called respectively when struct interface is
@@ -980,6 +979,22 @@ interface_config_write (struct vty *vty)
     return write;
 }
 
+/* Output a "network" statement line for each of the enabled interfaces. */
+int
+babel_enable_if_config_write (struct vty * vty)
+{
+    unsigned int i, lines = 0;
+    char *str;
+
+    for (i = 0; i < vector_active (babel_enable_if); i++)
+        if ((str = vector_slot (babel_enable_if, i)) != NULL)
+        {
+            vty_out (vty, " network %s%s", str, VTY_NEWLINE);
+            lines++;
+        }
+    return lines;
+}
+
 /* functions to allocate or free memory for a babel_interface_nfo, filling
  needed fields */
 static babel_interface_nfo *
index 579dc0430bb6e0e438a62ce706ef120e92b8ac20..1761e3d905b740e05b9bbe02166a4d67a519ed7e 100644 (file)
@@ -41,6 +41,7 @@ THE SOFTWARE.
 
 #include <zebra.h>
 #include "zclient.h"
+#include "vty.h"
 
 #define CONFIG_DEFAULT 0
 #define CONFIG_NO 1
@@ -147,6 +148,7 @@ unsigned update_jitter(babel_interface_nfo *babel_ifp, int urgent);
 int is_interface_ll_address(struct interface *ifp, const unsigned char *address);
 /* Send retraction to all, and reset all interfaces statistics. */
 void babel_interface_close_all(void);
+extern int babel_enable_if_config_write (struct vty *);
 
 
 #endif
index 4cb2d83e38a60e159da9ad365d8db1031e5f04f5..3d83091bf2bff075ee504c3a3ea6a1dac6026437 100644 (file)
@@ -77,7 +77,7 @@ struct thread_master *master;     /* quagga's threads handler */
 struct timeval babel_now;         /* current time             */
 
 unsigned char myid[8];            /* unique id (mac address of an interface) */
-int debug = BABEL_DEBUG_COMMON;
+int debug = 0;
 
 int default_wireless_hello_interval = -1;
 int default_wired_hello_interval = -1;
@@ -523,30 +523,6 @@ babel_save_state_file(void)
 void
 show_babel_main_configuration (struct vty *vty)
 {
-#ifdef NO_DEBUG
-    vty_out(vty, "No debug.%s", VTY_NEWLINE);
-#else
-    vty_out(vty, "Activated debug options:");
-    if (debug == BABEL_DEBUG_ALL) {
-        vty_out(vty, " all%s", VTY_NEWLINE);
-    } else {
-        vty_out(vty, "%s%s%s%s%s%s%s%s%s%s%s%s%s",
-                debug & BABEL_DEBUG_COMMON  ? VTY_NEWLINE    : "",
-                debug & BABEL_DEBUG_COMMON  ? "    common"   : "",
-                debug & BABEL_DEBUG_KERNEL  ? VTY_NEWLINE    : "",
-                debug & BABEL_DEBUG_KERNEL  ? "    kernel"   : "",
-                debug & BABEL_DEBUG_FILTER  ? VTY_NEWLINE    : "",
-                debug & BABEL_DEBUG_FILTER  ? "    filter"   : "",
-                debug & BABEL_DEBUG_TIMEOUT ? VTY_NEWLINE    : "",
-                debug & BABEL_DEBUG_TIMEOUT ? "    timeout"  : "",
-                debug & BABEL_DEBUG_IF      ? VTY_NEWLINE    : "",
-                debug & BABEL_DEBUG_IF      ? "    interface": "",
-                debug & BABEL_DEBUG_ROUTE   ? VTY_NEWLINE    : "",
-                debug & BABEL_DEBUG_ROUTE   ? "    route"    : "",
-                VTY_NEWLINE);
-    }
-#endif
-
     vty_out(vty,
             "pid file                = %s%s"
             "state file              = %s%s"
index ed6566f7ddb343ab5163fa521434a7be9f402956..75a1e6a849b252a2f083cda9ca1298723d615d4d 100644 (file)
@@ -236,10 +236,11 @@ DEFUN (no_babel_redistribute_type,
 
 #ifndef NO_DEBUG
 /* [Babel Command] */
-DEFUN (babel_debug,
-       babel_debug_cmd,
-       "debug (common|kernel|filter|timeout|interface|route|all)",
+DEFUN (debug_babel,
+       debug_babel_cmd,
+       "debug babel (common|kernel|filter|timeout|interface|route|all)",
        "Enable debug messages for specific or all part.\n"
+       "Babel information\n"
        "Common messages (default)\n"
        "Kernel messages\n"
        "Filter messages\n"
@@ -264,11 +265,12 @@ DEFUN (babel_debug,
 }
 
 /* [Babel Command] */
-DEFUN (no_babel_debug,
-       no_babel_debug_cmd,
-       "no debug (common|kernel|filter|timeout|interface|route|all)",
+DEFUN (no_debug_babel,
+       no_debug_babel_cmd,
+       "no debug babel (common|kernel|filter|timeout|interface|route|all)",
        NO_STR
        "Disable debug messages for specific or all part.\n"
+       "Babel information\n"
        "Common messages (default)\n"
        "Kernel messages\n"
        "Filter messages\n"
@@ -293,6 +295,39 @@ DEFUN (no_babel_debug,
 }
 #endif /* NO_DEBUG */
 
+/* Output "debug" statement lines, if necessary. */
+int
+debug_babel_config_write (struct vty * vty)
+{
+#ifdef NO_DEBUG
+    return 0;
+#else
+    int i, lines = 0;
+
+    if (debug == BABEL_DEBUG_ALL)
+    {
+        vty_out (vty, "debug babel all%s", VTY_NEWLINE);
+        lines++;
+    }
+    else
+        for (i = 0; debug_type[i].str != NULL; i++)
+            if
+            (
+                debug_type[i].type != BABEL_DEBUG_ALL
+                && CHECK_FLAG (debug, debug_type[i].type)
+            )
+            {
+                vty_out (vty, "debug babel %s%s", debug_type[i].str, VTY_NEWLINE);
+                lines++;
+            }
+    if (lines)
+    {
+        vty_out (vty, "!%s", VTY_NEWLINE);
+        lines++;
+    }
+    return lines;
+#endif /* NO_DEBUG */
+}
 
 void babelz_zebra_init(void)
 {
@@ -313,8 +348,10 @@ void babelz_zebra_init(void)
     install_node (&zebra_node, zebra_config_write);
     install_element(BABEL_NODE, &babel_redistribute_type_cmd);
     install_element(BABEL_NODE, &no_babel_redistribute_type_cmd);
-    install_element(BABEL_NODE, &babel_debug_cmd);
-    install_element(BABEL_NODE, &no_babel_debug_cmd);
+    install_element(ENABLE_NODE, &debug_babel_cmd);
+    install_element(ENABLE_NODE, &no_debug_babel_cmd);
+    install_element(CONFIG_NODE, &debug_babel_cmd);
+    install_element(CONFIG_NODE, &no_debug_babel_cmd);
 }
 
 static int
index 1b623f0147233f4f19375f6c9af716b93526d4a3..99601aa7ce07b61b0e8a283afd2f41139a0c6a70 100644 (file)
@@ -36,8 +36,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 */
 
+#ifndef BABEL_ZEBRA_H
+#define BABEL_ZEBRA_H
+
+#include "vty.h"
 
 extern struct zclient *zclient;
 
 void babelz_zebra_init(void);
 void babel_zebra_close_connexion(void);
+extern int debug_babel_config_write (struct vty *);
+
+#endif
index 07dd92a37edfb136f34f471612de6d791159b826..9fea2e1012511e61f25b2b104adb4dfdc7964b5b 100644 (file)
@@ -59,6 +59,7 @@ THE SOFTWARE.
 #include "message.h"
 #include "resend.h"
 #include "babel_filter.h"
+#include "babel_zebra.h"
 
 
 static int babel_init_routing_process(struct thread *thread);
@@ -92,7 +93,26 @@ static struct cmd_node cmd_babel_node =
 static int
 babel_config_write (struct vty *vty)
 {
-    return 0;
+    int lines = 0;
+    int i;
+
+    /* list enabled debug modes */
+    lines += debug_babel_config_write (vty);
+
+    if (!babel_routing_process)
+        return lines;
+    vty_out (vty, "router babel%s", VTY_NEWLINE);
+    /* list enabled interfaces */
+    lines = 1 + babel_enable_if_config_write (vty);
+    /* list redistributed protocols */
+    for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
+        if (i != zclient->redist_default && zclient->redist[i])
+        {
+            vty_out (vty, " redistribute %s%s", zebra_route_string (i), VTY_NEWLINE);
+            lines++;
+        }
+
+    return lines;
 }
 
 
@@ -701,9 +721,3 @@ redistribute_filter(const unsigned char *prefix, unsigned short plen,
     return 0;
 }
 
-void
-show_babeld_configuration (struct vty *vty)
-{
-    vty_out(vty, "babeld running process %s.%s",
-            babel_routing_process ? "enable" : "disable", VTY_NEWLINE);
-}
index e1585c1da8f85b7e696b8c8caf70a734cb2c2fcc..4eced43338f6f87b3134eb1d4cba1866c5b6ce49 100644 (file)
@@ -1,13 +1,21 @@
+debug babel common
+!debug babel kernel
+!debug babel filter
+!debug babel timeout
+!debug babel interface
+!debug babel route
+!debug babel all
+
 router babel
 ! network eth0
 ! redistribute kernel
 ! no redistribute static
 
 !interface eth0
-! wired
-! wireless
+! babel wired
+! babel wireless
 ! babel split-horizon
 ! no babel split-horizon
 
 ! log file /var/log/quagga/babeld.log
-log stdout
\ No newline at end of file
+log stdout
index 29bc5e8fd29b11af8881e6c29f3e787feaadb21c..3c4732309c0bde5a82401abfe92456b69a67f4a7 100644 (file)
@@ -132,7 +132,6 @@ extern int redistribute_filter(const unsigned char *prefix, unsigned short plen,
                                unsigned int ifindex, int proto);
 extern int resize_receive_buffer(int size);
 extern void schedule_neighbours_check(int msecs, int override);
-extern void show_babeld_configuration (struct vty *vty);
 
 
 #endif /* BABEL_BABELD_H */
index b6eeced879aa571477debfae653896853538799d..8f671974b92571d62b826075ef9c633d2048e01d 100644 (file)
@@ -109,7 +109,7 @@ Specify which kind of routes should be redistributed into Babel.
 @deffn {Command} {show babel database} {}
 @deffnx {Command} {show babel interface} {}
 @deffnx {Command} {show babel neighbour} {}
-@deffnx {Command} {show babel running-config} {}
+@deffnx {Command} {show babel parameters} {}
 These commands dump various parts of @command{babeld}'s internal
 state.  They are mostly useful for troubleshooting.
 @end deffn
@@ -117,8 +117,8 @@ state.  They are mostly useful for troubleshooting.
 @node Babel debugging commands,  , Show Babel information, Babel
 @section Babel debugging commands
 
-@deffn {Babel Command} {debug @var{kind}} {}
-@deffnx {Babel Command} {no debug @var{kind}} {}
+@deffn {Babel Command} {debug babel @var{kind}} {}
+@deffnx {Babel Command} {no debug babel @var{kind}} {}
 Enable or disable debugging messages of a given kind.  @var{kind} can
 be one of @samp{common}, @samp{kernel}, @samp{filter}, @samp{timeout},
 @samp{interface}, @samp{route} or @samp{all}.  Note that if you have