summaryrefslogtreecommitdiff
path: root/lib/vrf.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-11-03 00:29:19 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-11-03 12:53:02 +0300
commitd2dbaf3b5e57051b56efd1a38d69f552a5d56c41 (patch)
tree73661b5739b25536dc012ded49f5b33e7cff6712 /lib/vrf.c
parent9acc98c865bfc3aae2748ac5e922918dd70885d8 (diff)
lib: fix crash when terminating inactive VRFs
If the VRF is not enabled, if_terminate deletes the VRF after the last interface is removed from it. Therefore daemons crash on the subsequent call to vrf_delete. We should call vrf_delete only for enabled VRFs. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/vrf.c')
-rw-r--r--lib/vrf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/vrf.c b/lib/vrf.c
index a9a5a83794..aaedb63800 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -539,10 +539,13 @@ 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);
- vrf_delete(vrf);
+ if (enabled)
+ vrf_delete(vrf);
}
/* Terminate VRF module. */