netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Gal Pressman <gal@nvidia.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>, <netdev@vger.kernel.org>,
	Alex Lazar <alazar@nvidia.com>,
	"Dragos Tatulea" <dtatulea@nvidia.com>
Subject: Re: [PATCH net-next 1/2] net: vlan: Replace BUG() with WARN_ON_ONCE() in vlan_dev_* stubs
Date: Wed, 11 Jun 2025 17:15:40 -0700	[thread overview]
Message-ID: <20250611171540.27715f36@kernel.org> (raw)
In-Reply-To: <20250610072611.1647593-2-gal@nvidia.com>

On Tue, 10 Jun 2025 10:26:10 +0300 Gal Pressman wrote:
> This code should not be reached, as callers of these functions should
> always check for is_vlan_dev() first, but the usage of BUG() is not
> recommended, replace it with WARN_ON() instead.

Did you try something along the lines of:

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 38456b42cdb5..f24af2988fd9 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -81,7 +81,8 @@ extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
 
 static inline bool is_vlan_dev(const struct net_device *dev)
 {
-        return dev->priv_flags & IFF_802_1Q_VLAN;
+        return IS_ENABLED(CONFIG_VLAN_8021Q) &&
+               dev->priv_flags & IFF_802_1Q_VLAN;
 }
 
 #define skb_vlan_tag_present(__skb)    (!!(__skb)->vlan_all)


This should let the compiler eliminate the dead code completely,
assuming it truly dead. We can still replace the BUG()s as 
a of cleanup but I think the above is strictly preferable as 
a solution to your problem?

  reply	other threads:[~2025-06-12  0:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-10  7:26 [PATCH net-next 0/2] Couple of vlan cleanups Gal Pressman
2025-06-10  7:26 ` [PATCH net-next 1/2] net: vlan: Replace BUG() with WARN_ON_ONCE() in vlan_dev_* stubs Gal Pressman
2025-06-12  0:15   ` Jakub Kicinski [this message]
2025-06-12 10:32     ` Gal Pressman
2025-06-12 14:34       ` Jakub Kicinski
2025-06-10  7:26 ` [PATCH net-next 2/2] net: vlan: Use IS_ENABLED() helper for CONFIG_VLAN_8021Q guard Gal Pressman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250611171540.27715f36@kernel.org \
    --to=kuba@kernel.org \
    --cc=alazar@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).