public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: cups slow on linux-2.6.24
@ 2008-01-28 22:41 Jeff Chua
  2008-01-28 22:56 ` Krzysztof Oledzki
  2008-01-29 10:53 ` Jozsef Kadlecsik
  0 siblings, 2 replies; 28+ messages in thread
From: Jeff Chua @ 2008-01-28 22:41 UTC (permalink / raw)
  To: lkml, cups-bugs, Jozsef Kadlecsik, Krzysztof Piotr Oledzki,
	Patrick McHardy, David S. Miller, cups-bugs



On Jan 28, 2008 7:18 AM, Jeff Chua <jeff.chua.linux@gmail.com> wrote:
> I'm sending printing jobs to a network printer (it's actually printing
> to the localhost simply creating a file), and running this on
> Linux-2.6.24 will cause the printing to slow down to 1 print every 3
> seconds after printing 500 times.

I bisected the kernel since the last known good 2.6.23 and zeroed in to 
this commit.

commit 17311393f969090ab060540bd9dbe7dc885a76d5
Author: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Date:   Thu Oct 11 14:35:52 2007 -0700

     [NETFILTER]: nf_conntrack_tcp: fix connection reopening


Reverting this commit solves the problem.

Version              1000 jobs
2.6.23                 90 sec
2.6.24              1,492 sec  <== with commit
2.6.24(patch)          90 sec  <== reverted the commit


Since the code has changed an can't simply revert the commit for the 
latest linux git download, I made a patch to revert the above commit. I've 
tested and it's working, but don't know if it breaks other things. Please 
review.

Thanks,
Jeff.


--- net/netfilter/nf_conntrack_proto_tcp.c.org	2008-01-29 03:34:43 +0800
+++ net/netfilter/nf_conntrack_proto_tcp.c	2008-01-29 03:36:26 +0800
@@ -836,8 +836,8 @@
  			break;
  		if ((conntrack->proto.tcp.seen[!dir].flags &
  			IP_CT_TCP_FLAG_CLOSE_INIT)
-		    || (conntrack->proto.tcp.last_dir == dir
-		        && conntrack->proto.tcp.last_index == TCP_RST_SET)) {
+		    || after(ntohl(th->seq),
+		        conntrack->proto.tcp.seen[dir].td_end)) {
  			/* Attempt to reopen a closed/aborted connection.
  			 * Delete this connection and look up again. */
  			write_unlock_bh(&tcp_lock);
@@ -845,6 +845,12 @@
  				conntrack->timeout.function((unsigned long)
  							    conntrack);
  			return -NF_REPEAT;
+		} else {
+			write_unlock_bh(&tcp_lock);
+			if (LOG_INVALID(IPPROTO_TCP))
+				nf_log_packet(pf, 0, skb, NULL, NULL,
+					NULL, "nf_ct_tcp: invalid SYN");
+			return -NF_ACCEPT;
  		}
  		/* Fall through */
  	case TCP_CONNTRACK_IGNORE:



^ permalink raw reply	[flat|nested] 28+ messages in thread
* Re: cups slow on linux-2.6.24
@ 2008-02-10 15:06 Jeff Chua
  2008-02-14 15:02 ` Jozsef Kadlecsik
  0 siblings, 1 reply; 28+ messages in thread
From: Jeff Chua @ 2008-02-10 15:06 UTC (permalink / raw)
  To: Patrick McHardy
  Cc: Jozsef Kadlecsik, lkml, Krzysztof Piotr Oledzki, David S. Miller,
	cups-bugs, Netfilter Development Mailinglist, Linus Torvalds


On Feb 5, 2008 9:47 PM, Patrick McHardy wrote:
>> On Feb 5, 2008 4:16 PM, Jozsef Kadlecsik wrote:
>> Patrick, I suppose you need a patch against the latest git, don't you?
> Yes, please. I'll take you first patch for -stable though if you
> send me a Signed-off-by: line.

Please note the lastest git commit is missing one part (which was in 
Jozsef's original patch).

 	commit b2155e7f70b3f058efe94c0c459db023b05057bd
 	Author: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
 	Date:   Thu Feb 7 17:54:56 2008 -0800

 	    [NETFILTER]: nf_conntrack: TCP conntrack reopening fix


I've tested the following missing patch, and it solves the cups slow 
printing problem.


Thanks,
Jeff

--- a/net/netfilter/nf_conntrack_proto_tcp.c.org	2008-02-10 22:45:49 +0800
+++ a/net/netfilter/nf_conntrack_proto_tcp.c	2008-02-10 22:45:56 +0800
@@ -945,7 +945,7 @@

  	ct->proto.tcp.state = new_state;
  	if (old_state != new_state
-	    && new_state == TCP_CONNTRACK_CLOSE)
+	    && new_state == TCP_CONNTRACK_FIN_WAIT)
  		ct->proto.tcp.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT;
  	timeout = ct->proto.tcp.retrans >= nf_ct_tcp_max_retrans
  		  && tcp_timeouts[new_state] > nf_ct_tcp_timeout_max_retrans

^ permalink raw reply	[flat|nested] 28+ messages in thread
* Re: cups slow on linux-2.6.24
@ 2008-02-05  1:17 Jeff Chua
  2008-02-05  8:16 ` Jozsef Kadlecsik
  0 siblings, 1 reply; 28+ messages in thread
From: Jeff Chua @ 2008-02-05  1:17 UTC (permalink / raw)
  To: Jozsef Kadlecsik
  Cc: Patrick McHardy, lkml, Krzysztof Piotr Oledzki, David S. Miller,
	cups-bugs, Netfilter Development Mailinglist



On Feb 5, 2008 4:17 AM, Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> wrote:

> Actively closed connections are not handled properly, i.e. the initiator 
> of the active close should not be taken into account. So could you give 
> a try to the patch below? Does it just suppress the 'invalid packed 
> ignored' and all other kernel messages or both suppresses them and 
> produces normal printing speed?

Jozsef,

Amazing! You fixed it. No more 'invalid packed ignored', and speed back to 
normal (continues after approx. 20 seconds of pausing after 503 prints).

I used the latest git, and have to modify your patch slightly to make it 
work (changing "conntrack" to "ct").


Thank you for fixing this.

Jeff


Here's your patch modified so it'll apply to the latest git.

--- a/net/netfilter/nf_conntrack_proto_tcp.c.org	2008-02-05 08:29:39 +0800
+++ a/net/netfilter/nf_conntrack_proto_tcp.c	2008-02-05 08:28:05 +0800
@@ -125,7 +125,7 @@
   * CLOSE_WAIT:	ACK seen (after FIN)
   * LAST_ACK:	FIN seen (after FIN)
   * TIME_WAIT:	last ACK seen
- * CLOSE:	closed connection
+ * CLOSE:	closed connection (RST)
   *
   * LISTEN state is not used.
   *
@@ -824,9 +824,23 @@
  	case TCP_CONNTRACK_SYN_SENT:
  		if (old_state < TCP_CONNTRACK_TIME_WAIT)
  			break;
-		if ((ct->proto.tcp.seen[!dir].flags & IP_CT_TCP_FLAG_CLOSE_INIT)
-		    || (ct->proto.tcp.last_dir == dir
-		        && ct->proto.tcp.last_index == TCP_RST_SET)) {
+		/* RFC 1122: "When a connection is closed actively,
+		 * it MUST linger in TIME-WAIT state for a time 2xMSL
+		 * (Maximum Segment Lifetime). However, it MAY accept
+		 * a new SYN from the remote TCP to reopen the connection
+		 * directly from TIME-WAIT state, if..."
+		 * We ignore the conditions because we are in the
+		 * TIME-WAIT state anyway.
+		 *
+		 * Handle aborted connections: we and the server
+		 * think there is an existing connection but the client
+		 * aborts it and starts a new one.
+		 */
+		if (((ct->proto.tcp.seen[dir].flags
+		      | ct->proto.tcp.seen[!dir].flags)
+		     & IP_CT_TCP_FLAG_CLOSE_INIT)
+ 		    || (ct->proto.tcp.last_dir == dir
+ 		        && ct->proto.tcp.last_index == TCP_RST_SET)) {
  			/* Attempt to reopen a closed/aborted connection.
  			 * Delete this connection and look up again. */
  			write_unlock_bh(&tcp_lock);
@@ -838,15 +852,23 @@
  	case TCP_CONNTRACK_IGNORE:
  		/* Ignored packets:
  		 *
+		 * Our connection entry may be out of sync, so ignore
+		 * packets which may signal the real connection between
+		 * the client and the server.
+		 *
  		 * a) SYN in ORIGINAL
  		 * b) SYN/ACK in REPLY
  		 * c) ACK in reply direction after initial SYN in original.
+		 *
+		 * If the ignored packet is invalid, the receiver will send 
+		 * a RST we'll catch below.
  		 */
  		if (index == TCP_SYNACK_SET
  		    && ct->proto.tcp.last_index == TCP_SYN_SET
  		    && ct->proto.tcp.last_dir != dir
  		    && ntohl(th->ack_seq) == ct->proto.tcp.last_end) {
  			/* This SYN/ACK acknowledges a SYN that we earlier
+			/* b) This SYN/ACK acknowledges a SYN that we earlier
  			 * ignored as invalid. This means that the client and
  			 * the server are both in sync, while the firewall is
  			 * not. We kill this session and block the SYN/ACK so
@@ -924,8 +946,7 @@

  	ct->proto.tcp.state = new_state;
  	if (old_state != new_state
-	    && (new_state == TCP_CONNTRACK_FIN_WAIT
-		|| new_state == TCP_CONNTRACK_CLOSE))
+	    && new_state == TCP_CONNTRACK_FIN_WAIT)
  		ct->proto.tcp.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT;
  	timeout = ct->proto.tcp.retrans >= nf_ct_tcp_max_retrans
  		  && tcp_timeouts[new_state] > nf_ct_tcp_timeout_max_retrans

^ permalink raw reply	[flat|nested] 28+ messages in thread
[parent not found: <Pine.LNX.4.64.0802042226340.28805@boston.corp.fedex.com>]
* cups slow on linux-2.6.24
@ 2008-01-27 23:18 Jeff Chua
  0 siblings, 0 replies; 28+ messages in thread
From: Jeff Chua @ 2008-01-27 23:18 UTC (permalink / raw)
  To: lkml, cups-bugs

I'm sending printing jobs to a network printer (it's actually printing
to the localhost simply creating a file), and running this on
Linux-2.6.24 will cause the printing to slow down to 1 print every 3
seconds after printing 500 times.

No such symptoms on 2.6.23.12, or 2.6.20.21.

It's repeatable.

I'm just check if this is already reported/resolved before bisecting the kernel.

Thanks,
Jeff.

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2008-02-15  1:44 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-28 22:41 cups slow on linux-2.6.24 Jeff Chua
2008-01-28 22:56 ` Krzysztof Oledzki
2008-01-28 23:55   ` Jeff Chua
2008-01-29 10:53 ` Jozsef Kadlecsik
     [not found]   ` <b6a2187b0801291924k15f883aeg54f704156e4f2e3e@mail.gmail.com>
2008-01-30 13:47     ` Patrick McHardy
2008-01-31  2:23       ` Jeff Chua
     [not found]         ` <b6a2187b0801301826l5a50ce84p7d5dce3d0a74b3c0@mail.gmail.com>
2008-01-31  2:41           ` Patrick McHardy
2008-01-31  3:21             ` Jeff Chua
2008-01-31  3:25               ` Patrick McHardy
2008-01-31  5:01                 ` Jeff Chua
2008-01-31 10:40                   ` Jozsef Kadlecsik
2008-01-31 18:53                     ` Patrick McHardy
2008-02-01  0:47                       ` David Newall
2008-02-01  2:12                         ` David Miller
2008-02-01  6:07                           ` David Newall
2008-02-01  6:10                             ` Patrick McHardy
2008-02-01  5:28                     ` Jeff Chua
2008-02-02 14:44                       ` Jozsef Kadlecsik
2008-02-03 16:08                         ` Jeff Chua
  -- strict thread matches above, loose matches on Subject: below --
2008-02-10 15:06 Jeff Chua
2008-02-14 15:02 ` Jozsef Kadlecsik
2008-02-14 22:50   ` David Miller
2008-02-15  1:44     ` Patrick McHardy
2008-02-05  1:17 Jeff Chua
2008-02-05  8:16 ` Jozsef Kadlecsik
2008-02-05 13:47   ` Patrick McHardy
     [not found] <Pine.LNX.4.64.0802042226340.28805@boston.corp.fedex.com>
2008-02-04 20:17 ` Jozsef Kadlecsik
2008-01-27 23:18 Jeff Chua

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox