]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: fix "no pseudowire IFNAME" on vtysh
authorRenato Westphal <renato@opensourcerouting.org>
Sun, 8 Jul 2018 22:18:58 +0000 (19:18 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 13 Aug 2018 21:59:31 +0000 (18:59 -0300)
We must hide only "pseudowire IFNAME" from vtysh, the "no" form of the
command should be made available to the extract.pl script. Split the
command into two to fix this problem.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
zebra/zebra_pw.c

index bf76f7e86b7d32758764e8110fc17e2e230f79ad..c6db1463f2e71dea995f0d5a2fb62ec8225d5e46 100644 (file)
@@ -308,15 +308,14 @@ void zebra_pw_exit(struct zebra_vrf *zvrf)
 
 DEFUN_NOSH (pseudowire_if,
            pseudowire_if_cmd,
-           "[no] pseudowire IFNAME",
-           NO_STR
+           "pseudowire IFNAME",
            "Static pseudowire configuration\n"
            "Pseudowire name\n")
 {
        struct zebra_vrf *zvrf;
        struct zebra_pw *pw;
-       int idx = 0;
        const char *ifname;
+       int idx = 0;
 
        zvrf = vrf_info_lookup(VRF_DEFAULT);
        if (!zvrf)
@@ -324,19 +323,13 @@ DEFUN_NOSH (pseudowire_if,
 
        argv_find(argv, argc, "IFNAME", &idx);
        ifname = argv[idx]->arg;
+
        pw = zebra_pw_find(zvrf, ifname);
        if (pw && pw->protocol != ZEBRA_ROUTE_STATIC) {
                vty_out(vty, "%% Pseudowire is not static\n");
                return CMD_WARNING;
        }
 
-       if (argv_find(argv, argc, "no", &idx)) {
-               if (!pw)
-                       return CMD_SUCCESS;
-               zebra_pw_del(zvrf, pw);
-               return CMD_SUCCESS;
-       }
-
        if (!pw)
                pw = zebra_pw_add(zvrf, ifname, ZEBRA_ROUTE_STATIC, NULL);
        VTY_PUSH_CONTEXT(PW_NODE, pw);
@@ -344,6 +337,37 @@ DEFUN_NOSH (pseudowire_if,
        return CMD_SUCCESS;
 }
 
+DEFUN (no_pseudowire_if,
+       no_pseudowire_if_cmd,
+       "no pseudowire IFNAME",
+       NO_STR
+       "Static pseudowire configuration\n"
+       "Pseudowire name\n")
+{
+       struct zebra_vrf *zvrf;
+       struct zebra_pw *pw;
+       const char *ifname;
+       int idx = 0;
+
+       zvrf = vrf_info_lookup(VRF_DEFAULT);
+       if (!zvrf)
+               return CMD_WARNING;
+
+       argv_find(argv, argc, "IFNAME", &idx);
+       ifname = argv[idx]->arg;
+
+       pw = zebra_pw_find(zvrf, ifname);
+       if (pw) {
+               if (pw->protocol != ZEBRA_ROUTE_STATIC) {
+                       vty_out(vty, "%% Pseudowire is not static\n");
+                       return CMD_WARNING;
+               }
+               zebra_pw_del(zvrf, pw);
+       }
+
+       return CMD_SUCCESS;
+}
+
 DEFUN (pseudowire_labels,
        pseudowire_labels_cmd,
        "[no] mpls label local (16-1048575) remote (16-1048575)",
@@ -531,6 +555,7 @@ void zebra_pw_vty_init(void)
        install_default(PW_NODE);
 
        install_element(CONFIG_NODE, &pseudowire_if_cmd);
+       install_element(CONFIG_NODE, &no_pseudowire_if_cmd);
        install_element(PW_NODE, &pseudowire_labels_cmd);
        install_element(PW_NODE, &pseudowire_neighbor_cmd);
        install_element(PW_NODE, &pseudowire_control_word_cmd);