Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp656230lqs; Fri, 14 Jun 2024 01:21:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUsstjcxb9957gV5jDZK3JyR0eGNwN+I1CjiB9K3UHM5r21wMIXOK2l5N1Mi2sv3eiJkCaSNzB8FK5f82bVwpHIfx3svK8Lr6RBOGG50g== X-Google-Smtp-Source: AGHT+IFiEnQv1KoB+BG76/yatPEwfr33i2ANOXBpEt7ll4g5xiD+nb/GKWSyC5hgTNy/H6bZPb5t X-Received: by 2002:a50:d5c2:0:b0:57c:5ec6:1466 with SMTP id 4fb4d7f45d1cf-57cbd67dbdfmr1414874a12.25.1718353279339; Fri, 14 Jun 2024 01:21:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718353279; cv=pass; d=google.com; s=arc-20160816; b=kzD0cnTbF9SRJrEjnB2rn8c859C7QT0OchbfYHjXLFI2u/SBdaH+Nh4ZhaBn+9ze27 vstxRe6XxqkN6r8xu2d8hzTNb5yU8KPm7OxBgseftdv03PbMRyLaN/+kAyVUqdmF0u9/ 0EuedHu9SksxV3hbmKh8bHCELU+38f0YVyPaxOJy+A1dl/AowoQwUf248TAwv+z9I+ZO DUR66DIGjvy8XLHvbRzLpRWgD6hbTBCqrHkOIvH0rjf7PX9kHaFHmiHUCmV6jvTEnm1e L8Z/7XKAlLiNwb254SwzVqYAaVIJ3eDPG4EtbLd9KwNfMEuSAXMJP9+cfaSdlrOtF+Xy l/YA== 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=TrAYZuPQEFVMnNXXZezdUz7ROfmf8b3TzYo3Pat1VSqtwkdSXXNoSvd2CgOBTfIp9/ Tnes7jQcXyavW7f0DEZndvjDWRAdC4kizIG8tRulUky99FYX8n6izd6Cqt/GlAVBY/wS hOoe19lZKXzCU1KiYaxXP1lnH+itCD+h3nRoBG5JXEHPst/Mzxu99VNZrrYhscWEgxaM 1KYi6WhqWFiyzoATiiUrflgH5zhX6HPY7IYZG/8qVTUvrOCcOs7EtySRYFlpVV7xlBtQ VNCjs6uoDrJkxO0TWCh8Upf7q0rSDRIUV4+JDXcgeppf2WQ3tl/SohQOCFp3p43W2hMK J2TQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=CtNHeA4H; 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-9006-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-9006-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57cb7dba09csi1468797a12.222.2024.06.14.01.21.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 01:21:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-9006-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=@sipsolutions.net header.s=mail header.b=CtNHeA4H; 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-9006-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-9006-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E11761F26D14 for ; Fri, 14 Jun 2024 08:21:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CFFD187573; Fri, 14 Jun 2024 08:20:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="CtNHeA4H" 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 8C0F61850BF; Fri, 14 Jun 2024 08:20:04 +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=1718353206; cv=none; b=EioDFJX/XAD/1MEUe7JUB6hcpYMGZRfTD0/xShxXU6VOE4IqH7/RijVbT2QCGA03PG/CrlyAn8GgZEUYvrlZrrhyqN8YRbTIaolrOMSZa8oGqBCd+QOBTC9EKSWd38D6+T0t0wL7DvEY+akMS265yINf/n3sTm/AlFxlkt+lWe8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718353206; c=relaxed/simple; bh=z9L/VT5UsQCivJ6SxdEVOVB2wfbgOMAG2X9WckMrwEM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C+CHMr+Mb1coKkngK0xnq7lq0QQpEs/p9kn+hmldjXzb9bq4b3sC9OkMPFft6MIFvf+vvEUoqhhpB87GHyG5k+GcHdb7CAAiynLbNsOeLBEDEoI2VNwJIfbteij8gxsK57MKqUj7IwStWW6+aLMPpwjik4NyPLlMYXM725jJy6o= 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=CtNHeA4H; 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=1718353204; x=1719562804; b=CtNHeA4HdNSORwTQs0F3TdFV6MHv4gLQgovN6ohMSKUWxRg 3W+UNqOQgMufzp28Nx5WVkxV7P6gOH7rz/CRiJ9vWKhMhMCJZ0LlMigrYtNgR0FLAn6r8f+hSMVlp E4gr7FQPftNEgXIFKS70zAUYnHxBFurSdGLq/zmRMKdkXc2QscsgER5LJRplTd46k4+OzNTQ0b41j muhwOT95RPTwzImFROfZF4VVinHCYk9Fta5XXThn+cQtn9wpgpmVugsRIzNKx5jisymdARntpqIho 7pvrHIyh2BPwrL58pHaQMpoOsbcJ8s9EHdzxvCS8BWSrGGIln0MqFiHWkJvZn2jQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1sI2AD-0000000DZpq-37cZ; Fri, 14 Jun 2024 10:20:02 +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 v5 4/4] net: drop_monitor: use drop_reason_lookup() Date: Fri, 14 Jun 2024 10:19:16 +0200 Message-ID: <20240614081956.19832-9-johannes@sipsolutions.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240614081956.19832-6-johannes@sipsolutions.net> References: <20240614081956.19832-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