]> granicus.if.org Git - ipset/commitdiff
net ipset: use rbtree postorder iteration instead of opencoding
authorCody P Schafer <cody@linux.vnet.ibm.com>
Wed, 13 Nov 2013 09:30:35 +0000 (10:30 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Wed, 13 Nov 2013 09:50:36 +0000 (10:50 +0100)
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>
configure.ac
kernel/include/linux/netfilter/ipset/ip_set_compat.h.in
kernel/net/netfilter/ipset/ip_set_hash_netiface.c

index 228000ba8e4b0655e79550798999b6c8a8dcd7b1..b88677837a32969836d529409e3b414df4b9f4cb 100644 (file)
@@ -313,6 +313,16 @@ else
        AC_SUBST(HAVE_USER_NS_IN_STRUCT_NET, undef)
 fi
 
+AC_MSG_CHECKING([kernel source for rbtree_postorder_for_each_entry_safe])
+if test -f $ksourcedir/include/linux/rbtree.h && \
+   $GREP -q 'rbtree_postorder_for_each_entry_safe' $ksourcedir/include/linux/rbtree.h; then
+       AC_MSG_RESULT(yes)
+       AC_SUBST(HAVE_RBTREE_POSTORDER_FOR_EACH_ENTRY_SAFE, define)
+else
+       AC_MSG_RESULT(no)
+       AC_SUBST(HAVE_RBTREE_POSTORDER_FOR_EACH_ENTRY_SAFE, undef)
+fi
+
 AC_MSG_CHECKING([kernel source for struct net_generic])
 if test -f $ksourcedir/include/net/netns/generic.h && \
    $GREP -q 'struct net_generic' $ksourcedir/include/net/netns/generic.h; then
index 4a076f843a4e4ae19cd3bb95780f22fc3d55442c..85684f334a76b3fb539a45cd5bd04dddc6447173 100644 (file)
@@ -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.
index 3f64a66bf5d9b78bfa551124cbc7bd3d7d8a8857..788825b219aeabc203f0fdc3a1cea7d3e2d2f40d 100644 (file)
@@ -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