summaryrefslogtreecommitdiff
path: root/zebra
diff options
context:
space:
mode:
authorMark Stapp <mjs.ietf@gmail.com>2025-03-12 08:09:29 -0400
committerGitHub <noreply@github.com>2025-03-12 08:09:29 -0400
commit27953dd141d2d3185ad20d94ab8677316b726c35 (patch)
tree041d824106d860eecdb0af50d7d30c7b5d679ba8 /zebra
parentd0cb3ad7cb3ce5ac25c159e43f2cb1ccde2e2e14 (diff)
parent3060afc84d2c8a6fa79d588000331e94c36921ae (diff)
Merge pull request #18336 from routingrocks/rvaratharaj/bugfixmar
zebra: Fix neigh delete causing heap-use-after-free error
Diffstat (limited to 'zebra')
-rw-r--r--zebra/zebra_neigh.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/zebra/zebra_neigh.c b/zebra/zebra_neigh.c
index a222e7f6e8..8a91f2719b 100644
--- a/zebra/zebra_neigh.c
+++ b/zebra/zebra_neigh.c
@@ -153,14 +153,18 @@ void zebra_neigh_del(struct interface *ifp, struct ipaddr *ip)
/* kernel neigh delete all for a given interface */
void zebra_neigh_del_all(struct interface *ifp)
{
- struct zebra_neigh_ent *n, *nn;
+ struct zebra_neigh_ent *n, *next;
if (IS_ZEBRA_DEBUG_NEIGH)
zlog_debug("zebra neigh delete all for interface %s/%d",
ifp->name, ifp->ifindex);
- RB_FOREACH_SAFE (n, zebra_neigh_rb_head, &zneigh_info->neigh_rb_tree, nn)
- zebra_neigh_del(ifp, &n->ip);
+ RB_FOREACH_SAFE (n, zebra_neigh_rb_head, &zneigh_info->neigh_rb_tree, next) {
+ if (n->ifindex == ifp->ifindex) {
+ /* Free the neighbor directly instead of looking it up again */
+ zebra_neigh_free(n);
+ }
+ }
}
/* kernel neigh add */