From patchwork Thu Feb 1 00:07:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Paasch X-Patchwork-Id: 868111 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="KS1vbFs8"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zX16161m9z9ryk for ; Thu, 1 Feb 2018 11:22:33 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755886AbeBAAWa (ORCPT ); Wed, 31 Jan 2018 19:22:30 -0500 Received: from mail-out25.apple.com ([17.171.2.35]:54625 "EHLO mail-in25.apple.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753461AbeBAAW3 (ORCPT ); Wed, 31 Jan 2018 19:22:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1517443647; x=2381357247; 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=MVp9gvpR5rziyrchnmHvgQctvFYHEUhRd0RsPqqh7b4=; b=KS1vbFs8Fb9pif8yOCQ+97esIAci6SQBEdFvEEauDfpk5g0Qi84bmESTsEO1Yfxz 2rBL16cTSn3389DIsXfhdTFmhrISaLbCGYedtFyI3to1Yy4EGs91Uxw175oEMvil 881b/EW6F5Qa6tIDr10CCiJI0G2S/PXlsjBlL/BeDEr660n6v4c/gZ9tZ288Nx3M uv0jYlrPN0YocvedymdNHc2fc62u2xtUm+8RLO2Gy6JtbwKDvIuoNOrhh68Hj0SR VN3QEmyTRK8ld/jKYzddZoYpCfQCNS/NAOt+xUW9RGVvTNteM7vWPM/tQ+xPjA+f CVWnFhV19aVewYvXlZuhbw==; Received: from relay7.apple.com (relay7.apple.com [17.128.113.101]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail-in25.apple.com (Apple Secure Mail Relay) with SMTP id A4.63.14365.F3A527A5; Wed, 31 Jan 2018 16:07:27 -0800 (PST) X-AuditID: 11ab0219-e904d9e00000381d-d1-5a725a3f2ffa Received: from nwk-mmpp-sz13.apple.com (nwk-mmpp-sz13.apple.com [17.128.115.216]) by relay7.apple.com (Apple SCV relay) with SMTP id A8.EC.05443.F3A527A5; Wed, 31 Jan 2018 16:07:27 -0800 (PST) Content-transfer-encoding: 7BIT Received: from localhost ([17.226.23.225]) by nwk-mmpp-sz13.apple.com (Oracle Communications Messaging Server 8.0.2.1.20180104 64bit (built Jan 4 2018)) with ESMTPSA id <0P3G006DN30E15B0@nwk-mmpp-sz13.apple.com>; Wed, 31 Jan 2018 16:07:27 -0800 (PST) From: Christoph Paasch To: netdev@vger.kernel.org Cc: Eric Dumazet , Mat Martineau Subject: [RFC v2 02/14] tcp: Pass sock and skb to tcp_options_write Date: Wed, 31 Jan 2018 16:07:04 -0800 Message-id: <20180201000716.69301-3-cpaasch@apple.com> X-Mailer: git-send-email 2.16.1 In-reply-to: <20180201000716.69301-1-cpaasch@apple.com> References: <20180201000716.69301-1-cpaasch@apple.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprILMWRmVeSWpSXmKPExsUi2FCYqmsfVRRlMPu8ksXTY4/YLf629LN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XGpMEqINbGsuDIX6DcOZiUR3o0iRVFCvCmJlVWpRfnxRaU5qcWHGH2AbpvILCWanA+M kLySeENjC2NLEwsDAxNLMxMcwkrivEeUgGYJpCeWpGanphakFsGMY+LglGpgdPv578X5fYml OWovH4sYTnAtMvttlcnVonrGU/71xUa3v3pfBDo3fAxMj51XFPSI64JCw1SRufeO/9IJPM3w aW2j34HmvdVm1+6Wxxt9FlEunC1pYncgomkTi+7JygX251dXJLXcfPLYWLRJM2tS3fSi/n8x uy4/zOJ/cohV055r3lNNrktvlFiAycJQi7moOBEAquVar28CAAA= 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 df50c7dc1a43..e598bf54e3fb 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) { @@ -3248,7 +3252,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