]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: reset the vty xpath index when entering the config mode
authorRenato Westphal <renato@opensourcerouting.org>
Sat, 19 Jan 2019 00:58:58 +0000 (22:58 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Sat, 19 Jan 2019 17:56:54 +0000 (15:56 -0200)
The CLI code uses the vty->xpath[] array and the vty->xpath_index
variables to keep track of where the user is in the configuration
hierarchy. As such, we were resetting vty->xpath_index to zero
whenever the user exited from the configuration mode in order to
keep the index valid. We weren't doing this in the vty_stop_input()
function however, which is called when the user types ^C in the
terminal. This was leading to bugs like this:

  zebra> en
  zebra# conf t
  zebra(config)# interface eth0
  zebra(config-if)# ^C
  zebra# conf t
  zebra(config)# interface eth0
  % Configuration failed.

  Schema node not found.
  YANG path: /frr-interface:lib/interface[name='eth0'][vrf='default']/frr-interface:lib

To fix this, do something more clever: instead of resetting the
XPath index whenever the user exits from the configuration mode,
do that when the user enters in the configuration mode. This way
the XPath index needs to be reset in a single place only, not to
mention it's a more robust solution.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
lib/command.c
lib/vty.c

index d1dafa3a1a9ca0a305ca7c009e191b25db3c8268..7d20bae62a37a85b9036d1a1e09dc9dcdf5f1904 100644 (file)
@@ -1594,8 +1594,6 @@ DEFUN (config_end,
                break;
        }
 
-       vty->xpath_index = 0;
-
        return CMD_SUCCESS;
 }
 
index 085cbac742a004082a1594870d828994c671e815..f93301170a6954624c9942d12d7697dbb035bc55 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -828,8 +828,6 @@ static void vty_end_config(struct vty *vty)
                break;
        }
 
-       vty->xpath_index = 0;
-
        vty_prompt(vty);
        vty->cp = 0;
 }
@@ -2696,6 +2694,7 @@ int vty_config_enter(struct vty *vty, bool private_config, bool exclusive)
        vty->node = CONFIG_NODE;
        vty->config = true;
        vty->private_config = private_config;
+       vty->xpath_index = 0;
 
        if (private_config) {
                vty->candidate_config = nb_config_dup(running_config);