summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorCody P Schafer <cody@linux.vnet.ibm.com>2013-11-13 10:30:35 +0100
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2013-11-13 10:50:36 +0100
commit04ca6d3715d42277ef001f5a5252cd015d84279b (patch)
treead9ef98667d0000304b43032e3ee92744fa05bdf /kernel
parentea39db5d0778ced5bbed902c2b62abe5e7ee8c39 (diff)
net ipset: 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> Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/include/linux/netfilter/ipset/ip_set_compat.h.in3
-rw-r--r--kernel/net/netfilter/ipset/ip_set_hash_netiface.c9
2 files changed, 11 insertions, 1 deletions
diff --git a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in
index 4a076f8..85684f3 100644
--- a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in
+++ b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in
@@ -22,7 +22,8 @@
#@HAVE_CHECKENTRY_BOOL@ HAVE_CHECKENTRY_BOOL
#@HAVE_XT_TARGET_PARAM@ HAVE_XT_TARGET_PARAM
#@HAVE_NET_OPS_ID@ HAVE_NET_OPS_ID
-#@HAVE_USER_NS_IN_STRUCT_NET@ HAVE_USER_NS_IN_STRUCT_NET
+#@HAVE_USER_NS_IN_STRUCT_NET@ HAVE_USER_NS_IN_STRUCT_NET
+#@HAVE_RBTREE_POSTORDER_FOR_EACH_ENTRY_SAFE@ HAVE_RBTREE_POSTORDER_FOR_EACH_ENTRY_SAFE
/* Not everything could be moved here. Compatibility stuffs can be found in
* xt_set.c, ip_set_core.c, ip_set_getport.c, pfxlen.c too.
diff --git a/kernel/net/netfilter/ipset/ip_set_hash_netiface.c b/kernel/net/netfilter/ipset/ip_set_hash_netiface.c
index 3f64a66..788825b 100644
--- a/kernel/net/netfilter/ipset/ip_set_hash_netiface.c
+++ b/kernel/net/netfilter/ipset/ip_set_hash_netiface.c
@@ -46,6 +46,14 @@ struct iface_node {
static void
rbtree_destroy(struct rb_root *root)
{
+#ifdef HAVE_RBTREE_POSTORDER_FOR_EACH_ENTRY_SAFE
+ struct iface_node *node, *next;
+
+ rbtree_postorder_for_each_entry_safe(node, next, root, node)
+ kfree(node);
+
+ *root = RB_ROOT;
+#else
struct rb_node *p, *n = root->rb_node;
struct iface_node *node;
@@ -71,6 +79,7 @@ rbtree_destroy(struct rb_root *root)
kfree(node);
n = p;
}
+#endif
}
static int