]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: fix crash when terminating inactive VRFs
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 2 Nov 2021 21:29:19 +0000 (00:29 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 3 Nov 2021 09:53:02 +0000 (12:53 +0300)
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>
lib/vrf.c

index a9a5a83794eada5043ca05b78a3441c91099b2d6..aaedb638001b37776b4876d3841a48455727e1cc 100644 (file)
--- 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. */