]> git.puffer.fish Git - mirror/frr.git/commit
zebra: fix config after exit from vrf
authorIgor Ryzhov <iryzhov@nfware.com>
Wed, 2 Jun 2021 14:27:02 +0000 (17:27 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 8 Jun 2021 17:51:25 +0000 (20:51 +0300)
commit8ab721babbdd3cfb673be36c759bc2add61baa65
tree3e227c314077239929371fb954ba1cac1ac2cee1
parent55d9ae78dbc2403974227b78dbade01cba37324a
zebra: fix config after exit from vrf

When the VRF node is exited using "exit" or "quit", there's still a VRF
pointer stored in the vty context. If you try to configure some router
related command, it will be applied to the previous VRF instead of the
default VRF. For example:

```
(config)# vrf test
(config-vrf)# ip router-id 1.1.1.1
(config-vrf)# do show run
...
!
vrf test
 ip router-id 1.1.1.1
 exit-vrf
!
...
(config-vrf)# exit
(config)# ip router-id 2.2.2.2
(config)# do show run
...
!
vrf test
 ip router-id 2.2.2.2
 exit-vrf
!
...
```

`vrf-exit` works correctly, because it stores a pointer to the default
VRF into the vty context (but weirdly keeping the VRF_NODE instead of
changing it to CONFIG_NODE).

Instead of relying on the behavior of exit function, always use the
default VRF when in CONFIG_NODE.

Another problem is missing `VTY_CHECK_CONTEXT`. If someone deletes the
VRF in which node the user enters the command, then zebra applies the
command to the default VRF instead of throwing an error.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
lib/vrf.c
zebra/zebra_vrf.h