]> git.puffer.fish 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>
Tue, 19 Feb 2019 12:42:25 +0000 (09:42 -0300)
commit3193c8b3d15920aad429d36670b535aebfae5248
treef497ccdfbc1cf348dafac9c84e882fee45c0e933
parentacf3cf454b0f016354060a6b0cf05d747af40da6
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