Skip to content

Commit b182837

Browse files
codypstorvalds
authored andcommitted
net/netfilter/ipset/ip_set_hash_netiface.c: use rbtree postorder iteration instead of opencoding
Use rbtree_postorder_for_each_entry_safe() to destroy the rbtree instead of opencoding an alternate postorder iteration that modifies the tree Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com> Cc: Michel Lespinasse <walken@google.com> Cc: Jan Kara <jack@suse.cz> Cc: Pablo Neira Ayuso <pablo@netfilter.org> Cc: Patrick McHardy <kaber@trash.net> Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 964fe94 commit b182837

1 file changed

Lines changed: 4 additions & 23 deletions

File tree

‎net/netfilter/ipset/ip_set_hash_netiface.c‎

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,12 @@ struct iface_node {
4646
static void
4747
rbtree_destroy(struct rb_root *root)
4848
{
49-
struct rb_node *p, *n = root->rb_node;
50-
struct iface_node *node;
51-
52-
/* Non-recursive destroy, like in ext3 */
53-
while (n) {
54-
if (n->rb_left) {
55-
n = n->rb_left;
56-
continue;
57-
}
58-
if (n->rb_right) {
59-
n = n->rb_right;
60-
continue;
61-
}
62-
p = rb_parent(n);
63-
node = rb_entry(n, struct iface_node, node);
64-
if (!p)
65-
*root = RB_ROOT;
66-
else if (p->rb_left == n)
67-
p->rb_left = NULL;
68-
else if (p->rb_right == n)
69-
p->rb_right = NULL;
49+
struct iface_node *node, *next;
7050

51+
rbtree_postorder_for_each_entry_safe(node, next, root, node)
7152
kfree(node);
72-
n = p;
73-
}
53+
54+
*root = RB_ROOT;
7455
}
7556

7657
static int

0 commit comments

Comments
 (0)