]> git.puffer.fish Git - matthieu/frr.git/commitdiff
vtysh: fix node walkup
authorIgor Ryzhov <iryzhov@nfware.com>
Fri, 1 Oct 2021 14:25:57 +0000 (17:25 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Fri, 1 Oct 2021 14:25:57 +0000 (17:25 +0300)
The current code executes either "exit" or "end" once - so vtysh switches
either to the parent node or straight to the config node. But sometimes,
we need to exit to the grandparent node, which is not the config node.

Another issue is that some nodes are completely missing in this long
checklist, for example, BFD peer and profile nodes.

Instead of doing all this special checking, we should just always exit
the exact number of times we need - it is stored in "tried" variable.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
vtysh/vtysh.c

index cd1ad28a5b6439d8294cd9be9006cba85f285f04..3559b8ba7e50ca0dd85edb8d63e3c33c00502674 100644 (file)
@@ -499,51 +499,8 @@ static int vtysh_execute_func(const char *line, int pager)
         */
        if (ret == CMD_SUCCESS || ret == CMD_SUCCESS_DAEMON
            || ret == CMD_WARNING) {
-               if ((saved_node == BGP_VPNV4_NODE
-                    || saved_node == BGP_VPNV6_NODE
-                    || saved_node == BGP_IPV4_NODE
-                    || saved_node == BGP_IPV6_NODE
-                    || saved_node == BGP_FLOWSPECV4_NODE
-                    || saved_node == BGP_FLOWSPECV6_NODE
-                    || saved_node == BGP_IPV4M_NODE
-                    || saved_node == BGP_IPV4L_NODE
-                    || saved_node == BGP_IPV6L_NODE
-                    || saved_node == BGP_IPV6M_NODE
-                    || saved_node == BGP_EVPN_NODE
-                    || saved_node == LDP_IPV4_NODE
-                    || saved_node == LDP_IPV6_NODE)
-                   && (tried == 1)) {
-                       vtysh_execute("exit-address-family");
-               } else if ((saved_node == BGP_EVPN_VNI_NODE) && (tried == 1)) {
-                       vtysh_execute("exit-vni");
-               } else if (saved_node == BGP_VRF_POLICY_NODE && (tried == 1)) {
-                       vtysh_execute("exit-vrf-policy");
-               } else if ((saved_node == BGP_VNC_DEFAULTS_NODE
-                           || saved_node == BGP_VNC_NVE_GROUP_NODE
-                           || saved_node == BGP_VNC_L2_GROUP_NODE)
-                          && (tried == 1)) {
-                       vtysh_execute("exit-vnc");
-               } else if (saved_node == VRF_NODE && (tried == 1)) {
-                       vtysh_execute("exit-vrf");
-               } else if ((saved_node == KEYCHAIN_KEY_NODE
-                           || saved_node == LDP_PSEUDOWIRE_NODE
-                           || saved_node == LDP_IPV4_IFACE_NODE
-                           || saved_node == LDP_IPV6_IFACE_NODE)
-                          && (tried == 1)) {
+               while (tried-- > 0)
                        vtysh_execute("exit");
-               } else if ((saved_node == SR_SEGMENT_LIST_NODE
-                           || saved_node == SR_POLICY_NODE
-                           || saved_node == SR_CANDIDATE_DYN_NODE
-                           || saved_node == PCEP_NODE
-                           || saved_node == PCEP_PCE_CONFIG_NODE
-                           || saved_node == PCEP_PCE_NODE
-                           || saved_node == PCEP_PCC_NODE)
-                          && (tried > 0)) {
-                       vtysh_execute("exit");
-               } else if (tried) {
-                       vtysh_execute("end");
-                       vtysh_execute("configure");
-               }
        }
        /*
         * If command didn't succeed in any node, continue with return value