]> git.puffer.fish Git - mirror/frr.git/commitdiff
vrf: mark vrf as configured when entering vrf node
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 9 Feb 2021 18:38:45 +0000 (21:38 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 9 Feb 2021 18:38:45 +0000 (21:38 +0300)
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>
lib/vrf.c

index 1a9cd7e451b589f587b89735ce1f7e1821a463d7..7d0336314f0d6a8c07fe183d4ab200afe10c4942 100644 (file)
--- 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;