]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib, vtysh: fix inconsistent interface commands in vtysh
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 9 Jul 2018 00:39:37 +0000 (21:39 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 13 Aug 2018 21:59:31 +0000 (18:59 -0300)
The definition of the interface commands in vtysh.c were outdated.
Currently, all daemons that call if_cmd_init() will have the "no interface
IFNAME" command and the "[no] description" commands as well, so there's
no need to define exceptions for these commands anymore.

To fix this, make extract.pl parse the if.c file so that vtysh can get the
interface commands from there automatically. Only the "interface IFNAME
[vrf NAME]" must be kept in vtysh.c because it changes the vty node and
thus needs special treatment.

Finally, make pimd and pbrd display interface descriptions on "sh run"
when they are configured.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
lib/if.c
pbrd/pbr_vty.c
pimd/pim_vty.c
vtysh/Makefile.am
vtysh/extract.pl.in
vtysh/vtysh.c

index e31ccd8563f2744a30ee695e012e33113286fc35..dd7d210381eafdee7d507a91df2b2fa8e790f45b 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -626,7 +626,7 @@ static struct interface *if_sunwzebra_get(char *name, vrf_id_t vrf_id)
 }
 #endif /* SUNOS_5 */
 
-DEFUN (interface,
+DEFUN_NOSH (interface,
        interface_cmd,
        "interface IFNAME [vrf NAME]",
        "Select an interface to configure\n"
@@ -669,13 +669,13 @@ DEFUN (interface,
        return CMD_SUCCESS;
 }
 
-DEFUN_NOSH (no_interface,
-           no_interface_cmd,
-           "no interface IFNAME [vrf NAME]",
-           NO_STR
-           "Delete a pseudo interface's configuration\n"
-           "Interface's name\n"
-           VRF_CMD_HELP_STR)
+DEFUN (no_interface,
+       no_interface_cmd,
+       "no interface IFNAME [vrf NAME]",
+       NO_STR
+       "Delete a pseudo interface's configuration\n"
+       "Interface's name\n"
+       VRF_CMD_HELP_STR)
 {
        int idx_vrf = 4;
        const char *ifname = argv[2]->arg;
index 44e14c5477dff78061faed8f16f4abdecbb7c6f3..a4b87f99d9d0e2b8eecb6151f52a8ac5fafd3ed0 100644 (file)
@@ -580,6 +580,9 @@ static int pbr_interface_config_write(struct vty *vty)
                                vty_frame(vty, "interface %s vrf %s\n",
                                          ifp->name, vrf->name);
 
+                       if (ifp->desc)
+                               vty_out(vty, " description %s\n", ifp->desc);
+
                        pbr_map_write_interfaces(vty, ifp);
 
                        vty_endframe(vty, "!\n");
index f4d833c26f1237f9c0a6f296952379d99409c2a6..88be195beec7fba8afa4cb963cea1b13036afd6d 100644 (file)
@@ -258,6 +258,11 @@ int pim_interface_config_write(struct vty *vty)
                                          ifp->name, vrf->name);
                        ++writes;
 
+                       if (ifp->desc) {
+                               vty_out(vty, " description %s\n", ifp->desc);
+                               ++writes;
+                       }
+
                        if (ifp->info) {
                                struct pim_interface *pim_ifp = ifp->info;
 
index 6d0b4a8fdb85719d1ac61fc6adc0e8e01162e5cf..9f81b42e32820bf3a08fd198f18440afe6d82c3b 100644 (file)
@@ -154,7 +154,7 @@ vtysh_cmd_FILES = $(vtysh_scan) \
                  $(top_srcdir)/lib/keychain.c $(top_srcdir)/lib/routemap.c \
                  $(top_srcdir)/lib/filter.c $(top_srcdir)/lib/plist.c \
                  $(top_srcdir)/lib/distribute.c $(top_srcdir)/lib/if_rmap.c \
-                 $(top_srcdir)/lib/vrf.c \
+                 $(top_srcdir)/lib/vrf.c $(top_srcdir)/lib/if.c \
                  $(top_srcdir)/lib/vty.c $(top_srcdir)/zebra/debug.c \
                  $(top_srcdir)/lib/logicalrouter.c \
                  $(top_srcdir)/lib/nexthop_group.c \
index b93314c9670419cb6263db2b6ee873ebb108881f..92b5686a945a1a26f2ca6a0207b5142784647aed 100755 (executable)
@@ -87,6 +87,9 @@ foreach (@ARGV) {
         elsif ($file =~ /lib\/vrf\.c$/) {
             $protocol = "VTYSH_VRF";
         }
+        elsif ($file =~ /lib\/if\.c$/) {
+            $protocol = "VTYSH_INTERFACE";
+        }
         elsif ($file =~ /lib\/logicalrouter\.c$/) {
             $protocol = "VTYSH_ALL";
         }
index 4e24bef9292ea3b917913356a7ab8818ece2af8a..229337d82f5cbd30ba0d1fa16e5a3a26981ddec9 100644 (file)
@@ -2018,18 +2018,6 @@ DEFUNSH(VTYSH_ZEBRA, vtysh_pseudowire, vtysh_pseudowire_cmd,
        return CMD_SUCCESS;
 }
 
-/* TODO Implement "no interface command in isisd. */
-DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D
-             | VTYSH_EIGRPD,
-      vtysh_no_interface_cmd, "no interface IFNAME", NO_STR
-      "Delete a pseudo interface's configuration\n"
-      "Interface's name\n")
-
-DEFSH(VTYSH_ZEBRA, vtysh_no_interface_vrf_cmd, "no interface IFNAME vrf NAME",
-      NO_STR
-      "Delete a pseudo interface's configuration\n"
-      "Interface's name\n" VRF_CMD_HELP_STR)
-
 DEFUNSH(VTYSH_ZEBRA, vtysh_logicalrouter, vtysh_logicalrouter_cmd,
        "logical-router (1-65535) ns NAME",
        "Enable a logical-router\n"
@@ -2119,19 +2107,6 @@ DEFUNSH(VTYSH_VRF, vtysh_quit_nexthop_group, vtysh_quit_nexthop_group_cmd,
        return vtysh_exit_nexthop_group(self, vty, argc, argv);
 }
 
-/*
- * TODO Implement interface description commands in ripngd, ospf6d
- * and isisd.
- */
-DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_OSPFD | VTYSH_EIGRPD,
-      vtysh_interface_desc_cmd, "description LINE...",
-      "Interface specific description\n"
-      "Characters describing this interface\n")
-
-DEFSH(VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_OSPFD | VTYSH_EIGRPD,
-      vtysh_no_interface_desc_cmd, "no description",
-      NO_STR "Interface specific description\n")
-
 DEFUNSH(VTYSH_INTERFACE, vtysh_exit_interface, vtysh_exit_interface_cmd, "exit",
        "Exit current mode and down to previous mode\n")
 {
@@ -3584,8 +3559,6 @@ void vtysh_init_vty(void)
        install_element(PBRMAP_NODE, &vtysh_end_all_cmd);
        install_element(VTY_NODE, &vtysh_end_all_cmd);
 
-       install_element(INTERFACE_NODE, &vtysh_interface_desc_cmd);
-       install_element(INTERFACE_NODE, &vtysh_no_interface_desc_cmd);
        install_element(INTERFACE_NODE, &vtysh_end_all_cmd);
        install_element(INTERFACE_NODE, &vtysh_exit_interface_cmd);
        install_element(LINK_PARAMS_NODE, &exit_link_params_cmd);
@@ -3689,8 +3662,6 @@ void vtysh_init_vty(void)
        install_element(KEYCHAIN_NODE, &key_chain_cmd);
        install_element(KEYCHAIN_KEY_NODE, &key_chain_cmd);
        install_element(CONFIG_NODE, &vtysh_interface_cmd);
-       install_element(CONFIG_NODE, &vtysh_no_interface_cmd);
-       install_element(CONFIG_NODE, &vtysh_no_interface_vrf_cmd);
        install_element(CONFIG_NODE, &vtysh_pseudowire_cmd);
        install_element(INTERFACE_NODE, &vtysh_link_params_cmd);
        install_element(ENABLE_NODE, &vtysh_show_running_config_cmd);