diff mbox

BSD 4.2 style TCP keepalives

Message ID 20100106.192131.193700514.davem@davemloft.net
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

David Miller Jan. 7, 2010, 3:21 a.m. UTC
From: David Miller <davem@davemloft.net>
Date: Wed, 06 Jan 2010 16:14:54 -0800 (PST)

> +#if 1
> +	/* Construct BSD 4.2 style zero-window probe with one
> +	 * out-of-window garbage data byte.
> +	 *
> +	 * XXX this does the wrong thing when 'urgent' is true
> +	 */
> +	{
> +		unsigned char *garbage_byte = skb_put(skb, 1);
> +
> +		*garbage_byte = 0xff;
> +		TCP_SKB_CB(skb)->end_seq++;
> +	}
> +#endif

This doesn't work so well, because the checksum will be wrong.
The patch at the end of this email should work better.

And maybe that's a clue, because with this upstream Linux does ACK the
probe.  So I wonder if the Windows 2000 systems don't calculate the
checksum correctly?

More mysterious by the minute :-)

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller Jan. 7, 2010, 3:36 a.m. UTC | #1
From: David Miller <davem@davemloft.net>
Date: Wed, 06 Jan 2010 19:21:31 -0800 (PST)

> And maybe that's a clue, because with this upstream Linux does ACK the
> probe.

Here's an example trace, note the DSACK blocks:

19:26:51.966289 IP A.34376 > B.330: . ack 22738433 win 0 <nop,nop,timestamp 4294964458 375470>
19:26:52.185946 IP B.330 > A.34376: . 22738432:22738433(1) ack 10753 win 127 <nop,nop,timestamp 375492 4294964458>
19:26:52.207848 IP A.34376 > B.330: . ack 22738433 win 0 <nop,nop,timestamp 4294964480 375492,nop,nop,sack 1 {22738432:22738433}>
19:26:52.645946 IP B.330 > A.34376: . 22738432:22738433(1) ack 10753 win 127 <nop,nop,timestamp 375538 4294964480>
19:26:52.668386 IP A.34376 > B.330: . ack 22738433 win 0 <nop,nop,timestamp 4294964526 375538,nop,nop,sack 1 {22738432:22738433}>
19:26:53.545949 IP B.330 > A.34376: . 22738432:22738433(1) ack 10753 win 127 <nop,nop,timestamp 375628 4294964526>
19:26:53.568955 IP A.34376 > B.330: . ack 22738433 win 0 <nop,nop,timestamp 4294964616 375628,nop,nop,sack 1 {22738432:22738433}>
19:26:55.328448 IP B.330 > A.34376: . 22738432:22738433(1) ack 10753 win 127 <nop,nop,timestamp 375806 4294964616>
19:26:55.351998 IP A.34376 > B.330: . ack 22738433 win 0 <nop,nop,timestamp 4294964794 375806,nop,nop,sack 1 {22738432:22738433}>

I added diagnostics to tcp_data_queue() to validate which conditional
triggers:

[  662.808884] TCP: HIT SYN[0] FIN[0] ACK[1] SEQ[a018c50f:a018c510] rcv_nxt[a018c510] rcv_wup[a018c510] window[00000000]
[  662.822532] TCP: tcp_data_queue() !after(end_seq, rcv_nxt)

Which is what I said should trigger for these things.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 383ce23..ce0ae32 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2727,6 +2727,20 @@  static int tcp_xmit_probe_skb(struct sock *sk, int urgent)
 	 * send it.
 	 */
 	tcp_init_nondata_skb(skb, tp->snd_una - !urgent, TCPCB_FLAG_ACK);
+#if 1
+	/* Construct BSD 4.2 style zero-window probe with one
+	 * out-of-window garbage data byte.
+	 *
+	 * XXX this does the wrong thing when 'urgent' is true
+	 */
+	{
+		unsigned char *garbage_byte = skb_put(skb, 1);
+
+		*garbage_byte = 0xff;
+		TCP_SKB_CB(skb)->end_seq++;
+		skb->ip_summed = CHECKSUM_PARTIAL;
+	}
+#endif
 	TCP_SKB_CB(skb)->when = tcp_time_stamp;
 	return tcp_transmit_skb(sk, skb, 0, GFP_ATOMIC);
 }