From patchwork Thu Dec 3 23:40:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Allen Simpson X-Patchwork-Id: 40284 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id B0FDEB7CF9 for ; Fri, 4 Dec 2009 10:41:24 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754835AbZLCXkW (ORCPT ); Thu, 3 Dec 2009 18:40:22 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754793AbZLCXkT (ORCPT ); Thu, 3 Dec 2009 18:40:19 -0500 Received: from mail-gx0-f226.google.com ([209.85.217.226]:40797 "EHLO mail-gx0-f226.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755407AbZLCXkJ (ORCPT ); Thu, 3 Dec 2009 18:40:09 -0500 Received: by gxk26 with SMTP id 26so1730274gxk.1 for ; Thu, 03 Dec 2009 15:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type; bh=oP3u1ADYhuL5uBzn7+hNRPVA2NLBoGjGNUkgnmkk1+k=; b=r/JSN2xPyytmHRPPy9R7mBw5ASysx8jFQuQScKLOHNERsKTOQMkLNZJ/hjqVicY+mq rTd/jJfyq98TaNnYh29vtkeZsIWvVaUsFPPHPKd0AxNb8BqHVz6LPctW7thqptPGINFF pDZd/3gpyhqqAGhCWH0EGNNUMZkMMLNVjFd5k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; b=da1NOdx4olYV/0ledW+oVTPpT7oRNfivZt8IW2kl6kAToR1xxgTN1VVulZbE2gTvib AjynpMXaZ9nJ16626tlmRACQpZy4b88V8lmDPpG46I7CF3k5NnHYEypdvF+z/G0PkZW+ bS0NDcwY0VwrYbUxqpvru9Zo63bCAO2o5yAXU= Received: by 10.101.22.14 with SMTP id z14mr2705974ani.147.1259883615975; Thu, 03 Dec 2009 15:40:15 -0800 (PST) Received: from Wastrel.local (c-68-42-73-61.hsd1.mi.comcast.net [68.42.73.61]) by mx.google.com with ESMTPS id 23sm1290973yxe.18.2009.12.03.15.40.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 03 Dec 2009 15:40:15 -0800 (PST) Message-ID: <4B184C5D.40707@gmail.com> Date: Thu, 03 Dec 2009 18:40:13 -0500 From: William Allen Simpson User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: Linux Kernel Network Developers Subject: Re: [net-next-2.6 PATCH v9 0/2] TCPCT part 1h: accept SYNACK data References: <4B184A20.4050005@gmail.com> In-Reply-To: <4B184A20.4050005@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When accompanied by cookie option, Initiator (client) queues incoming SYNACK transaction data. This is a straightforward re-implementation of an earlier (year-old) patch that no longer applies cleanly, with permission of the original author (Adam Langley). The patch was previously reviewed: http://thread.gmane.org/gmane.linux.network/102586 Also, redefine two TCP header functions to accept TCP header pointer. When subtracting, return signed int to allow error checking. These functions will also be used in subsequent patches that implement additional features. Signed-off-by: William.Allen.Simpson@gmail.com --- include/linux/tcp.h | 12 ++++++++++++ net/ipv4/tcp_input.c | 25 ++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 7fee8a4..54ef984 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -223,6 +223,18 @@ static inline unsigned int tcp_optlen(const struct sk_buff *skb) return (tcp_hdr(skb)->doff - 5) * 4; } +/* Fixed portion plus standard options. */ +static inline unsigned int tcp_header_len_th(const struct tcphdr *th) +{ + return th->doff * 4; +} + +/* Standard options only. When doff is bad, this could be negative. */ +static inline int tcp_option_len_th(const struct tcphdr *th) +{ + return (int)(th->doff * 4) - sizeof(*th); +} + /* This defines a selective acknowledgement block. */ struct tcp_sack_block_wire { __be32 start_seq; diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 57ae96a..8089424 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -5393,6 +5393,12 @@ discard: return 0; } +/* + * Returns: + * +1 on reset, + * 0 success and/or SYNACK data, + * -1 on discard. + */ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, struct tcphdr *th, unsigned len) { @@ -5402,6 +5408,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, struct dst_entry *dst = __sk_dst_get(sk); struct tcp_cookie_values *cvp = tp->cookie_values; int saved_clamp = tp->rx_opt.mss_clamp; + int queued = 0; tcp_parse_options(skb, &tp->rx_opt, &hash_location, 0, dst); @@ -5523,6 +5530,19 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, hash_location, cookie_size); cvp->cookie_pair_size = cookie_pair_size; } + + queued = skb->len - tcp_header_len_th(th); + if (queued > 0) { + /* Queue incoming transaction data. */ + __skb_pull(skb, tcp_header_len_th(th)); + __skb_queue_tail(&sk->sk_receive_queue, skb); + skb_set_owner_r(skb, sk); + sk->sk_data_ready(sk, 0); + cvp->s_data_in = 1; /* true */ + tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; + tp->rcv_wup = TCP_SKB_CB(skb)->end_seq; + tp->copied_seq = TCP_SKB_CB(skb)->seq + 1; + } } smp_mb(); @@ -5576,11 +5596,14 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, TCP_DELACK_MAX, TCP_RTO_MAX); discard: - __kfree_skb(skb); + if (queued <= 0) + __kfree_skb(skb); return 0; } else { tcp_send_ack(sk); } + if (queued > 0) + return 0; return -1; }