From 4635314cefd55aaa2a0146b6722df55e7efba4b8 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Tue, 30 Mar 2021 15:09:53 +0200 Subject: [PATCH] Routing tables list iteration should use explicit node struct position --- nest/rt-table.c | 3 ++- proto/mrt/mrt.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/nest/rt-table.c b/nest/rt-table.c index 626c2fb8..7b81e141 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -1741,8 +1741,9 @@ void rt_dump_all(void) { rtable *t; + node *n; - WALK_LIST(t, routing_tables) + WALK_LIST2(t, n, routing_tables, n) rt_dump(t); } diff --git a/proto/mrt/mrt.c b/proto/mrt/mrt.c index 838360c2..8d97c860 100644 --- a/proto/mrt/mrt.c +++ b/proto/mrt/mrt.c @@ -224,12 +224,15 @@ mrt_next_table_(rtable *tab, rtable *tab_ptr, const char *pattern) return !tab ? tab_ptr : NULL; /* Walk routing_tables list, starting after tab (if non-NULL) */ - for (tab = !tab ? HEAD(routing_tables) : NODE_NEXT(tab); - NODE_VALID(tab); - tab = NODE_NEXT(tab)) + for (node *tn = tab ? tab->n.next : HEAD(routing_tables); + NODE_VALID(tn); + tn = tn->next) + { + tab = SKIP_BACK(struct rtable, n, tn); if (patmatch(pattern, tab->name) && ((tab->addr_type == NET_IP4) || (tab->addr_type == NET_IP6))) return tab; + } return NULL; }