Skip to contentSkip to conversation

destroy_conntrack optimization

PATCH Applied Harald Welte 2 participants 2 messages Oct 2, 2003 – Oct 3, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 destroy_conntrack optimization

Hi Davem!

Please apply the following patch to your 2.6 tree and push it to Marcelo. Thanks.

Author: Patrick McHardy <[email protected]>

Don't call ip_conntrack_put with ip_conntrack_lock held

Signature · 5 lines
- Harald Welte <[email protected]>             http://www.netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.1357 -> 1.1358
# net/ipv4/netfilter/ip_conntrack_core.c 1.37 -> 1.38
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/09/27 [email protected] 1.1358
# [NETFILTER]: Don't call ip_conntrack_put with ip_conntrack_lock held # --------------------------------------------
#

net/ipv4/netfilter/ip_conntrack_core.c +5 -2
diff -Nru a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -301,7 +301,7 @@
 static void
 destroy_conntrack(struct nf_conntrack *nfct)
 {
-	struct ip_conntrack *ct = (struct ip_conntrack *)nfct;
+	struct ip_conntrack *ct = (struct ip_conntrack *)nfct, *master = NULL;
 	struct ip_conntrack_protocol *proto;
 
 	DEBUGP("destroy_conntrack(%p)\n", ct);
@@ -328,11 +328,14 @@
 			/* can't call __unexpect_related here,
 			 * since it would screw up expect_list */
 			list_del(&ct->master->expected_list);
-			ip_conntrack_put(ct->master->expectant);
+			master = ct->master->expectant;
 		}
 		kfree(ct->master);
 	}
 	WRITE_UNLOCK(&ip_conntrack_lock);
+
+	if (master)
+		ip_conntrack_put(master);
 
 	DEBUGP("destroy_conntrack: returning ct=%p to slab\n", ct);
 	kmem_cache_free(ip_conntrack_cachep, ct);
#1 lore raw
Quoted 1 line · On Thu, 2 Oct 2003 16:25:04 +0200 Harald Welte <[email protected]> wrote:

Please apply the following patch to your 2.6 tree and push it to Marcelo.

Applied, thanks.