summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-02-09 21:38:45 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-02-16 21:05:15 +0300
commit2bdc59ca21da2d67b77ec70a2fadffbca60690cd (patch)
tree5f46c0704d4677814ca32a2a7d0e34f71d46ee74
parentb9611f65a71adc0b8fa14a5a4d1a8f44e04dcd85 (diff)
vrf: mark vrf as configured when entering vrf node
The VRF must be marked as configured when user enters "vrf NAME" command. Otherwise, the following problem occurs: `ip link add red type vrf table 1` VRF structure is allocated. `vtysh -c "conf t" -c "vrf red"` `lib_vrf_create` is called, and pointer to the VRF structure is stored to the nb_config_entry. `ip link del red` VRF structure is freed (because it is not marked as configured), but the pointer is still stored in the nb_config_entry. `vtysh -c "conf t" -c "no vrf red"` Nothing happens, because VRF structure doesn't exist. It means that `lib_vrf_destroy` is not called, and nb_config_entry still exists in the running config with incorrect pointer. `ip link add red type vrf table 1` New VRF structure is allocated. `vtysh -c "conf t" -c "vrf red"` `lib_vrf_create` is NOT called, because the nb_config_entry for that VRF name still exists in the running config. After that all NB commands for this VRF will use incorrect pointer to the freed VRF structure. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
-rw-r--r--lib/vrf.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/vrf.c b/lib/vrf.c
index 1a9cd7e451..7d0336314f 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -1064,6 +1064,7 @@ static int lib_vrf_create(struct nb_cb_create_args *args)
vrfp = vrf_get(VRF_UNKNOWN, vrfname);
+ SET_FLAG(vrfp->status, VRF_CONFIGURED);
nb_running_set_entry(args->dnode, vrfp);
return NB_OK;