Skip to contentSkip to conversation

locking optimization in ip_conntrack_core

PATCH New Harald Welte 1 participant 1 message Mar 29, 2004

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

PATCH 1/1 locking optimization in ip_conntrack_core

Hi Dave!

This is the first in a set of 2.6.x optimization patches. Obviosly, they are meant for 2.6.6, not 2.6.5. Please apply to your tree, thanks.

A: Pablo Neira
D: This patch puts tightens up a lock protected section in
D: ip_ct_refresh()

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
net/ipv4/netfilter/ip_conntrack_core.c +2 -2
@@ -1158,18 +1158,18 @@
 {
 	IP_NF_ASSERT(ct->timeout.data == (unsigned long)ct);
 
-	WRITE_LOCK(&ip_conntrack_lock);
 	/* If not in hash table, timer will not be active yet */
 	if (!is_confirmed(ct))
 		ct->timeout.expires = extra_jiffies;
 	else {
+		WRITE_LOCK(&ip_conntrack_lock);
 		/* Need del_timer for race avoidance (may already be dying). */
 		if (del_timer(&ct->timeout)) {
 			ct->timeout.expires = jiffies + extra_jiffies;
 			add_timer(&ct->timeout);
 		}
+		WRITE_UNLOCK(&ip_conntrack_lock);
 	}
-	WRITE_UNLOCK(&ip_conntrack_lock);
 }
 
 /* Returns new sk_buff, or NULL */