From patchwork Mon Dec 18 21:50:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Paasch X-Patchwork-Id: 850421 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=apple.com header.i=@apple.com header.b="fxJTz5On"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0vr93jnXz9s7v for ; Tue, 19 Dec 2017 08:51:37 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937459AbdLRVvf (ORCPT ); Mon, 18 Dec 2017 16:51:35 -0500 Received: from mail-out6.apple.com ([17.151.62.28]:48858 "EHLO mail-in6.apple.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935637AbdLRVva (ORCPT ); Mon, 18 Dec 2017 16:51:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1513633890; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-Version:Content-Type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=tVV48Frl2EtqDSMz+mpLDADrcJZK0qLBOMQBXGRXohA=; b=fxJTz5OnfHJgJNO4CmpXOhZscXit/JMKBzRouY8bSh0zNXXOWqS/P8U6fsIDgesY 4SVCXQPKSDbWLD4Mxm6POsF0qGscfFMEQ4kcSEarC47XhfLp2jTz38Yu3Chl0aBb /gCAQgsYS6gKWJe6SX1vEaLeqy7JnOIDOy1BP8qLhiiKc33wRitYRyd7auKv52gO CsSnkhBvxxAliq2+/x7fbZhdg/Nfjg+mPeXLOEfqPlYk9LHCfmwpyxp2A3p0X41f u8MxgLwRvqC7Tw1De+6m87cb8WFUH4T591jElmP35dgokyS7I00+w2jJ5kL2gs/J cp1aNhevY3RZHd/Sch72jQ==; Received: from relay6.apple.com (relay6.apple.com [17.128.113.90]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in6.apple.com (Apple Secure Mail Relay) with SMTP id 38.23.20985.268383A5; Mon, 18 Dec 2017 13:51:30 -0800 (PST) X-AuditID: 11973e15-7125b9c0000051f9-2a-5a3838623f6a Received: from nwk-mmpp-sz13.apple.com (nwk-mmpp-sz13.apple.com [17.128.115.216]) by relay6.apple.com (Apple SCV relay) with SMTP id D1.13.05652.268383A5; Mon, 18 Dec 2017 13:51:30 -0800 (PST) Content-transfer-encoding: 7BIT Received: from localhost ([17.226.23.135]) by nwk-mmpp-sz13.apple.com (Oracle Communications Messaging Server 8.0.2.1.20171204 64bit (built Dec 4 2017)) with ESMTPSA id <0P1600LBSFDUYT00@nwk-mmpp-sz13.apple.com>; Mon, 18 Dec 2017 13:51:30 -0800 (PST) From: Christoph Paasch To: netdev@vger.kernel.org Cc: Eric Dumazet , Mat Martineau , Alexei Starovoitov Subject: [RFC 01/14] tcp: Write options after the header has been fully done Date: Mon, 18 Dec 2017 13:50:56 -0800 Message-id: <20171218215109.38700-2-cpaasch@apple.com> X-Mailer: git-send-email 2.15.0 In-reply-to: <20171218215109.38700-1-cpaasch@apple.com> References: <20171218215109.38700-1-cpaasch@apple.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBLMWRmVeSWpSXmKPExsUi2FAYpZtkYRFl0PJI2uLLz9vsFk+PPWK3 +NvSz2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4Vw0AJGxlWMAkWpOYmVZnpwn25iBIdk YdQOxoblVocYBTgYlXh4Z1w1jxJiTSwrrswF+oyDWUmE1+8sUIg3JbGyKrUoP76oNCe1+BCj D9BpE5mlRJPzgfGSVxJvaGxhbGliYWBgYmlmgkNYSZzXfRXQLIH0xJLU7NTUgtQimHFMHJxS DYyBk56E9WvUW3UeKd9Sl1fJfEAppro+xmSL/aR3J4JMbF1iIprnqjnYpByxZLtRkrNEIbCx yeec5N9NKg8W7wqzuxJ6fpo7T63cjqLpWqrMK+4eUomaaztv6dS+1r/fE7fN2vHX5Me1h1uS Xm7tK33cqDu/XLQ0I6b9jffVgJWNTFlWYY893yixANOEoRZzUXEiAOg4B7Z2AgAA Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The generic TCP-option framework will need to have access to the full TCP-header (e.g., if we want to compute a checksum for TCP-MD5). Thus, we move the call to tcp_options_write() to after all the fields in the header have been filled out. Signed-off-by: Christoph Paasch Reviewed-by: Mat Martineau --- net/ipv4/tcp_output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 04be9f833927..0f66d101d0ca 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1126,7 +1126,6 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, } } - tcp_options_write((__be32 *)(th + 1), tp, &opts); skb_shinfo(skb)->gso_type = sk->sk_gso_type; if (likely(!(tcb->tcp_flags & TCPHDR_SYN))) { th->window = htons(tcp_select_window(sk)); @@ -1137,6 +1136,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, */ th->window = htons(min(tp->rcv_wnd, 65535U)); } + tcp_options_write((__be32 *)(th + 1), tp, &opts); #ifdef CONFIG_TCP_MD5SIG /* Calculate the MD5 hash, as we have all we need now */ if (md5) { @@ -3242,8 +3242,8 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst, /* RFC1323: The window in SYN & SYN/ACK segments is never scaled. */ th->window = htons(min(req->rsk_rcv_wnd, 65535U)); - tcp_options_write((__be32 *)(th + 1), NULL, &opts); th->doff = (tcp_header_size >> 2); + tcp_options_write((__be32 *)(th + 1), NULL, &opts); __TCP_INC_STATS(sock_net(sk), TCP_MIB_OUTSEGS); #ifdef CONFIG_TCP_MD5SIG