From patchwork Mon Dec 18 21:50:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Paasch X-Patchwork-Id: 850424 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="MpVb4iYk"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z0vrN396Fz9s7v for ; Tue, 19 Dec 2017 08:51:48 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937601AbdLRVvr (ORCPT ); Mon, 18 Dec 2017 16:51:47 -0500 Received: from mail-out2.apple.com ([17.151.62.25]:53894 "EHLO mail-in2.apple.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934193AbdLRVvb (ORCPT ); Mon, 18 Dec 2017 16:51:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1513633891; 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=Fb77NcWqYxn9tw/A5ZyWnZoVqsW6gqgNwKgKPsZZoUU=; b=MpVb4iYk12Sy5h4bVjCh9/4eXtXXTcEK0p/GL6pBeTSQjZk9H1Md2h2EIhHFmM0O uI8L4TMByBED/jVWCXM5O+sKYFxbKv5dSOh2CTT9kOLaD+piHgmD9oyrb/pKxFzx tR9GN6NpsHhj4VEB/EHTgQ4GfI2jMzz3nVXyvtnW7fywZLA9DVP2ueNhqaYD4Rmk gZuRoH7D+WqWaaXSvptHavH/8WXyTH2cpHIhJWFSVqYOgCiKZww99mSEh3yQVDm6 fQ6paRG3BuYGyW7qlOaBnkT1GURdtT8yqmwUm18RB4OVgT5YjsUWBxJOFHP/PNLF 7yWM/Q4yx9CcJXuAtL2+NQ==; Received: from relay8.apple.com (relay8.apple.com [17.128.113.102]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in2.apple.com (Apple Secure Mail Relay) with SMTP id C7.62.22347.368383A5; Mon, 18 Dec 2017 13:51:31 -0800 (PST) X-AuditID: 11973e11-163b19c00000574b-d5-5a383863fe7f Received: from nwk-mmpp-sz13.apple.com (nwk-mmpp-sz13.apple.com [17.128.115.216]) by relay8.apple.com (Apple SCV relay) with SMTP id 03.0F.22651.368383A5; Mon, 18 Dec 2017 13:51:31 -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 <0P1600LBWFDVYT00@nwk-mmpp-sz13.apple.com>; Mon, 18 Dec 2017 13:51:31 -0800 (PST) From: Christoph Paasch To: netdev@vger.kernel.org Cc: Eric Dumazet , Mat Martineau , Alexei Starovoitov Subject: [RFC 02/14] tcp: Pass sock and skb to tcp_options_write Date: Mon, 18 Dec 2017 13:50:57 -0800 Message-id: <20171218215109.38700-3-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+NgFprJLMWRmVeSWpSXmKPExsUi2FCYpptsYRFlcH+Ft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g5JuFcNECRsZVjAJFqTmJlRZ6cK9uYgQHZWHa Dsam5VaHGAU4GJV4eGdcNY8SYk0sK67MBXqNg1lJhNfvLFCINyWxsiq1KD++qDQntfgQow/Q aROZpUST84ERk1cSb2hsYWxpYmFgYGJpZoJDWEmc12MV0CyB9MSS1OzU1ILUIphxTBycUg2M ywrOPuI5WzPp9i7XmXK7Fq9KjRPySL6zdaVRnl/u66ygu/tZtNpztW1dOjt0fk45Uh09cXXt gYL+tnuua/IfTv+wxutEzeXnsRte7bv06eBt9rdPvq/bena94byglwn6iUtNzmuu1IoVT1EP yqqxnWI/je3mk4aAnjbrbyePT5KNfrZ/wYykTiUWYKIw1GIuKk4EAJngBf13AgAA Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org An upcoming patch adds a configurable, per-socket list of TCP options to populate in the TCP header. This requires tcp_options_write() to know the socket (to use the options list) and the skb (to provide visibility to the packet data for options like TCP_MD5SIG). Signed-off-by: Christoph Paasch Reviewed-by: Mat Martineau --- net/ipv4/tcp_output.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 0f66d101d0ca..efe599a41e36 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -444,10 +444,14 @@ struct tcp_out_options { * At least SACK_PERM as the first option is known to lead to a disaster * (but it may well be that other scenarios fail similarly). */ -static void tcp_options_write(__be32 *ptr, struct tcp_sock *tp, +static void tcp_options_write(__be32 *ptr, struct sk_buff *skb, struct sock *sk, struct tcp_out_options *opts) { u16 options = opts->options; /* mungable copy */ + struct tcp_sock *tp = NULL; + + if (sk_fullsock(sk)) + tp = tcp_sk(sk); if (unlikely(OPTION_MD5 & options)) { *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | @@ -1136,7 +1140,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); + tcp_options_write((__be32 *)(th + 1), skb, sk, &opts); #ifdef CONFIG_TCP_MD5SIG /* Calculate the MD5 hash, as we have all we need now */ if (md5) { @@ -3243,7 +3247,7 @@ 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)); th->doff = (tcp_header_size >> 2); - tcp_options_write((__be32 *)(th + 1), NULL, &opts); + tcp_options_write((__be32 *)(th + 1), skb, req_to_sk(req), &opts); __TCP_INC_STATS(sock_net(sk), TCP_MIB_OUTSEGS); #ifdef CONFIG_TCP_MD5SIG