babeld: justify "running-config" meaning in CLI
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
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c
index 588fea7..404be7a 100644
--- a/babeld/babel_interface.c
+++ b/babeld/babel_interface.c
@@ -877,9 +877,9 @@
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 @@
{
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 @@
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 @@
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 *
diff --git a/babeld/babel_interface.h b/babeld/babel_interface.h
index 579dc04..1761e3d 100644
--- a/babeld/babel_interface.h
+++ b/babeld/babel_interface.h
@@ -41,6 +41,7 @@
#include <zebra.h>
#include "zclient.h"
+#include "vty.h"
#define CONFIG_DEFAULT 0
#define CONFIG_NO 1
@@ -147,6 +148,7 @@
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
diff --git a/babeld/babel_main.c b/babeld/babel_main.c
index 4cb2d83..3d83091 100644
--- a/babeld/babel_main.c
+++ b/babeld/babel_main.c
@@ -77,7 +77,7 @@
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 @@
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"
diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c
index ed6566f..75a1e6a 100644
--- a/babeld/babel_zebra.c
+++ b/babeld/babel_zebra.c
@@ -236,10 +236,11 @@
#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 @@
}
/* [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 @@
}
#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 @@
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
diff --git a/babeld/babel_zebra.h b/babeld/babel_zebra.h
index 1b623f0..99601aa 100644
--- a/babeld/babel_zebra.h
+++ b/babeld/babel_zebra.h
@@ -36,8 +36,15 @@
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
diff --git a/babeld/babeld.c b/babeld/babeld.c
index 07dd92a..9fea2e1 100644
--- a/babeld/babeld.c
+++ b/babeld/babeld.c
@@ -59,6 +59,7 @@
#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 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 @@
return 0;
}
-void
-show_babeld_configuration (struct vty *vty)
-{
- vty_out(vty, "babeld running process %s.%s",
- babel_routing_process ? "enable" : "disable", VTY_NEWLINE);
-}
diff --git a/babeld/babeld.conf.sample b/babeld/babeld.conf.sample
index e1585c1..4eced43 100644
--- a/babeld/babeld.conf.sample
+++ b/babeld/babeld.conf.sample
@@ -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
diff --git a/babeld/babeld.h b/babeld/babeld.h
index 29bc5e8..3c47323 100644
--- a/babeld/babeld.h
+++ b/babeld/babeld.h
@@ -132,7 +132,6 @@
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 */
diff --git a/doc/babeld.texi b/doc/babeld.texi
index b6eeced..8f67197 100644
--- a/doc/babeld.texi
+++ b/doc/babeld.texi
@@ -109,7 +109,7 @@
@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 @@
@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