Skip to content

Commit ccde408

Browse files
committed
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/[email protected]/ ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 6786dd7 + 9c5f5a5 commit ccde408

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

include/linux/if_vlan.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ static inline struct vlan_ethhdr *skb_vlan_eth_hdr(const struct sk_buff *skb)
7979
/* found in socket.c */
8080
extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
8181

82-
static inline bool is_vlan_dev(const struct net_device *dev)
83-
{
84-
return dev->priv_flags & IFF_802_1Q_VLAN;
85-
}
86-
8782
#define skb_vlan_tag_present(__skb) (!!(__skb)->vlan_all)
8883
#define skb_vlan_tag_get(__skb) ((__skb)->vlan_tci)
8984
#define skb_vlan_tag_get_id(__skb) ((__skb)->vlan_tci & VLAN_VID_MASK)
@@ -136,7 +131,7 @@ struct vlan_pcpu_stats {
136131
u32 tx_dropped;
137132
};
138133

139-
#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
134+
#if IS_ENABLED(CONFIG_VLAN_8021Q)
140135

141136
extern struct net_device *__vlan_find_dev_deep_rcu(struct net_device *real_dev,
142137
__be16 vlan_proto, u16 vlan_id);
@@ -200,6 +195,11 @@ struct vlan_dev_priv {
200195
#endif
201196
};
202197

198+
static inline bool is_vlan_dev(const struct net_device *dev)
199+
{
200+
return dev->priv_flags & IFF_802_1Q_VLAN;
201+
}
202+
203203
static inline struct vlan_dev_priv *vlan_dev_priv(const struct net_device *dev)
204204
{
205205
return netdev_priv(dev);
@@ -237,6 +237,11 @@ extern void vlan_vids_del_by_dev(struct net_device *dev,
237237
extern bool vlan_uses_dev(const struct net_device *dev);
238238

239239
#else
240+
static inline bool is_vlan_dev(const struct net_device *dev)
241+
{
242+
return false;
243+
}
244+
240245
static inline struct net_device *
241246
__vlan_find_dev_deep_rcu(struct net_device *real_dev,
242247
__be16 vlan_proto, u16 vlan_id)
@@ -254,19 +259,19 @@ vlan_for_each(struct net_device *dev,
254259

255260
static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
256261
{
257-
BUG();
262+
WARN_ON_ONCE(1);
258263
return NULL;
259264
}
260265

261266
static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
262267
{
263-
BUG();
268+
WARN_ON_ONCE(1);
264269
return 0;
265270
}
266271

267272
static inline __be16 vlan_dev_vlan_proto(const struct net_device *dev)
268273
{
269-
BUG();
274+
WARN_ON_ONCE(1);
270275
return 0;
271276
}
272277

0 commit comments

Comments
 (0)