Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp633206lqt; Thu, 6 Jun 2024 13:34:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXQBNB48w5lxy4Ms5RFrqJBzL0bCuDQNlOGUSMy3NFtRJR7h/zVI7wqeZ9AAsXZ1YFirfdH7tkDdh50rtcKHizUrOOinEfBZT9a9Wc7gA== X-Google-Smtp-Source: AGHT+IFNqsbPBnkAtDdpw9OSIGo0ytnb1LNWDllDKd9tullkiA6iiWAeq+YzpUGNhRNJ0DYVV9I0 X-Received: by 2002:a50:8d4f:0:b0:575:954:7ef with SMTP id 4fb4d7f45d1cf-57c5086672fmr265043a12.3.1717706079074; Thu, 06 Jun 2024 13:34:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717706079; cv=pass; d=google.com; s=arc-20160816; b=HexVKBmlv58WCXzqeUUSSByik9f/KcOLaJtf/lwbcB7CKCp+S6wxgE4KPsEXFZL/sZ SglcL9qBLW8G2A+24iOntiOcOwCTF7VSbSlaZFEUwresX2TSF9pEsZ1mLFanyMSAwwzK S2jE8whETrU1Vu+N+tGGs45PcfDaeHGucw29RbS/3SAriLt+mx5qoX1I7n5Sf8OHzE17 KAZ0kPMQ62vGWnoyx0+hBPdJfdgeaqwqtomT0IYDWEIS7X7hmYqrs9/5Tq5C0afxi6rf k59X2GtcHI1/MAL18nKo6dSDqxSNEHbh2gScdFCg4AxrlRolR+EaMXj4SGfUA56i4Xvs YNxQ== 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=wH4qzpwIFO32RLV7tQSPATNkfLQ4Pd/Kex9TJqhUJBg=; fh=JN7tMyF6zC6ERZ5PXsr4V7IKiYp4vRUwR5tQFwkRxbI=; b=qtYBbBg73MrrsM/ugZ210WlPxrQ7hh0fUorUGWysSrq+xzQDWmxcBifaU7lcuB9q7q w19BrMHbiT2t5aa+axq3BQGyFoo7cOqvmxfJOErp1+iNGonAUxOHtAHpTp78Uvo1XuKk Wz7Rgs9JPhYkcKMGM42JvR8iMurKpwUXqwL9O+SYp5d8dBatwMv4nPsXM4xlWXCqs28/ qlbhFDnu6zf6iihx1LNkph0AbmlxWUVfwxfH3/dyhvpVhS18oWrV78HnGGKrxuNogMsm AjbZfP55sn7BCgAPnOM80Y88+07G/rCAfe0M9O+YVoqKZ8ArNI86iDoV/Rbij5KvJHgK wGCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=pIErAS3g; 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-8647-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8647-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-57aae230c24si1090809a12.434.2024.06.06.13.34.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 13:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8647-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=pIErAS3g; 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-8647-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8647-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 9B49E1F23D09 for ; Thu, 6 Jun 2024 20:34:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 545CE199EA6; Thu, 6 Jun 2024 20:33:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="pIErAS3g" 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 46CCD13C3F1; Thu, 6 Jun 2024 20:33:12 +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=1717705994; cv=none; b=fmZ9lPg4sC+vpomlA3ub3DsqJJrAbkb1ljqWyixKgAxtDtOOJ1ZkbKtfX795CJL1y8Lvcu5ExY7c/z0HO3YkheCwbCdciVzg/5MWcmmAPkR+jTdhOhweyXG9Sl3AkJtl8HKfq1BEKPiLq2pm0//B2/h1BQVH7XwtJpGZ/irF4ZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717705994; c=relaxed/simple; bh=6nX7MWUTnzz52ZyxiV9MFVPAXzEarRGnZlK04/SqCeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WulckGntRX01EdB1pAx5TbqJk9U+9TKj5TD1u8SV95pDByu+aoIkuHtbFA+KiF4svGqZR9q4MaFlXjiFkhPIQObgPhvgu8M3bmeXjJC208/+RyYtcBEhUUZDp/beGRRvOXY4WO8KSHDFFXnFFu4pZm4iLXTMP6qYvJGKJ4BFD0Y= 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=pIErAS3g; 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=wH4qzpwIFO32RLV7tQSPATNkfLQ4Pd/Kex9TJqhUJBg=; t=1717705992; x=1718915592; b=pIErAS3gbYP9f03aZlbUayk9Nfs0UFxbLSV0Q66CapIzxIv WVBu7ThqrtxxVtWKJrLqYiaQtQF4NTKMyJgsKUHr0os2Z6sU4eHwLmg+r/YM8fsCDyJk3KRK+rL2E V7LFHBrzUmOzU6ee+EfNQPraJPQXuyPMNc4DdYWtR9bY54oTetASu2cLI3mqiNShrcn0nWcm2C+6z ys7Z4QIR+EPLt5/RdVAGJ4N7EIojmhQAN/uHQAZEsNMfv40aK3RXh6Ton4a01lAH0rXiiaw8l07Xl wr0ftBaSyH1YnMctjtMStGgdOACNjlPSlgekM62976ZdWKXdO87DN1GNpvnZ+89Q==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1sFJnC-0000000HDhM-2Poh; Thu, 06 Jun 2024 22:33: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 v3 4/4] net: drop_monitor: use drop_reason_lookup() Date: Thu, 6 Jun 2024 22:32:04 +0200 Message-ID: <20240606203255.49433-10-johannes@sipsolutions.net> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240606203255.49433-6-johannes@sipsolutions.net> References: <20240606203255.49433-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.1