Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp306414rbb; Sat, 24 Feb 2024 01:05:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVYk4WhV8/iQOxrC4Qyd1CVD5Ee6rvVjCkCZ09QCw+mAR787YdnjuUfa0Cb/q4sl6gtCUhA79IUmqeuDZgTBQw8l1LYslEAqGyaoIWEtg== X-Google-Smtp-Source: AGHT+IHP42bq0I9NIuz9oyqJqufdO+ORNSL17YHEK4o+NxiP7J0JhyecahccsrKGrHnhYJged81x X-Received: by 2002:a17:906:fcca:b0:a40:18ad:3fcc with SMTP id qx10-20020a170906fcca00b00a4018ad3fccmr1037142ejb.36.1708765508927; Sat, 24 Feb 2024 01:05:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708765508; cv=pass; d=google.com; s=arc-20160816; b=nFDx2nF/WliT31AVIrToXb60WTdBSJ9NahqO9Ssoy/DdUkkmVzA1OvvoZ4+VUckU72 quU0v4kWmeD3/rRUE/GA7ji2Ed2y1ibweCsLe+YdQsrstpZdEAKN6DRZlPDtXk8Hz7kj sl3CSs06exS7sM0rediAAQYEc+vAW82L/38/SVXaWLljGpvTzd4m0ppde2Y4FTPSQo3I JhacJv3jGDTHJAOVW6cB30zQfnIkJw5PE3GqSRaoiNZXU7s/SFUXPuPIaE/n7KAqrJsk ZjodT8X8dmMPgtSnBgDhRQ4YAE3yACL+d12M3v9dKC2YYzbjSGYlyvMCu8KDFcFlhagC 7zOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uHrQr/XJfBtNje1BbDqA25SZP6hUvJlYF/SVh1AtKWc=; fh=kMQ/iNfUdxzHmTS0Nyg8iBokS7AbeuTz9GdytRGxy+I=; b=DOZVCiw//xzKhA7mOn8j7VViId06YNTQeNFGvuD8QXoTcxX6wmoMatdjfnNLOAdZgW +G7yrhHnR1TUn+uCY8i64ZNbApXdabKqjcAUeDXn43gJObWNRTTIswguRWVwE17wLl3U /zIrWm+1SZsHx5TjrD2gcVqsVRZf0i4AVb7F3YQDg9Mhd+9B/kw3SApHm7DT1QmuutUX MwsWJIEf4T+U/J8I7PDjhIS8dEL697BMGMGUM74e/T879mFUPa72dpvmSTGg0xdJ1A9+ lU/zUXfVjviX1mOK6jVhELBucCdYcSd++oEYVzErWzqZ4ce4f2r1LAmbhjuRoidWNJSJ CWzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=eI8XeX+w; arc=pass (i=1 spf=pass spfdomain=arista.com dkim=pass dkdomain=arista.com dmarc=pass fromdomain=arista.com); spf=pass (google.com: domain of linux-kernel+bounces-79521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79521-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bk15-20020a170906b0cf00b00a3eefaec75fsi358783ejb.76.2024.02.24.01.05.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 01:05:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79521-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=@arista.com header.s=google header.b=eI8XeX+w; arc=pass (i=1 spf=pass spfdomain=arista.com dkim=pass dkdomain=arista.com dmarc=pass fromdomain=arista.com); spf=pass (google.com: domain of linux-kernel+bounces-79521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79521-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com 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 50F241F23B3A for ; Sat, 24 Feb 2024 09:05:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E30D01AADF; Sat, 24 Feb 2024 09:04:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b="eI8XeX+w" Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36CB417BA5 for ; Sat, 24 Feb 2024 09:04:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708765487; cv=none; b=rFK/z9I2RfRlH8/RKCp7znzVq1G7jwq8b0jNx4fflQanWWlwkx9Py7pQw+qkIvp2UY7IPcnYSvXQlv6bWEwjMAOVxrI11tMTuKwM1TaLtLMF8NSUVIcG7FfINRRhLe5M8FnYQPfGlRsiw3ELy/Y0nry+rh30fVkVU+Nxcpbm2Qo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708765487; c=relaxed/simple; bh=ZnGxdQGJy1ClaaFcPFlryVbb4hGecUZML2DaP2kkzLg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HmngIZmjZb6Lq/wkSRB88RS51lM2HZztHjM10u1KHXAz4tZqWB8dSIa+O69BiyLlgqV6VDLOtG7y53Zv2j6UZfTysvbIpboOCs/nQOg+TdWobPoF6KJ9RU9tM/UTX7u7FWuTsN5gxsryZV4bU0WxbQlM+1qTECuUtX899gogiDU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=arista.com; spf=pass smtp.mailfrom=arista.com; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b=eI8XeX+w; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=arista.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arista.com Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4129ed6f514so644125e9.1 for ; Sat, 24 Feb 2024 01:04:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1708765483; x=1709370283; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uHrQr/XJfBtNje1BbDqA25SZP6hUvJlYF/SVh1AtKWc=; b=eI8XeX+wRqalUFQitMgR1L6d2VjXQSZ1tPvZas+cPzBwtLoIx+IULGFFduuUVL8fnz zKXLxO5/OIAsQQTMiCHvIa1DFIyQSVTRN3h65jE1DbicXJwmo1YILfNcgK5fmRAcXNef rmhxndqrnOksZLIBBGSxBFVBh0mWueMNxl4QUPcy7uQz70Cuxi1m2NqXpXPmq9va9td0 2NnWd/mAp8BeLSVcrS0PzRtGBzxpwhzMaj3wHib87U8dRZMJwcd0Ixr5VWsrrew39EFy 3PAE5cqX2IyMnj2YH7rwo9lb7jJyF0b5kaTifLDunHjiG+N9vV4E/eG6VoLb0S6TycP8 BMdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708765483; x=1709370283; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uHrQr/XJfBtNje1BbDqA25SZP6hUvJlYF/SVh1AtKWc=; b=mGYCozAxPUD9JGko/o4J1nbaQ7PndrxPPDWhD8akDDEg2xYyGQJSkGrifIWmbg8VDF kruRLNNtm7sTmK9AG1g6lXQJ7wpluKRpZT6kSxFIG1H8qJ5NTKAa4O4m5VY78GLw3PUm sOO+vAxOPqK6mLrKl4OB4HLm4RJv754wO+mp05BlOak9kvzJGLEJV9lHPDzQgcXdYB7Y dt8dN0G49ASXSRsCfwn/lAIK4TGLFB193zJpR4upERj6rOPbKo2wrfb1DQOGbSzuhFc4 WB4IttAQwubFolTyB1q9rYw4tc25z3FY8g3mm7IcQ3766481kzLbcd7/s5dIDrsM2AV0 NpDQ== X-Forwarded-Encrypted: i=1; AJvYcCUJXzVeP65KlwaKOyCVlnsFGrMkTHAa+zfNwto2HQ7KeZ4lDdCw+un/+nKeXrsr3CH2JhHgxow3LrEh429z4XVVhzlboa85VGnt9gP6 X-Gm-Message-State: AOJu0YyldoX3fze0POEtEb3ur4vJ+HRY4HbWl1D9CIGY+4J9i607Ps4x +CPd+k7DgQVsJzPwgzCCv6LW/e/6VlsqNSUt3oNceSip88GptzuteihFTajmng== X-Received: by 2002:a05:600c:5109:b0:412:610f:c2e7 with SMTP id o9-20020a05600c510900b00412610fc2e7mr1544855wms.41.1708765483493; Sat, 24 Feb 2024 01:04:43 -0800 (PST) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id m6-20020a7bce06000000b00410bca333b7sm5320593wmc.27.2024.02.24.01.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 01:04:42 -0800 (PST) From: Dmitry Safonov To: Eric Dumazet , "David S. Miller" , Jakub Kicinski , Paolo Abeni , David Ahern , Shuah Khan , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: Dmitry Safonov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Dmitry Safonov <0x7f454c46@gmail.com> Subject: [PATCH net-next 01/10] net/tcp: Use static_branch_tcp_{md5,ao} to drop ifdefs Date: Sat, 24 Feb 2024 09:04:09 +0000 Message-ID: <20240224-tcp-ao-tracepoints-v1-1-15f31b7f30a7@arista.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240224-tcp-ao-tracepoints-v1-0-15f31b7f30a7@arista.com> References: <20240224-tcp-ao-tracepoints-v1-0-15f31b7f30a7@arista.com> 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" X-Mailer: b4 0.13-dev-b6b4b X-Developer-Signature: v=1; a=ed25519-sha256; t=1708765347; l=2366; i=dima@arista.com; s=20231212; h=from:subject:message-id; bh=ZnGxdQGJy1ClaaFcPFlryVbb4hGecUZML2DaP2kkzLg=; b=YSWRW5wa+c4zamP9YG0WiY8b3kvQg+Hs5tBhsFDlmGdWW+fFHBs58d2MLzy98VPbD0bMlZuKP 7VdCGuaclWIDZ9N+RulWTS1iDcO0YMqwrD005kHZ5vXbl8FA7sDewrN X-Developer-Key: i=dima@arista.com; a=ed25519; pk=hXINUhX25b0D/zWBKvd6zkvH7W2rcwh/CH6cjEa3OTk= Content-Transfer-Encoding: 8bit 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"). Signed-off-by: Dmitry Safonov --- 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 33bf92dff0af..c1fff9207e2d 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -2369,21 +2369,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 0c50c5a32b84..56dfae81c671 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1050,12 +1050,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, @@ -1124,8 +1122,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; @@ -1134,7 +1131,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 } /* RFC 7323 2.3 -- 2.43.0