Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1141656lqt; Fri, 7 Jun 2024 09:06:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUaLg9bLWGP8COXSO9uwTkh6MFQ9oB4qJCsuTEZTpcvgftLY3xx6eKOqAukYGdxbgmhA8QRYUqPOEi7O4xl7zroeiXjz3z2MROv5LV64w== X-Google-Smtp-Source: AGHT+IG3guJzHkkIedO5EtSn7NSPHPhK5rHZHBwuGOBb7zjy+ZI9EatdxpMhLASE/31U1bkutd9k X-Received: by 2002:a05:6214:4a84:b0:6af:b6e1:5ed3 with SMTP id 6a1803df08f44-6b059bada7bmr37526886d6.28.1717776387889; Fri, 07 Jun 2024 09:06:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717776387; cv=pass; d=google.com; s=arc-20160816; b=whCRO0a/pEwNwHxrB94UrSIX3fPJv5R96IpEWji4vGIel7rnTb1+TslW1h4kg2DquH 4j8PwLa5t2ql1e3WG4gcQR+DWpEIoP8vIFTxUcUxUQwOm4Q9bH2igAbJA2u2+z+vkcpt 4vTM5aMwd1c3Fs+3/CduIKQ6DDDXGNWU850XtmL4oeRnws9Yvgafo2fFz8BfaMbrVT6J IwH1xOjH9wJKkGrt1CQaV+HOw7UZalpucmCmGpfonWeGSL/VVu6I0nz+QkbhUNmq4WrH hbs4Rl4anDrebGoUGi9QloAQND6F3DkF20ubX5XymbkCQ05Cl0QDnVV4kQuvxI/yK4O4 rnvQ== 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=HFqbvy+yDIcOAsvFP2JAPAHPKAhf7Z1A8lonQFVNw84=; fh=JN7tMyF6zC6ERZ5PXsr4V7IKiYp4vRUwR5tQFwkRxbI=; b=GNEPTISwnqid2mBVKTg/T72ax0l6bf9YpyQSvd9ffom47BGFptJYiFW8zt+v4uFL0j HTnDRkJkuwQBo+UjFcChplQP5epHWKtUfmCgxR1tBun0UaHSvI+0mnqAjPcw/Dn1RZPe nv5b1xxDC1QTnKyENhmlso1pjYCXsAIHD135dXwn9lT2l7awdqFAcY86LmB/PiAjO6fg +1eNHFLlLKdoxfiyCWS5Nb8E6uVWPUnN1iuXROVTTCY+OIqJUcBizFfZcE17RnD0LwQD 3oqSQXCTaLL0N0vcyLWjLn8QeMYhs80qMx+lZ6j4byA92my9TJBoDyQlGWUDc/3GIUDh yHLg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=YeyzoXCH; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-8703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8703-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6b06469977fsi8760206d6.563.2024.06.07.09.06.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 09:06:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=YeyzoXCH; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-8703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8703-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net 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 75D261C235CB for ; Fri, 7 Jun 2024 16:06:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDEB319B3CD; Fri, 7 Jun 2024 16:05:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="YeyzoXCH" X-Original-To: linux-wireless@vger.kernel.org Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (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 334DC199EBB; Fri, 7 Jun 2024 16:05:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717776337; cv=none; b=t9MAEXNUR75P+PZap1YFDNkkKjGrl4oVpXoVzkP43gYg5gCVGRXy2tH9ouQ9H7mNrEroYHCvsWmXFNT0XzJi5MONNrjW63C/QMTS/bcXErABv8Ks6wjCWkVkKrXIgisoFzO7cwb78WLhjjZpReb4mff0ZwyjnEVnZqPdxccP/XQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717776337; c=relaxed/simple; bh=z9L/VT5UsQCivJ6SxdEVOVB2wfbgOMAG2X9WckMrwEM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sQ7aiFRTc2sEfSTQL5Q9SKKSFnjifC9nSzkVcDCS3l4FTc06piueVTusPLOLniWhvrHxQG9kq5senp/i/QZd/4yDCGMYruhhzJhNRSPk4VovhooSUsoQ8eUnJtxPBdPlFnXXJp3jpvbgCKBDyeyJknP+68NW1U8c0ww14B4Pzug= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=YeyzoXCH; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=HFqbvy+yDIcOAsvFP2JAPAHPKAhf7Z1A8lonQFVNw84=; t=1717776336; x=1718985936; b=YeyzoXCHvwBq9JqcIH8YqjejXCDzHMmvGR+Uc23fbjKMMr4 wiZ8EM1oTna/rjFZT3pD2GaVpKS2L8e7Iu8aDAawGHTsu30X0tUGjpiAvuhZaVTNp+O32D87UHL6k EAaHphw+69MkJ+U4QcX4iNadwOsXfMkgLYP8vDi7YUBV92+mq7tDReosumgJGrmYtwkO7I+N3HBLd GaqBEmGl6f2lPvopT1F8BRl7+mx9ak6ah/og1iE3kmG8qYb/kv4daEYvvSpad3sQaprs3MVtHZvuc an6pcSgGGrbZlK3c/Vo5zG5Opk7goNH0GQrEJj293wE3H6RQGQYwcagc+9AXRFFw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1sFc5t-00000001Iyu-11vF; Fri, 07 Jun 2024 18:05:33 +0200 From: Johannes Berg To: linux-kernel@vger.kernel.org Cc: linux-trace-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Johannes Berg Subject: [PATCH v4 4/4] net: drop_monitor: use drop_reason_lookup() Date: Fri, 7 Jun 2024 18:04:26 +0200 Message-ID: <20240607160527.23624-10-johannes@sipsolutions.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240607160527.23624-6-johannes@sipsolutions.net> References: <20240607160527.23624-6-johannes@sipsolutions.net> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Johannes Berg Now that we have drop_reason_lookup(), we can just use it for drop_monitor as well, rather than exporting the list itself. Signed-off-by: Johannes Berg --- v3: - look up SKB_DROP_REASON_NOT_SPECIFIED if initial lookup returns NULL, to preserve previous behaviour --- include/net/dropreason.h | 4 ---- net/core/drop_monitor.c | 20 +++++--------------- net/core/skbuff.c | 6 +++--- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/include/net/dropreason.h b/include/net/dropreason.h index c157070b5303..0e2195ccf2cd 100644 --- a/include/net/dropreason.h +++ b/include/net/dropreason.h @@ -38,10 +38,6 @@ struct drop_reason_list { size_t n_reasons; }; -/* Note: due to dynamic registrations, access must be under RCU */ -extern const struct drop_reason_list __rcu * -drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM]; - #ifdef CONFIG_TRACEPOINTS const char *drop_reason_lookup(unsigned long long value); void drop_reason_show(struct seq_file *m); diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c index 430ed18f8584..fddf6b68bf06 100644 --- a/net/core/drop_monitor.c +++ b/net/core/drop_monitor.c @@ -610,9 +610,8 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb, size_t payload_len) { struct net_dm_skb_cb *cb = NET_DM_SKB_CB(skb); - const struct drop_reason_list *list = NULL; - unsigned int subsys, subsys_reason; char buf[NET_DM_MAX_SYMBOL_LEN]; + const char *reason_str; struct nlattr *attr; void *hdr; int rc; @@ -630,19 +629,10 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb, goto nla_put_failure; rcu_read_lock(); - subsys = u32_get_bits(cb->reason, SKB_DROP_REASON_SUBSYS_MASK); - if (subsys < SKB_DROP_REASON_SUBSYS_NUM) - list = rcu_dereference(drop_reasons_by_subsys[subsys]); - subsys_reason = cb->reason & ~SKB_DROP_REASON_SUBSYS_MASK; - if (!list || - subsys_reason >= list->n_reasons || - !list->reasons[subsys_reason] || - strlen(list->reasons[subsys_reason]) > NET_DM_MAX_REASON_LEN) { - list = rcu_dereference(drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_CORE]); - subsys_reason = SKB_DROP_REASON_NOT_SPECIFIED; - } - if (nla_put_string(msg, NET_DM_ATTR_REASON, - list->reasons[subsys_reason])) { + reason_str = drop_reason_lookup(cb->reason); + if (unlikely(!reason_str)) + reason_str = drop_reason_lookup(SKB_DROP_REASON_NOT_SPECIFIED); + if (nla_put_string(msg, NET_DM_ATTR_REASON, reason_str)) { rcu_read_unlock(); goto nla_put_failure; } diff --git a/net/core/skbuff.c b/net/core/skbuff.c index cd1ea6c3e0f8..bd4fb7410284 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -139,13 +139,11 @@ static const struct drop_reason_list drop_reasons_core = { .n_reasons = ARRAY_SIZE(drop_reasons), }; -const struct drop_reason_list __rcu * +static const struct drop_reason_list __rcu * drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM] = { [SKB_DROP_REASON_SUBSYS_CORE] = RCU_INITIALIZER(&drop_reasons_core), }; -EXPORT_SYMBOL(drop_reasons_by_subsys); -#ifdef CONFIG_TRACEPOINTS const char *drop_reason_lookup(unsigned long long value) { unsigned long long subsys_id = value >> SKB_DROP_REASON_SUBSYS_SHIFT; @@ -162,7 +160,9 @@ const char *drop_reason_lookup(unsigned long long value) return NULL; return subsys->reasons[reason]; } +EXPORT_SYMBOL(drop_reason_lookup); +#ifdef CONFIG_TRACEPOINTS void drop_reason_show(struct seq_file *m) { u32 subsys_id; -- 2.45.2