Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'misc-vlan-cleanups'

Gal Pressman says:

====================
Misc vlan cleanups

This patch series addresses compilation issues with objtool when VLAN
support is disabled (CONFIG_VLAN_8021Q=n) and makes related improvements
to the VLAN infrastructure.

When CONFIG_VLAN_8021Q=n, CONFIG_OBJTOOL=y, and CONFIG_OBJTOOL_WERROR=y,
the following compilation error occurs:

drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.o: error: objtool: parse_mirred.isra.0+0x370: mlx5e_tc_act_vlan_add_push_action() missing __noreturn in .c/.h or NORETURN() in noreturns.h

The error occurs because objtool cannot determine that unreachable BUG()
calls in VLAN code paths are actually dead code when VLAN support is
disabled.

First patch makes is_vlan_dev() a stub when VLAN is not configured,
allows compile-out of VLAN-dependent dead code paths and resolves the
objtool compilation error.

Second patch replaces BUG() calls with WARN_ON_ONCE(), as the usage of
BUG() should be avoided.

Third patch uses the "kernel" way of testing whether an option is
configured as builtin/module, instead of open-coding it.

v2: https://lore.kernel.org/20250610072611.1647593-1-gal@nvidia.com/
====================

Link: https://patch.msgid.link/20250616132626.1749331-1-gal@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+14 -9
+14 -9
include/linux/if_vlan.h
··· 79 79 /* found in socket.c */ 80 80 extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *)); 81 81 82 - static inline bool is_vlan_dev(const struct net_device *dev) 83 - { 84 - return dev->priv_flags & IFF_802_1Q_VLAN; 85 - } 86 - 87 82 #define skb_vlan_tag_present(__skb) (!!(__skb)->vlan_all) 88 83 #define skb_vlan_tag_get(__skb) ((__skb)->vlan_tci) 89 84 #define skb_vlan_tag_get_id(__skb) ((__skb)->vlan_tci & VLAN_VID_MASK) ··· 131 136 u32 tx_dropped; 132 137 }; 133 138 134 - #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 139 + #if IS_ENABLED(CONFIG_VLAN_8021Q) 135 140 136 141 extern struct net_device *__vlan_find_dev_deep_rcu(struct net_device *real_dev, 137 142 __be16 vlan_proto, u16 vlan_id); ··· 195 200 #endif 196 201 }; 197 202 203 + static inline bool is_vlan_dev(const struct net_device *dev) 204 + { 205 + return dev->priv_flags & IFF_802_1Q_VLAN; 206 + } 207 + 198 208 static inline struct vlan_dev_priv *vlan_dev_priv(const struct net_device *dev) 199 209 { 200 210 return netdev_priv(dev); ··· 237 237 extern bool vlan_uses_dev(const struct net_device *dev); 238 238 239 239 #else 240 + static inline bool is_vlan_dev(const struct net_device *dev) 241 + { 242 + return false; 243 + } 244 + 240 245 static inline struct net_device * 241 246 __vlan_find_dev_deep_rcu(struct net_device *real_dev, 242 247 __be16 vlan_proto, u16 vlan_id) ··· 259 254 260 255 static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev) 261 256 { 262 - BUG(); 257 + WARN_ON_ONCE(1); 263 258 return NULL; 264 259 } 265 260 266 261 static inline u16 vlan_dev_vlan_id(const struct net_device *dev) 267 262 { 268 - BUG(); 263 + WARN_ON_ONCE(1); 269 264 return 0; 270 265 } 271 266 272 267 static inline __be16 vlan_dev_vlan_proto(const struct net_device *dev) 273 268 { 274 - BUG(); 269 + WARN_ON_ONCE(1); 275 270 return 0; 276 271 } 277 272