From 1e9d11834535c506af8ba426f5c9c580e071313a Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Sun, 8 Jul 2018 19:18:58 -0300 Subject: [PATCH] zebra: fix "no pseudowire IFNAME" on vtysh 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 --- zebra/zebra_pw.c | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c index bf76f7e86b..c6db1463f2 100644 --- a/zebra/zebra_pw.c +++ b/zebra/zebra_pw.c @@ -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); -- 2.39.5