From patchwork Tue Feb 2 16:33:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Allen Simpson X-Patchwork-Id: 44296 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.180.67]) by ozlabs.org (Postfix) with ESMTP id 32550B7D51 for ; Wed, 3 Feb 2010 03:33:36 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756272Ab0BBQdb (ORCPT ); Tue, 2 Feb 2010 11:33:31 -0500 Received: from mail-iw0-f171.google.com ([209.85.223.171]:44449 "EHLO mail-iw0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752024Ab0BBQd3 (ORCPT ); Tue, 2 Feb 2010 11:33:29 -0500 Received: by iwn1 with SMTP id 1so280570iwn.25 for ; Tue, 02 Feb 2010 08:33:28 -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:cc:subject:references:in-reply-to :content-type; bh=ZvyOz7Eyitn4EsUWXOqMR9rbmH8k5SjY117b2zCTxUA=; b=Lw6dkL8eNXah9uVSDIhYuetUInfLqro5OFReq8RGQ/Zel1wC9eq+NpsJzikYhuG1MN FT8B7C4w1Q/yXAe2QIGprAsK+oFCybsXcxSFIEX6FJhiAwQghlTcemwPPm49rKm1UF+i 1Z0f6L+xxIvJJr2tzUkX6mLlyguHLFYc2CxlI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; b=IkxKut+OWBXvta7xVkAA5UAVJFkH36Q0ysJ9YTnmxmWO/Fj2x3s9yyAZrQJx0r0J24 OY6e8R4dZl8e7y+1CLn8uwGijuZe5JHhedFINghWfl4LImZ67Ad6ZOkOvwrw3TyY1bcc tLUOokwNvf70RTF5HsAVYej0D0mnXSMbL239s= Received: by 10.231.85.198 with SMTP id p6mr7658698ibl.65.1265128408332; Tue, 02 Feb 2010 08:33:28 -0800 (PST) Received: from Wastrel.local (c-68-40-195-221.hsd1.mi.comcast.net [68.40.195.221]) by mx.google.com with ESMTPS id 23sm6666395iwn.3.2010.02.02.08.33.23 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 02 Feb 2010 08:33:24 -0800 (PST) Message-ID: <4B6853D3.9080300@gmail.com> Date: Tue, 02 Feb 2010 11:33:23 -0500 From: William Allen Simpson User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: Linux Kernel Developers , Linux Kernel Network Developers CC: Andrew Morton Subject: [PATCH v3 5/7] TCPCT part 2e: accept SYNACK data References: <4B684DE7.3020601@gmail.com> In-Reply-To: <4B684DE7.3020601@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 This function will also be used in subsequent patches that implement additional features. Requires: TCPCT part 1g: Responder Cookie => Initiator net: tcp_header_len_th and tcp_option_len_th Signed-off-by: William.Allen.Simpson@gmail.com --- net/ipv4/tcp_input.c | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 8e0f6ae..165040e 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -5395,6 +5395,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) { @@ -5403,6 +5409,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, struct tcp_sock *tp = tcp_sk(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); @@ -5509,6 +5516,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, - TCPOLEN_COOKIE_BASE; int cookie_pair_size = cookie_size + cvp->cookie_desired; + int tcp_header_len = tcp_header_len_th(th); /* A cookie extension option was sent and returned. * Note that each incoming SYNACK replaces the @@ -5524,6 +5532,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; + if (queued > 0) { + /* Queue incoming transaction data. */ + __skb_pull(skb, tcp_header_len); + __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(); @@ -5577,11 +5598,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; }