lib, zebra: Ensure that the ifp->node exists

On removal, ensure that the ifp->node is set to a null
pointer so that FRR does not use data after freed.
In addition ensure that the ifp->node exists before
attempting to free it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2023-05-28 10:13:16 -04:00
parent 06504bea79
commit 46d725f76b
2 changed files with 4 additions and 0 deletions

View File

@ -1028,6 +1028,7 @@ void if_terminate(struct vrf *vrf)
if (ifp->node) {
ifp->node->info = NULL;
route_unlock_node(ifp->node);
ifp->node = NULL;
}
if_delete(&ifp);
}

View File

@ -267,6 +267,9 @@ struct interface *if_link_per_ns(struct zebra_ns *ns, struct interface *ifp)
/* Delete a VRF. This is called in vrf_terminate(). */
void if_unlink_per_ns(struct interface *ifp)
{
if (!ifp->node)
return;
ifp->node->info = NULL;
route_unlock_node(ifp->node);
ifp->node = NULL;