zebra: fix stale pointer when netns is deleted

When the netns is deleted, we should always clear the vrf->ns_ctxt
pointer. Currently, it is not cleared when there are interfaces in the
netns at the time of deletion.

If the netns is re-created, zebra crashes because it tries to use the
stale pointer.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2021-11-02 23:54:43 +03:00
parent 0051effcb1
commit 9acc98c865
2 changed files with 2 additions and 3 deletions

View File

@ -256,10 +256,8 @@ void vrf_delete(struct vrf *vrf)
* the ID mapping. Interfaces assigned to this VRF should've been * the ID mapping. Interfaces assigned to this VRF should've been
* removed already as part of the VRF going down. * removed already as part of the VRF going down.
*/ */
if (vrf_is_user_cfged(vrf)) { if (vrf_is_user_cfged(vrf))
vrf->ns_ctxt = NULL;
return; return;
}
/* Do not delete the VRF if it has interfaces configured in it. */ /* Do not delete the VRF if it has interfaces configured in it. */
if (!RB_EMPTY(if_name_head, &vrf->ifaces_by_name)) if (!RB_EMPTY(if_name_head, &vrf->ifaces_by_name))

View File

@ -165,6 +165,7 @@ static int zebra_ns_delete(char *name)
/* the deletion order is the same /* the deletion order is the same
* as the one used when siging signal is received * as the one used when siging signal is received
*/ */
vrf->ns_ctxt = NULL;
vrf_delete(vrf); vrf_delete(vrf);
if (ns) if (ns)
ns_delete(ns); ns_delete(ns);