summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_vrf.h
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-06-02 16:27:02 +0200
committerIgor Ryzhov <iryzhov@nfware.com>2021-06-04 18:02:32 +0200
commit58929633fb1073e0010bca34688ff0c6be15909e (patch)
tree497ae0f26a0ec84ec2337f14fa30f08fadbf503e /zebra/zebra_vrf.h
parentMerge pull request #8779 from idryzhov/zebra-rst (diff)
downloadfrr-58929633fb1073e0010bca34688ff0c6be15909e.tar.xz
frr-58929633fb1073e0010bca34688ff0c6be15909e.zip
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>
Diffstat (limited to 'zebra/zebra_vrf.h')
-rw-r--r--zebra/zebra_vrf.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/zebra/zebra_vrf.h b/zebra/zebra_vrf.h
index b2b0fcfbb..57dd0c20a 100644
--- a/zebra/zebra_vrf.h
+++ b/zebra/zebra_vrf.h
@@ -192,8 +192,13 @@ struct zebra_vrf {
* special macro to allow us to get the correct zebra_vrf
*/
#define ZEBRA_DECLVAR_CONTEXT(A, B) \
- struct vrf *A = VTY_GET_CONTEXT(vrf); \
- struct zebra_vrf *B = (A) ? A->info : vrf_info_lookup(VRF_DEFAULT)
+ struct vrf *A; \
+ if (vty->node == CONFIG_NODE) \
+ A = vrf_lookup_by_id(VRF_DEFAULT); \
+ else \
+ A = VTY_GET_CONTEXT(vrf); \
+ VTY_CHECK_CONTEXT(A); \
+ struct zebra_vrf *B = A->info
static inline vrf_id_t zvrf_id(struct zebra_vrf *zvrf)
{