]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Routing tables list iteration should use explicit node struct position
authorMaria Matejka <mq@ucw.cz>
Tue, 30 Mar 2021 13:09:53 +0000 (15:09 +0200)
committerMaria Matejka <mq@ucw.cz>
Tue, 30 Mar 2021 19:56:08 +0000 (21:56 +0200)
nest/rt-table.c
proto/mrt/mrt.c

index 626c2fb863205c7b0f437546acdd355888ec5d38..7b81e1415a66d732715d052707185d63adac2247 100644 (file)
@@ -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);
 }
 
index 838360c26591b4d2d9cb6b4eeb2cb04c8a07da99..8d97c8607f329801e960cc93271d749d0f2a516b 100644 (file)
@@ -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;
 }