Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp72261lqt; Wed, 5 Jun 2024 17:59:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+pQy3NnnIfCM4QC0rZ1U66OX+dKfLcPngj2fA886+HGEIxqkVWv7JyPNYIeMyjk+3Kon6HZr5i0iZtlJJFdq2MuW0u5W3WBgvM3+ZgQ== X-Google-Smtp-Source: AGHT+IFLSE6HS3ljCObwfbTKRXGUKl+V0Qa4D+0KKQ9LSNwm9+p4YE5CR8x9jfo3Kbf6I6tPRwwl X-Received: by 2002:a17:907:c85:b0:a6a:7e39:2a3c with SMTP id a640c23a62f3a-a6a7e39380amr162301766b.48.1717635562237; Wed, 05 Jun 2024 17:59:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717635562; cv=pass; d=google.com; s=arc-20160816; b=pjS3FmUH/PlcxOYrsBAHfllbsO/hpmbzckuiPtTIVC5iVcT6foOS7Hg8tC9GFcoQh2 CzCFojPT3+STwvoFsj3YGWubdXu74iPrHcwEQh92UEhPl7kNox3fm6SY6fsjhVQdVO71 /CiLlhw4NrG2p88OJDiMxnoo2xQ4tvHkUACCmQqgYH36g9Toxe0l5FVhISRgiX8ChYeq LWU4Vd8wRpgmyQZQa5WuQJHfX4+Ye8/EMjZ22uxN5UDLtNBB/4Ul1mAQ3Zprok+N1nx0 3n0Jw+tHBSHtD2n88/yS8z/DsQn1pbuNLQSMmIPEq7OMvhibqyg7YnZ6+XZfK9XGqwLh bgmw== 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=cXCDx5V6hlKY0ccQT9GoviPVC4ucUUOE/sMudpxADsCsm7XmwMgvmScZwuN/ClRxpY xRLAOVtMPY/V0JuJ3t+V9+ffc0TyIlQIvvj6XCQikzhGMZzLedK3ON13l/v0eh06ZoYk uI0G6fbsgql3QaBSE72YVRewuq0BwRfu95WNQXjaoTWDBpgeZXcKUUR0jdxgotrRg/Up i3JtpLglpQhHPtSrJSxDcjR3l2P0/cEzQYhQiFfG6/Xsyhj0QbB32GHF4/EI3Iou8T1u kMJ4FCGccr81uaZZ0jKGBpvLez9h1fmde1kZpNw2ZWMuhNs6jzC2K0khzse/dzVTZiWz 0VNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P15oJyyi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-203480-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203480-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-a6c80581ce5si11334266b.38.2024.06.05.17.59.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 17:59:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203480-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=P15oJyyi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-203480-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203480-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 BE5CB1F245A6 for ; Thu, 6 Jun 2024 00:59:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B6C51BC20; Thu, 6 Jun 2024 00:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P15oJyyi" 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 436B8CA64; Thu, 6 Jun 2024 00:58:30 +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=1717635511; cv=none; b=DISPp7AJgipxr0OBzHe/C+MCA6TYHBZ7pQ1wyQHaBfQumBgEEhqeAFpBt8vLNOpNPCq25UzEZW+WnXoo4nzxq/3O5vWT4WiFBplblDTnsryNrYLRZfRZWODXJTzgVAa5m3PG1cLBhnKOY66c+uHBOqOGrKkMzOj0wjHSUS1p35g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717635511; c=relaxed/simple; bh=M+7owuWJKB1TcQGrX6ydAUMZphqPdvJHKkUxkJgNcS0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E3lGyDcE1EOs0mxgYNyneDsyKb3FA5fE1KcWwNQe7TFJha8wsorqOdJehETl+nrBfm90Tc1j9oqrxN+P/Rh6+lusFsrGEFxETJFO3rOa5HpBBoKGGac/GqAxKU2xXKiNLDFpZsh8MMMNfGITsARRqETURUrtnQrdPhaqDPsj5aM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P15oJyyi; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id A6EE0C32786; Thu, 6 Jun 2024 00:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717635510; bh=M+7owuWJKB1TcQGrX6ydAUMZphqPdvJHKkUxkJgNcS0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=P15oJyyiiYyVQ7pObcgODIUbWnZ0X2Vb8AlcwrObY0bKbbboFfvo9WgMVjg+RzfKD vbfEoid+Wtt4lpgi/cJ9H4lfqhKpTLbc2O21jSQ87H7q2HI8ddfj2sfKHdyv3NwOyw xj4Yj7iRIU0H+CAFJAc40c3FxwhAqkfJogOrBu3cJiGnLxMfkSpjPO4WOmd5ijCiCP iHRuaSejqEishMUF6aanHmUzHW3dOsVMnZcprMdHr0xIAQhV9KBaBnwouG41HeKqUE lBAxhokkanEDjuG3jHLfQD2YRJHMSD2d4F/GuG0vnBkJa+5nqP6+pF5xQOcs0hXiTo bXc/jzDBZgP8w== 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 8DA22C27C53; Thu, 6 Jun 2024 00:58:30 +0000 (UTC) From: Dmitry Safonov via B4 Relay Date: Thu, 06 Jun 2024 01:58:18 +0100 Subject: [PATCH net-next v3 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: <20240606-tcp_ao-tracepoints-v3-1-13621988c09f@gmail.com> References: <20240606-tcp_ao-tracepoints-v3-0-13621988c09f@gmail.com> In-Reply-To: <20240606-tcp_ao-tracepoints-v3-0-13621988c09f@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=1717635508; l=2434; i=0x7f454c46@gmail.com; s=20240410; h=from:subject:message-id; bh=A+9VHh2Wjb1Lw7NYtMOuRJG+qPpXrhu2iaF3GgBb+QE=; b=MCMtuXR3ptmAVjLy1xb4OSwJnmGn47nX3fU02e6GW7Gr6tLyf59HRUQ2a8R8qm0CrynCMyp0vaTk T1XblNqQDbuyQSz74TIIohG5rzLmrB894f2H5QmJZQfYa1LFNEdd 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