From 0c34fa2cc6354633dfb64275d1e37c273f3b95d0 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Thu, 30 Nov 2023 13:57:57 +0100 Subject: [PATCH] lib: fix nexthop node entry from nhg_list When stopping a VRF, the linked list entries must be removed too. Fixes: 98cbbaea91f6 ("lib: Handle if up/down and vrf enable/disable events") Signed-off-by: Philippe Guibert --- lib/nexthop_group.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index e5c2258191..9abd3139fd 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -1234,9 +1234,9 @@ void nexthop_group_disable_vrf(struct vrf *vrf) struct nexthop_hold *nhh; RB_FOREACH (nhgc, nhgc_entry_head, &nhgc_entries) { - struct listnode *node; + struct listnode *node, *nnode; - for (ALL_LIST_ELEMENTS_RO(nhgc->nhg_list, node, nhh)) { + for (ALL_LIST_ELEMENTS(nhgc->nhg_list, node, nnode, nhh)) { struct nexthop nhop; struct nexthop *nh; @@ -1257,6 +1257,8 @@ void nexthop_group_disable_vrf(struct vrf *vrf) nhg_hooks.del_nexthop(nhgc, nh); nexthop_free(nh); + + list_delete_node(nhgc->nhg_list, node); } } }