From: Pablo Neira <pablo@eurodev.net>
To: Netfilter Development Mailinglist
<netfilter-devel@lists.netfilter.org>,
Patrick McHardy <kaber@trash.net>
Subject: [PATCH] fine grain locking for tcp helper
Date: Sun, 02 May 2004 05:40:41 +0200 [thread overview]
Message-ID: <40946DB9.6050705@eurodev.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 235 bytes --]
Hi,
This patch provides a fine-grain locking for the tcp helper in
conntrack. A per-conntrack lock is used, instead of having a global lock
to protect tcp specific data. If I'm missing something, please let me know.
regards,
Pablo
[-- Attachment #2: locking_tcp_proto_helper.patch --]
[-- Type: text/plain, Size: 2112 bytes --]
--- linux-2.6.3-old/net/ipv4/netfilter/ip_conntrack_proto_tcp.c 2004-05-02 04:19:30.000000000 +0200
+++ linux-2.6.3/net/ipv4/netfilter/ip_conntrack_proto_tcp.c 2004-05-02 04:18:18.000000000 +0200
@@ -28,9 +28,6 @@
#define DEBUGP(format, args...)
#endif
-/* Protects conntrack->proto.tcp */
-static DECLARE_RWLOCK(tcp_lock);
-
/* FIXME: Examine ipfilter's timeouts and conntrack transitions more
closely. They're more complex. --RR */
@@ -151,9 +148,9 @@
{
enum tcp_conntrack state;
- READ_LOCK(&tcp_lock);
+ READ_LOCK(&conntrack->proto.tcp.lock);
state = conntrack->proto.tcp.state;
- READ_UNLOCK(&tcp_lock);
+ READ_UNLOCK(&conntrack->proto.tcp.lock);
return sprintf(buffer, "%s ", tcp_conntrack_names[state]);
}
@@ -188,7 +185,7 @@
return NF_ACCEPT;
}
- WRITE_LOCK(&tcp_lock);
+ WRITE_LOCK(&conntrack->proto.tcp.lock);
oldtcpstate = conntrack->proto.tcp.state;
newconntrack
= tcp_conntracks
@@ -200,7 +197,7 @@
DEBUGP("ip_conntrack_tcp: Invalid dir=%i index=%u conntrack=%u\n",
CTINFO2DIR(ctinfo), get_conntrack_index(&tcph),
conntrack->proto.tcp.state);
- WRITE_UNLOCK(&tcp_lock);
+ WRITE_UNLOCK(&conntrack->proto.tcp.lock);
return -1;
}
@@ -222,7 +219,7 @@
&& tcph.ack_seq == conntrack->proto.tcp.handshake_ack)
set_bit(IPS_ASSURED_BIT, &conntrack->status);
-out: WRITE_UNLOCK(&tcp_lock);
+out: WRITE_UNLOCK(&conntrack->proto.tcp.lock);
ip_ct_refresh(conntrack, *tcp_timeouts[newconntrack]);
return NF_ACCEPT;
@@ -249,6 +246,9 @@
}
conntrack->proto.tcp.state = newconntrack;
+ /* make sure that lock is correctly initialized */
+ conntrack->proto.tcp.lock = RW_LOCK_UNLOCKED;
+
return 1;
}
--- linux-2.6.3-old/include/linux/netfilter_ipv4/ip_conntrack_tcp.h 2004-02-18 04:57:29.000000000 +0100
+++ linux-2.6.3/include/linux/netfilter_ipv4/ip_conntrack_tcp.h 2004-05-02 04:19:04.000000000 +0200
@@ -18,6 +18,9 @@
struct ip_ct_tcp
{
+ /* Protects conntrack tcp protocol specific information */
+ rwlock_t tcp_lock;
+
enum tcp_conntrack state;
/* Poor man's window tracking: sequence number of valid ACK
next reply other threads:[~2004-05-02 3:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-02 3:40 Pablo Neira [this message]
2004-05-02 3:51 ` [PATCH] fine grain locking for tcp helper Pablo Neira
2004-05-03 8:55 ` Jozsef Kadlecsik
2004-05-03 13:55 ` Pablo Neira
2004-05-03 14:49 ` Jozsef Kadlecsik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40946DB9.6050705@eurodev.net \
--to=pablo@eurodev.net \
--cc=kaber@trash.net \
--cc=netfilter-devel@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.