Merge pull request #16936 from FRRouting/mergify/bp/stable/10.1/pr-16579

bgpd: Avoid use-after-free when doing `no router bgp` with auto created instances (backport #16579)
This commit is contained in:
Donald Sharp 2024-09-26 15:56:19 -04:00 committed by GitHub
commit cf5b42e3fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1695,15 +1695,18 @@ DEFUN (no_router_bgp,
/* Cannot delete default instance if vrf instances exist */ /* Cannot delete default instance if vrf instances exist */
if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) {
struct listnode *node; struct listnode *node, *nnode;
struct bgp *tmp_bgp; struct bgp *tmp_bgp;
for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, tmp_bgp)) {
if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF)
continue; continue;
if (CHECK_FLAG(tmp_bgp->vrf_flags, BGP_VRF_AUTO)) if (CHECK_FLAG(tmp_bgp->vrf_flags,
BGP_VRF_AUTO)) {
bgp_delete(tmp_bgp); bgp_delete(tmp_bgp);
continue;
}
if (CHECK_FLAG( if (CHECK_FLAG(
tmp_bgp->af_flags[AFI_IP] tmp_bgp->af_flags[AFI_IP]