Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp246165lqt; Thu, 6 Jun 2024 02:16:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVFszcTfoPJRRBnjOrTqhmiv1WJ7jPHVzQz4+KIW6k9iWEhJRW0DgZIbOqAd7x2rY0ACV/ycfeNNw3BfmqJyw7rVOvGZ/HDeiVKc7vhdw== X-Google-Smtp-Source: AGHT+IEsRxku5bdLCIH8UMbCiQo/TNyWTcHSZdA0BNcryXAzvFOqU76CAa1IqC218uz6xDJIci5x X-Received: by 2002:a05:620a:c46:b0:792:949d:bb0 with SMTP id af79cd13be357-79523ec2700mr652042985a.47.1717665415382; Thu, 06 Jun 2024 02:16:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717665415; cv=pass; d=google.com; s=arc-20160816; b=H4UvzYcN6FN0I9PCsbNgaKCF/TZRX+nG4klEPl6ya2N0kvXAz8tmUREHqc9wGvS9k8 elxsWSRPNhW8zIKJCYltmSx3WHnThczNF8KPaW5p6rReGigCCrx18iWv6dc7j6DKptgy uEs3j8DGO63AAw+DFD6sOmhbsA/8/EnqlZAvdZcV5AdcdrjztHPZfHhSwkKL+X2Jbkx+ VNXPHcE0Zfc582oog94oTrmMbUVVm0i7T/nxl1f8Oh+H4yHP4TKUX3m44cqRsvXDl0p6 QmWsRN7TYjHi4KXrSMM4GtpEPTRCRHMCNJg4b6mEnxbenOGnaw87mgbV4GTIcKsU4GKc MMwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=w7qOpzjmdEdYnKfAJPjp25RftihjvkYu7fQEwDvR2bA=; fh=/y7WjrUdNx74QTxOs/vk9Oad7i84A4V8UThYYoDdJic=; b=WTqM9aIv4mpRiXgMCp1QH1iduY3YB/WfkIKKU6DdzRx6OORgRGHA72W6qBXunlYDP9 dOCWA/jtf407GKhDcRTEBbL8cRMmJSAlbotpsGthrIk/rO9HwXNOGuqeZJ0Ggprz+7Im M9O/7oHQkrgMeSKHjbgIhLF0xEmv3TgnOegxAMtUUDr8GAmmNwOFILkXvt278T5Ku/yj MKWeDuROvoxHXI/IFVZcenz/UY3Bjpikly/X8lol5txnp2oQFk1GXaIEoiHAshhrxBzC lbnrlT9nNPQeSdkLtsYPs8Alwbc9n0+CMWjk9B1Yzl74Spb97Zr7IzLKb1/EGeGLvJkV Prpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ju8sxcUF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-203959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203959-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-44038a70179si11228131cf.22.2024.06.06.02.16.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 02:16:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ju8sxcUF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-203959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203959-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 059721C21E18 for ; Thu, 6 Jun 2024 09:16:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ECFC7152504; Thu, 6 Jun 2024 09:11:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ju8sxcUF" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB18313E03C; Thu, 6 Jun 2024 09:11:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717665116; cv=none; b=rphVHB+vVthnpcko8HCjklXbg69K1NA9t2UNRrFkFgHpAvowIDtmMcOMHwuuUaa7ROsfumY+OUlV3dWJAtwinsAhOckPbXljG6zmtSfgWcTyqpiG7Zk+i5lvIYzEbdvzbAZVuzRqmBoXN/bC8J25JEEzvspBUvxhniO1Pbi46V4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717665116; c=relaxed/simple; bh=eC5wX2eAW1HqPpt0NLbi0EUof17svVNQi4hnTqBuM1Y=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Tl8lLTBW/YTAqhIoaAMu+tGqXEe4FrJ6Cm7BL4o9rMoMHcXELBTgtJpszf41rYEPz+Yi3Z7WS9izTj1OU4gcyRlflWU+iqvv7NvjyDRLqecwMua03oTaNbH70LcTGBFYhEsr/sAId4LFwmKRfQd+D7y3ZabuhCzFhQ1R5aZeG2o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ju8sxcUF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D2F0C2BD10; Thu, 6 Jun 2024 09:11:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717665116; bh=eC5wX2eAW1HqPpt0NLbi0EUof17svVNQi4hnTqBuM1Y=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Ju8sxcUFv/x6oSnDewNWGfttFoWiXZaGTGlTQrjw2RjVabkmKyvBgzrGPeLIhX48z 9hskYqu2ZuB5QgVA/vmbFcqdWAG6DzIjl+U9Yt4qTKOShiQSvKR4zg1B1O5wvcwUlM /wTbxKmT3X0RXSc1IWpQJRvz7k1PENGFEyOQs96mJNvD9ZLaKuzZ5FHKtBvtQQcseE LVTNi3AmvyqQNRUmS1o+cmcjkYrQ8w/ZL/Q8vSslkitlRaq14/6T2ZOU5+t9UdIj4u zV+JBQcqcJgF3agocC7dggwuEnCK9HD+KzT7bQIV6jBSxu1QXkqfPt7GUEzLcUUgaY QsZ9BdWs/VXZw== Message-ID: <92c1cb53-ec2b-4153-b97d-c2b8c0fdfaf2@kernel.org> Date: Thu, 6 Jun 2024 11:11:38 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH net-next v3 3/6] net/tcp: Move tcp_inbound_hash() from headers Content-Language: en-GB To: 0x7f454c46@gmail.com, Eric Dumazet , "David S. Miller" , Jakub Kicinski , Paolo Abeni , David Ahern , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet Cc: Mohammad Nassiri , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org References: <20240606-tcp_ao-tracepoints-v3-0-13621988c09f@gmail.com> <20240606-tcp_ao-tracepoints-v3-3-13621988c09f@gmail.com> From: Matthieu Baerts Autocrypt: addr=matttbe@kernel.org; keydata= xsFNBFXj+ekBEADxVr99p2guPcqHFeI/JcFxls6KibzyZD5TQTyfuYlzEp7C7A9swoK5iCvf YBNdx5Xl74NLSgx6y/1NiMQGuKeu+2BmtnkiGxBNanfXcnl4L4Lzz+iXBvvbtCbynnnqDDqU c7SPFMpMesgpcu1xFt0F6bcxE+0ojRtSCZ5HDElKlHJNYtD1uwY4UYVGWUGCF/+cY1YLmtfb WdNb/SFo+Mp0HItfBC12qtDIXYvbfNUGVnA5jXeWMEyYhSNktLnpDL2gBUCsdbkov5VjiOX7 CRTkX0UgNWRjyFZwThaZADEvAOo12M5uSBk7h07yJ97gqvBtcx45IsJwfUJE4hy8qZqsA62A nTRflBvp647IXAiCcwWsEgE5AXKwA3aL6dcpVR17JXJ6nwHHnslVi8WesiqzUI9sbO/hXeXw TDSB+YhErbNOxvHqCzZEnGAAFf6ges26fRVyuU119AzO40sjdLV0l6LE7GshddyazWZf0iac nEhX9NKxGnuhMu5SXmo2poIQttJuYAvTVUNwQVEx/0yY5xmiuyqvXa+XT7NKJkOZSiAPlNt6 VffjgOP62S7M9wDShUghN3F7CPOrrRsOHWO/l6I/qJdUMW+MHSFYPfYiFXoLUZyPvNVCYSgs 3oQaFhHapq1f345XBtfG3fOYp1K2wTXd4ThFraTLl8PHxCn4ywARAQABzSRNYXR0aGlldSBC YWVydHMgPG1hdHR0YmVAa2VybmVsLm9yZz7CwZEEEwEIADsCGwMFCwkIBwIGFQoJCAsCBBYC AwECHgECF4AWIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZUDpDAIZAQAKCRD2t4JPQmmgcz33 EACjROM3nj9FG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IP Qox7mAPznyKyXEfG+0rrVseZSEssKmY01IsgwwbmN9ZcqUKYNhjv67WMX7tNwiVbSrGLZoqf Xlgw4aAdnIMQyTW8nE6hH/Iwqay4S2str4HZtWwyWLitk7N+e+vxuK5qto4AxtB7VdimvKUs x6kQO5F3YWcC3vCXCgPwyV8133+fIR2L81R1L1q3swaEuh95vWj6iskxeNWSTyFAVKYYVskG V+OTtB71P1XCnb6AJCW9cKpC25+zxQqD2Zy0dK3u2RuKErajKBa/YWzuSaKAOkneFxG3LJIv Hl7iqPF+JDCjB5sAEQEAAcLBXwQYAQIACQUCVeP56QIbDAAKCRD2t4JPQmmgc5VnD/9YgbCr HR1FbMbm7td54UrYvZV/i7m3dIQNXK2e+Cbv5PXf19ce3XluaE+wA8D+vnIW5mbAAiojt3Mb 6p0WJS3QzbObzHNgAp3zy/L4lXwc6WW5vnpWAzqXFHP8D9PTpqvBALbXqL06smP47JqbyQxj Xf7D2rrPeIqbYmVY9da1KzMOVf3gReazYa89zZSdVkMojfWsbq05zwYU+SCWS3NiyF6QghbW voxbFwX1i/0xRwJiX9NNbRj1huVKQuS4W7rbWA87TrVQPXUAdkyd7FRYICNW+0gddysIwPoa KrLfx3Ba6Rpx0JznbrVOtXlihjl4KV8mtOPjYDY9u+8x412xXnlGl6AC4HLu2F3ECkamY4G6 UxejX+E6vW6Xe4n7H+rEX5UFgPRdYkS1TA/X3nMen9bouxNsvIJv7C6adZmMHqu/2azX7S7I vrxxySzOw9GxjoVTuzWMKWpDGP8n71IFeOot8JuPZtJ8omz+DZel+WCNZMVdVNLPOd5frqOv mpz0VhFAlNTjU1Vy0CnuxX3AM51J8dpdNyG0S8rADh6C8AKCDOfUstpq28/6oTaQv7QZdge0 JY6dglzGKnCi/zsmp2+1w559frz4+IC7j/igvJGX4KDDKUs0mlld8J2u2sBXv7CGxdzQoHaz lzVbFe7fduHbABmYz9cefQpO7wDE/Q== Organization: NGI0 Core In-Reply-To: <20240606-tcp_ao-tracepoints-v3-3-13621988c09f@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi Dmitry, On 06/06/2024 02:58, Dmitry Safonov via B4 Relay wrote: > From: Dmitry Safonov <0x7f454c46@gmail.com> > > Two reasons: > 1. It's grown up enough > 2. In order to not do header spaghetti by including > , which is necessary for TCP tracepoints. > > While at it, unexport and make static tcp_inbound_ao_hash(). Thank you for working on this. > Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com> > --- > include/net/tcp.h | 78 +++---------------------------------------------------- > net/ipv4/tcp.c | 66 ++++++++++++++++++++++++++++++++++++++++++++-- > 2 files changed, 68 insertions(+), 76 deletions(-) > > diff --git a/include/net/tcp.h b/include/net/tcp.h > index e5427b05129b..2aac11e7e1cc 100644 > --- a/include/net/tcp.h > +++ b/include/net/tcp.h > @@ -1863,12 +1863,6 @@ tcp_md5_do_lookup_any_l3index(const struct sock *sk, > return __tcp_md5_do_lookup(sk, 0, addr, family, true); > } > > -enum skb_drop_reason > -tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb, > - const void *saddr, const void *daddr, > - int family, int l3index, const __u8 *hash_location); > - > - > #define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_key) > #else > static inline struct tcp_md5sig_key * > @@ -1885,13 +1879,6 @@ tcp_md5_do_lookup_any_l3index(const struct sock *sk, > return NULL; > } > > -static inline enum skb_drop_reason > -tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb, > - const void *saddr, const void *daddr, > - int family, int l3index, const __u8 *hash_location) > -{ > - return SKB_NOT_DROPPED_YET; > -} It looks like this no-op is still needed, please see below. > #define tcp_twsk_md5_key(twsk) NULL > #endif > (...) > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c > index fa43aaacd92b..80ed5c099f11 100644 > --- a/net/ipv4/tcp.c > +++ b/net/ipv4/tcp.c > @@ -4456,7 +4456,7 @@ int tcp_md5_hash_key(struct tcp_sigpool *hp, > EXPORT_SYMBOL(tcp_md5_hash_key); > > /* Called with rcu_read_lock() */ > -enum skb_drop_reason > +static enum skb_drop_reason > tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb, > const void *saddr, const void *daddr, > int family, int l3index, const __u8 *hash_location) > @@ -4510,10 +4510,72 @@ tcp_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb, > } > return SKB_NOT_DROPPED_YET; > } > -EXPORT_SYMBOL(tcp_inbound_md5_hash); > > #endif > > +/* Called with rcu_read_lock() */ > +enum skb_drop_reason > +tcp_inbound_hash(struct sock *sk, const struct request_sock *req, > + const struct sk_buff *skb, > + const void *saddr, const void *daddr, > + int family, int dif, int sdif) > +{ > + const struct tcphdr *th = tcp_hdr(skb); > + const struct tcp_ao_hdr *aoh; > + const __u8 *md5_location; > + int l3index; > + > + /* Invalid option or two times meet any of auth options */ > + if (tcp_parse_auth_options(th, &md5_location, &aoh)) { > + tcp_hash_fail("TCP segment has incorrect auth options set", > + family, skb, ""); > + return SKB_DROP_REASON_TCP_AUTH_HDR; > + } > + > + if (req) { > + if (tcp_rsk_used_ao(req) != !!aoh) { > + NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPAOBAD); > + tcp_hash_fail("TCP connection can't start/end using TCP-AO", > + family, skb, "%s", > + !aoh ? "missing AO" : "AO signed"); > + return SKB_DROP_REASON_TCP_AOFAILURE; > + } > + } > + > + /* sdif set, means packet ingressed via a device > + * in an L3 domain and dif is set to the l3mdev > + */ > + l3index = sdif ? dif : 0; > + > + /* Fast path: unsigned segments */ > + if (likely(!md5_location && !aoh)) { > + /* Drop if there's TCP-MD5 or TCP-AO key with any rcvid/sndid > + * for the remote peer. On TCP-AO established connection > + * the last key is impossible to remove, so there's > + * always at least one current_key. > + */ > + if (tcp_ao_required(sk, saddr, family, l3index, true)) { > + tcp_hash_fail("AO hash is required, but not found", > + family, skb, "L3 index %d", l3index); > + return SKB_DROP_REASON_TCP_AONOTFOUND; > + } > + if (unlikely(tcp_md5_do_lookup(sk, l3index, saddr, family))) { > + NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5NOTFOUND); > + tcp_hash_fail("MD5 Hash not found", > + family, skb, "L3 index %d", l3index); > + return SKB_DROP_REASON_TCP_MD5NOTFOUND; > + } > + return SKB_NOT_DROPPED_YET; > + } > + > + if (aoh) > + return tcp_inbound_ao_hash(sk, skb, family, req, l3index, aoh); > + > + return tcp_inbound_md5_hash(sk, skb, saddr, daddr, family, > + l3index, md5_location); Many selftests are currently failing [1] because of this line: if CONFIG_TCP_MD5SIG is not defined -- which is currently the case in many selftests: tc, mptcp, forwarding, netfilter, drivers, etc. -- then this tcp_inbound_md5_hash() function is not defined: > net/ipv4/tcp.c: In function ‘tcp_inbound_hash’: > net/ipv4/tcp.c:4570:16: error: implicit declaration of function ‘tcp_inbound_md5_hash’; did you mean ‘tcp_inbound_ao_hash’? [-Werror=implicit-function-declaration] > 4570 | return tcp_inbound_md5_hash(sk, skb, saddr, daddr, family, > | ^~~~~~~~~~~~~~~~~~~~ > | tcp_inbound_ao_hash Do you (or any maintainers) mind replying to this email with this line [2] so future builds from the CI will no longer pick-up this series? pw-bot: changes-requested [1] https://netdev.bots.linux.dev/contest.html?pw-n=0&branch=net-next-2024-06-06--06-00&test=build [2] https://docs.kernel.org/process/maintainer-netdev.html#updating-patch-status Cheers, Matt -- Sponsored by the NGI0 Core fund.