netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* query: tcp_sock tcp_header_len calculations (re-sent)
@ 2010-01-10 12:06 William Allen Simpson
  2010-01-15 14:16 ` [PATCH] tcp: input header length, prediction, and timestamp bugs William Allen Simpson
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: William Allen Simpson @ 2010-01-10 12:06 UTC (permalink / raw)
  To: Linux Kernel Developers; +Cc: Linux Kernel Network Developers

Apparently, nobody on the network developers list knows about this.  I've
stumbled upon a completely undocumented and incomprehensible usage for
tcp_header_len.  Is whomever wrote this still around?

linux/tcp.h documents this as:
...
	u16	tcp_header_len;	/* Bytes of tcp header to send		*/
...

So far, so good.  But it's clearly *not* correct in tcp_output.c:

tcp_connect_init()
...
	tp->tcp_header_len = sizeof(struct tcphdr) +
		(sysctl_tcp_timestamps ? TCPOLEN_TSTAMP_ALIGNED : 0);

#ifdef CONFIG_TCP_MD5SIG
	if (tp->af_specific->md5_lookup(sk, sk) != NULL)
		tp->tcp_header_len += TCPOLEN_MD5SIG_ALIGNED;
#endif
...

This combination is actually *impossible* -- current options code
*never* allows both authentication and timestamps, doing SACK instead:

tcp_syn_options()
...
	if (likely(sysctl_tcp_timestamps && *md5 == NULL)) {
		opts->options |= OPTION_TS;
...

tcp_synack_options()
...
		/* We can't fit any SACK blocks in a packet with MD5 + TS
		 * options. There was discussion about disabling SACK
		 * rather than TS in order to fit in better with old,
		 * buggy kernels, but that was deemed to be unnecessary.
		 */
		doing_ts &= !ireq->sack_ok;
...

Thus, tcp_header_len has the wrong value, resulting in underestimation
for MSS.  But even worse usage in minisocks.c:

tcp_create_openreq_child()
...
		if (newtp->rx_opt.tstamp_ok) {
			newtp->rx_opt.ts_recent = req->ts_recent;
			newtp->rx_opt.ts_recent_stamp = get_seconds();
			newtp->tcp_header_len = sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED;
		} else {
			newtp->rx_opt.ts_recent_stamp = 0;
			newtp->tcp_header_len = sizeof(struct tcphdr);
		}
#ifdef CONFIG_TCP_MD5SIG
		newtp->md5sig_info = NULL;	/*XXX*/
#endif
		if (skb->len >= TCP_MSS_DEFAULT + newtp->tcp_header_len)
			newicsk->icsk_ack.last_seg_size = skb->len - newtp->tcp_header_len;
...

This takes an *output* estimation, and then compares it to (and subtracts
from) skb->len, which is *input* length.  What's supposed to happen here?

Shouldn't this simply use the real input tcp_hdrlen()?

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

end of thread, other threads:[~2010-01-20  0:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-10 12:06 query: tcp_sock tcp_header_len calculations (re-sent) William Allen Simpson
2010-01-15 14:16 ` [PATCH] tcp: input header length, prediction, and timestamp bugs William Allen Simpson
2010-01-15 19:12   ` William Allen Simpson
2010-01-15 19:20 ` [PATCH v2] " William Allen Simpson
2010-01-19 17:35   ` William Allen Simpson
2010-01-19 19:35     ` William Allen Simpson
2010-01-19 19:58     ` William Allen Simpson
2010-01-19 20:17 ` [PATCH v3] " William Allen Simpson
2010-01-19 23:58   ` William Allen Simpson
2010-01-20  0:01 ` [PATCH v4] " William Allen Simpson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).