Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp701867lqt; Thu, 6 Jun 2024 16:26:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWw+/AxqCu5P2IhjbqgNgnQ5DWdSOa5qW/v9BbmTSnSycynT1DLgIvNOKP3kumVV+uTSWY8YfhhPCnDbDz4yxban0ZvpkZjLJdsNa3ZSQ== X-Google-Smtp-Source: AGHT+IFwsTwLLmqtIc1HJTm5TB5Z86OpzIwYDE4xvMfaST/F0yzxD3zAuMi2fd8W9T7kULI2Mhht X-Received: by 2002:a17:907:7818:b0:a69:3fd:aed with SMTP id a640c23a62f3a-a6cbcccbe5fmr79457166b.32.1717716411971; Thu, 06 Jun 2024 16:26:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717716411; cv=pass; d=google.com; s=arc-20160816; b=roPixkfaqTJSHr+Nj18jeuSVAzCE/75qIyiZzdDFT07aYH9KGFc+TZdelZv7Ceaa8+ jDLV2QizlgbobdKc/DVzuSQAgqucS58mj8TlO1ytYp/d1r8w4BWSvLdblDVXgyoJ1J51 9Cm2yA4zDOT6k8riIdufxVaPzq1/TAKHIDyA5C3n0bvPvHPeOo2u861qp4SBHK0C6AUP bqoVfkoUStOv2m63s46iUb5NDzzmQlspAWWzdnIVi9jmjWYx9Fnc4i49SKMvS/sJx0nP 9KyrtuKCjPO6U6nQORnUbsmuTF6cCivdZpzEfL0wVw7RqRBo98knsgIRgVceDp/8OZKK K2Ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=yOM/OjRNYO54sCwVLlmRu5pjCfFUiRnU9SDO6I2KR48=; fh=Nedj/Vrt7g720fea/k+6nmkVAb0uLutxfpisOQ2NqiQ=; b=p+CaN6u8iwAcAkJ1edodHZ1AYDl0r1/p5T7ZYnw6nHccCUrCPOcE/4rKKFKXjQarux NR5q3JfzS/axIEnnlKVAJ3NT/nNwD5HqvI0n8GsR2AUDrSY+rsUvyO6i38RPAN0vY3q+ MUWepotdFCnZ1sGhw+kojIdx9ODPLWnjmXjgs7B1Toi3sMgi+DmcZMUzPFuQaAmUoUCZ 9ZPYz6FvwUE0uYt8PX4/mpEwITGV0xAFNb5mn1ENtkaiXL3ugRH59OdG2gB/obWhXy/p S14AoFWCCBzcqobgz+W/DUG76Q4xj7GDWqpagnjSbQMf1x0SKfXIGuybvTnED3FZvo4O itxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XkdECwNu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-205151-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205151-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c807493a7si125769766b.999.2024.06.06.16.26.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 16:26:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205151-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XkdECwNu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-205151-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205151-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 am.mirrors.kernel.org (Postfix) with ESMTPS id AEC7C1F263AB for ; Thu, 6 Jun 2024 23:26:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60E84144D29; Thu, 6 Jun 2024 23:26:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XkdECwNu" 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 6B16E26292; Thu, 6 Jun 2024 23:26:14 +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=1717716374; cv=none; b=noQF4GSRJqdyAdSLv+uyx2d27nhiF4XKiz/vCMyheCrALHKWIDD3mVgkQe3XAee+szgzwDMlLXuvjiYpc2p23F2BF9xerzPO7Nr3Q41S6cqq3vGFGc5qNAZC9XvbxQi8ZSaGbvWPJ3fLGaKHK+1RfTClNUiznQu8qLzXeVsZ6zA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717716374; c=relaxed/simple; bh=M+7owuWJKB1TcQGrX6ydAUMZphqPdvJHKkUxkJgNcS0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JstJPxbTFtheAqsUJmTnyMjhDjp6epM6s/d/gbUyVIN9I/dF35fCo9Zv3mvp5LSvqoNXiytl8CZPB1n9tIIvdq7AHbA98Vt5XK6vhjyNCnR1zYxNHOw+0SkSZoOC/fgrQvzE0XDSjwNLthKm88n/VlNvVs9sjmoGmRd+n+FXMys= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XkdECwNu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 1610CC32781; Thu, 6 Jun 2024 23:26:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717716374; bh=M+7owuWJKB1TcQGrX6ydAUMZphqPdvJHKkUxkJgNcS0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=XkdECwNufaNp2v5aRlxBq8p9Q8C+Cl5N6Zkf3YsSBupip+aOJRpcQRah0LlJuvdLk 91DLjETxnCrXxXXdl35ixmy557hRxZpf9XdcvwZRHchww7tz/5irTHtZEgcqaTIvdE 5cVM1h0XKpm4Kwh6pXOHgwLoUb5eMBxg2vdEWvgK5wSz4qHZkuYqEtzHK0M16UU51k b4BzCBNiokTMAw0I4+7mcB/napOuFDozd2bH42opSVgpVRxhu0grxR4BavS8YNhzJr 8/RczeMj/4yvA7e8L/WtRQLhfoncAz4C8qST16+odN5gHc76JGFNDBY4cZQrLnWp/V Ii8HmanXRj62w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02BEDC27C54; Thu, 6 Jun 2024 23:26:14 +0000 (UTC) From: Dmitry Safonov via B4 Relay Date: Fri, 07 Jun 2024 00:25:55 +0100 Subject: [PATCH net-next v4 1/6] net/tcp: Use static_branch_tcp_{md5,ao} to drop ifdefs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240607-tcp_ao-tracepoints-v4-1-88dc245c1f39@gmail.com> References: <20240607-tcp_ao-tracepoints-v4-0-88dc245c1f39@gmail.com> In-Reply-To: <20240607-tcp_ao-tracepoints-v4-0-88dc245c1f39@gmail.com> To: 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, Dmitry Safonov <0x7f454c46@gmail.com> X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717716372; l=2434; i=0x7f454c46@gmail.com; s=20240410; h=from:subject:message-id; bh=A+9VHh2Wjb1Lw7NYtMOuRJG+qPpXrhu2iaF3GgBb+QE=; b=w/5KE85UJNmKQBg00hYW6MZCqodcIzzoCoepeBt2fMkrGGCbgbcAkXfWJ8De5H+/UgEbIMHa7xWn lA9J34nWCKr+oTFgSQhjJ0ynhsMP7wMy8mrtsua1LOXrhJV/3kkH X-Developer-Key: i=0x7f454c46@gmail.com; a=ed25519; pk=cFSWovqtkx0HrT5O9jFCEC/Cef4DY8a2FPeqP4THeZQ= X-Endpoint-Received: by B4 Relay for 0x7f454c46@gmail.com/20240410 with auth_id=152 X-Original-From: Dmitry Safonov <0x7f454c46@gmail.com> Reply-To: 0x7f454c46@gmail.com From: Dmitry Safonov <0x7f454c46@gmail.com> It's possible to clean-up some ifdefs by hiding that tcp_{md5,ao}_needed static branch is defined and compiled only under related configs, since commit 4c8530dc7d7d ("net/tcp: Only produce AO/MD5 logs if there are any keys"). Reviewed-by: Eric Dumazet Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com> --- include/net/tcp.h | 14 ++++---------- net/ipv4/tcp_ipv4.c | 8 ++------ 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index a70fc39090fe..e5427b05129b 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -2386,21 +2386,15 @@ static inline void tcp_get_current_key(const struct sock *sk, static inline bool tcp_key_is_md5(const struct tcp_key *key) { -#ifdef CONFIG_TCP_MD5SIG - if (static_branch_unlikely(&tcp_md5_needed.key) && - key->type == TCP_KEY_MD5) - return true; -#endif + if (static_branch_tcp_md5()) + return key->type == TCP_KEY_MD5; return false; } static inline bool tcp_key_is_ao(const struct tcp_key *key) { -#ifdef CONFIG_TCP_AO - if (static_branch_unlikely(&tcp_ao_needed.key) && - key->type == TCP_KEY_AO) - return true; -#endif + if (static_branch_tcp_ao()) + return key->type == TCP_KEY_AO; return false; } diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 3613e08ca794..b36bfd64382f 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1054,12 +1054,10 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb) #else if (0) { #endif -#ifdef CONFIG_TCP_MD5SIG - } else if (static_branch_unlikely(&tcp_md5_needed.key)) { + } else if (static_branch_tcp_md5()) { key.md5_key = tcp_twsk_md5_key(tcptw); if (key.md5_key) key.type = TCP_KEY_MD5; -#endif } tcp_v4_send_ack(sk, skb, @@ -1128,8 +1126,7 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, #else if (0) { #endif -#ifdef CONFIG_TCP_MD5SIG - } else if (static_branch_unlikely(&tcp_md5_needed.key)) { + } else if (static_branch_tcp_md5()) { const union tcp_md5_addr *addr; int l3index; @@ -1138,7 +1135,6 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb, key.md5_key = tcp_md5_do_lookup(sk, l3index, addr, AF_INET); if (key.md5_key) key.type = TCP_KEY_MD5; -#endif } tcp_v4_send_ack(sk, skb, seq, -- 2.42.0