]> git.proxmox.com Git - mirror_frr.git/commit
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)
commit41e195d47732fab800ce4f8bfd0b88561d2fab74
treebf6dff97d28d620b2976b091e759c609cbeb4a85
parent70fc94ca1d6063b64449b0971678521c021ac916
lib: reset the vty xpath index when entering the config mode

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