]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Don't print empty sections as they clutter the output of show-running
authorDinesh G Dutt <ddutt@cumulusnetworks.com>
Mon, 18 Jul 2016 06:08:05 +0000 (23:08 -0700)
committerDinesh G Dutt <ddutt@cumulusnetworks.com>
Tue, 19 Jul 2016 03:43:48 +0000 (20:43 -0700)
Ticket: CM-11808
Reviewed By: CCR-4971
Testing Done: Usual stuff including doing show running with multiple daemons

Interface and VRF are both sections of the config that could possibly be
empty. This unnecessarily clutters the output of show running. This patch
fixes that by not displaying empty sections of interface, and vrf.
Routemaps have a genuine empty stanza and so we cannot add routemap to this
list. Unfortunately this means a "show running-config ospfd" may have empty
route-maps if the route-maps all correspond to BGP, for example. This
is not a concern for the entire "show running-config".

The trick in fixing this is on the vtysh side rather than on the client side.
The reason for this is that its quite tricky given the number of options to
ensure that a daemon never printed a section header unless there was something
to print. On the vtysh side, however, its easy to check if a section is
empty and not print it.

vtysh/vtysh.c
vtysh/vtysh_config.c

index ecb6c5c6ac7c75a352099e513ab06ea81eaa5f98..abd5d04f44d77aebfa06144756f8c7f94beda0be 100644 (file)
@@ -2097,7 +2097,8 @@ DEFUN (vtysh_write_terminal,
   vty_out (vty, "!%s", VTY_NEWLINE);
 
   for (i = 0; i < array_size(vtysh_client); i++)
-    vtysh_client_config (&vtysh_client[i], line);
+    if ((argc < 1 ) || (begins_with(vtysh_client[i].name, argv[0])))
+      vtysh_client_config (&vtysh_client[i], line);
 
   /* Integrate vtysh specific configuration. */
   vtysh_config_write ();
@@ -2317,7 +2318,7 @@ ALIAS (vtysh_write_terminal,
        SHOW_STR
        "Current operating configuration\n")
 
-ALIAS (vtysh_write_terminal_daemon,
+ALIAS (vtysh_write_terminal,
        vtysh_show_running_config_daemon_cmd,
        "show running-config (zebra|ripd|ripngd|ospfd|ospf6d|bgpd|isisd|pimd)",
        SHOW_STR
index eeb635419c8f7896e523b26118a5dffb36332ca0..e678fc1a8b7ae1b4cf68c678f0369b1cde828645 100644 (file)
@@ -318,7 +318,14 @@ vtysh_config_dump (FILE *fp)
     if ((master = vector_slot (configvec, i)) != NULL)
       {
        for (ALL_LIST_ELEMENTS (master, node, nnode, config))
-         {
+    {
+      /* Don't print empty sections for interface/vrf. Route maps on the
+       * other hand could have a legitimate empty section at the end.
+       */
+      if ((config->index == INTERFACE_NODE || (config->index == VRF_NODE))
+          && list_isempty (config->line))
+        continue;
+
            fprintf (fp, "%s\n", config->name);
            fflush (fp);