[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250611171540.27715f36@kernel.org>
Date: Wed, 11 Jun 2025 17:15:40 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Gal Pressman <gal@...dia.com>
Cc: "David S. Miller" <davem@...emloft.net>, Eric Dumazet
<edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>, Andrew Lunn
<andrew+netdev@...n.ch>, <netdev@...r.kernel.org>, Alex Lazar
<alazar@...dia.com>, "Dragos Tatulea" <dtatulea@...dia.com>
Subject: Re: [PATCH net-next 1/2] net: vlan: Replace BUG() with
WARN_ON_ONCE() in vlan_dev_* stubs
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?
Powered by blists - more mailing lists