netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/3] Misc vlan cleanups
@ 2025-06-16 13:26 Gal Pressman
  2025-06-16 13:26 ` [PATCH net-next v2 1/3] net: vlan: Make is_vlan_dev() a stub when VLAN is not configured Gal Pressman
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gal Pressman @ 2025-06-16 13:26 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, netdev
  Cc: Gal Pressman

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.

Changelog -
v1->v2: https://lore.kernel.org/netdev/20250610072611.1647593-1-gal@nvidia.com/
* Add the first patch, alternative approach suggested by Jakub

Gal Pressman (3):
  net: vlan: Make is_vlan_dev() a stub when VLAN is not configured
  net: vlan: Replace BUG() with WARN_ON_ONCE() in vlan_dev_* stubs
  net: vlan: Use IS_ENABLED() helper for CONFIG_VLAN_8021Q guard

 include/linux/if_vlan.h | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

-- 
2.40.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 1/3] net: vlan: Make is_vlan_dev() a stub when VLAN is not configured
  2025-06-16 13:26 [PATCH net-next v2 0/3] Misc vlan cleanups Gal Pressman
@ 2025-06-16 13:26 ` Gal Pressman
  2025-06-16 13:26 ` [PATCH net-next v2 2/3] net: vlan: Replace BUG() with WARN_ON_ONCE() in vlan_dev_* stubs Gal Pressman
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Gal Pressman @ 2025-06-16 13:26 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, netdev
  Cc: Gal Pressman

Add a stub implementation of is_vlan_dev() that returns false when
VLAN support is not compiled in (CONFIG_VLAN_8021Q=n).

This allows us to compile-out VLAN-dependent dead code when it is not
needed.

This also resolves the following compilation error when:
* CONFIG_VLAN_8021Q=n
* CONFIG_OBJTOOL=y
* CONFIG_OBJTOOL_WERROR=y

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()
(which doesn't return) calls in VLAN code paths are actually dead code
when VLAN support is disabled.

Signed-off-by: Gal Pressman <gal@nvidia.com>
---
 include/linux/if_vlan.h | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 38456b42cdb5..618a973ff8ee 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -79,11 +79,6 @@ static inline struct vlan_ethhdr *skb_vlan_eth_hdr(const struct sk_buff *skb)
 /* found in socket.c */
 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;
-}
-
 #define skb_vlan_tag_present(__skb)	(!!(__skb)->vlan_all)
 #define skb_vlan_tag_get(__skb)		((__skb)->vlan_tci)
 #define skb_vlan_tag_get_id(__skb)	((__skb)->vlan_tci & VLAN_VID_MASK)
@@ -200,6 +195,11 @@ struct vlan_dev_priv {
 #endif
 };
 
+static inline bool is_vlan_dev(const struct net_device *dev)
+{
+	return dev->priv_flags & IFF_802_1Q_VLAN;
+}
+
 static inline struct vlan_dev_priv *vlan_dev_priv(const struct net_device *dev)
 {
 	return netdev_priv(dev);
@@ -237,6 +237,11 @@ extern void vlan_vids_del_by_dev(struct net_device *dev,
 extern bool vlan_uses_dev(const struct net_device *dev);
 
 #else
+static inline bool is_vlan_dev(const struct net_device *dev)
+{
+	return false;
+}
+
 static inline struct net_device *
 __vlan_find_dev_deep_rcu(struct net_device *real_dev,
 		     __be16 vlan_proto, u16 vlan_id)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 2/3] net: vlan: Replace BUG() with WARN_ON_ONCE() in vlan_dev_* stubs
  2025-06-16 13:26 [PATCH net-next v2 0/3] Misc vlan cleanups Gal Pressman
  2025-06-16 13:26 ` [PATCH net-next v2 1/3] net: vlan: Make is_vlan_dev() a stub when VLAN is not configured Gal Pressman
@ 2025-06-16 13:26 ` Gal Pressman
  2025-06-16 13:26 ` [PATCH net-next v2 3/3] net: vlan: Use IS_ENABLED() helper for CONFIG_VLAN_8021Q guard Gal Pressman
  2025-06-18  1:41 ` [PATCH net-next v2 0/3] Misc vlan cleanups patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Gal Pressman @ 2025-06-16 13:26 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, netdev
  Cc: Gal Pressman, Alex Lazar, Dragos Tatulea

When CONFIG_VLAN_8021Q=n, a set of stub helpers are used, three of these
helpers use BUG() unconditionally.

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.

Reviewed-by: Alex Lazar <alazar@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
---
 include/linux/if_vlan.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 618a973ff8ee..b9f699799cf6 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -259,19 +259,19 @@ vlan_for_each(struct net_device *dev,
 
 static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
 {
-	BUG();
+	WARN_ON_ONCE(1);
 	return NULL;
 }
 
 static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
 {
-	BUG();
+	WARN_ON_ONCE(1);
 	return 0;
 }
 
 static inline __be16 vlan_dev_vlan_proto(const struct net_device *dev)
 {
-	BUG();
+	WARN_ON_ONCE(1);
 	return 0;
 }
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 3/3] net: vlan: Use IS_ENABLED() helper for CONFIG_VLAN_8021Q guard
  2025-06-16 13:26 [PATCH net-next v2 0/3] Misc vlan cleanups Gal Pressman
  2025-06-16 13:26 ` [PATCH net-next v2 1/3] net: vlan: Make is_vlan_dev() a stub when VLAN is not configured Gal Pressman
  2025-06-16 13:26 ` [PATCH net-next v2 2/3] net: vlan: Replace BUG() with WARN_ON_ONCE() in vlan_dev_* stubs Gal Pressman
@ 2025-06-16 13:26 ` Gal Pressman
  2025-06-18  1:41 ` [PATCH net-next v2 0/3] Misc vlan cleanups patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Gal Pressman @ 2025-06-16 13:26 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, netdev
  Cc: Gal Pressman, Alex Lazar, Dragos Tatulea

The header currently tests the VLAN core with an explicit pair of 'if
defined' checks:
    #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)

Instead, use IS_ENABLED() which is the kernel way to test whether an
option is configured as builtin/module.

This is purely cosmetic – no functional changes.

Reviewed-by: Alex Lazar <alazar@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
---
 include/linux/if_vlan.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index b9f699799cf6..15e01935d3fa 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -131,7 +131,7 @@ struct vlan_pcpu_stats {
 	u32			tx_dropped;
 };
 
-#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+#if IS_ENABLED(CONFIG_VLAN_8021Q)
 
 extern struct net_device *__vlan_find_dev_deep_rcu(struct net_device *real_dev,
 					       __be16 vlan_proto, u16 vlan_id);
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v2 0/3] Misc vlan cleanups
  2025-06-16 13:26 [PATCH net-next v2 0/3] Misc vlan cleanups Gal Pressman
                   ` (2 preceding siblings ...)
  2025-06-16 13:26 ` [PATCH net-next v2 3/3] net: vlan: Use IS_ENABLED() helper for CONFIG_VLAN_8021Q guard Gal Pressman
@ 2025-06-18  1:41 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-18  1:41 UTC (permalink / raw)
  To: Gal Pressman; +Cc: davem, edumazet, kuba, pabeni, andrew+netdev, netdev

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 16 Jun 2025 16:26:23 +0300 you wrote:
> 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:
> 
> [...]

Here is the summary with links:
  - [net-next,v2,1/3] net: vlan: Make is_vlan_dev() a stub when VLAN is not configured
    https://git.kernel.org/netdev/net-next/c/2de1ba0887e5
  - [net-next,v2,2/3] net: vlan: Replace BUG() with WARN_ON_ONCE() in vlan_dev_* stubs
    https://git.kernel.org/netdev/net-next/c/60a8b1a5d082
  - [net-next,v2,3/3] net: vlan: Use IS_ENABLED() helper for CONFIG_VLAN_8021Q guard
    https://git.kernel.org/netdev/net-next/c/9c5f5a5bf0da

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-06-18  1:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-16 13:26 [PATCH net-next v2 0/3] Misc vlan cleanups Gal Pressman
2025-06-16 13:26 ` [PATCH net-next v2 1/3] net: vlan: Make is_vlan_dev() a stub when VLAN is not configured Gal Pressman
2025-06-16 13:26 ` [PATCH net-next v2 2/3] net: vlan: Replace BUG() with WARN_ON_ONCE() in vlan_dev_* stubs Gal Pressman
2025-06-16 13:26 ` [PATCH net-next v2 3/3] net: vlan: Use IS_ENABLED() helper for CONFIG_VLAN_8021Q guard Gal Pressman
2025-06-18  1:41 ` [PATCH net-next v2 0/3] Misc vlan cleanups patchwork-bot+netdevbpf

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).