diff options
author | Igor Ryzhov <iryzhov@nfware.com> | 2021-11-05 23:22:07 +0100 |
---|---|---|
committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-11-11 12:57:59 +0100 |
commit | ce27a13e90885de3a830e4ec78afc9efeadae42e (patch) | |
tree | b1417330f259a03ee93bea098330e71d5a8c234b /lib/vrf.c | |
parent | Merge pull request #10029 from anlancs/doc-bgp-title (diff) | |
download | frr-ce27a13e90885de3a830e4ec78afc9efeadae42e.tar.xz frr-ce27a13e90885de3a830e4ec78afc9efeadae42e.zip |
lib: fix vrf deletion when the last interface is deleted
Currently, we automatically delete an inactive VRF when its last
interface is deleted. This code introduces a couple of crashes because
of the following problems:
- vrf_delete is called before calling if_del hook, so daemons may try to
dereference an ifp->vrf pointer which is freed
- in if_terminate, we continue to use the VRF in the loop condition
after the last interface is deleted
This check is needed only when the interface is deleted by the user,
because if the interface is deleted by the system, VRF must still exist
in the system. Move the check to appropriate places to fix crashes.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/vrf.c')
-rw-r--r-- | lib/vrf.c | 5 |
1 files changed, 1 insertions, 4 deletions
@@ -539,13 +539,10 @@ void vrf_init(int (*create)(struct vrf *), int (*enable)(struct vrf *), static void vrf_terminate_single(struct vrf *vrf) { - int enabled = vrf_is_enabled(vrf); - /* Clear configured flag and invoke delete. */ UNSET_FLAG(vrf->status, VRF_CONFIGURED); if_terminate(vrf); - if (enabled) - vrf_delete(vrf); + vrf_delete(vrf); } /* Terminate VRF module. */ |