[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251127230857.96436-1-socketcan@hartkopp.net>
Date: Fri, 28 Nov 2025 00:08:57 +0100
From: Oliver Hartkopp <socketcan@...tkopp.net>
To: linux-can@...r.kernel.org
Cc: netdev@...r.kernel.org,
davem@...emloft.net,
kuba@...nel.org,
kernel@...gutronix.de,
mkl@...gutronix.de,
Oliver Hartkopp <socketcan@...tkopp.net>,
Vincent Mailhol <mailhol@...nel.org>
Subject: [net-next v3] can: raw: fix build without CONFIG_CAN_DEV
The feature to instantly reject unsupported CAN frames makes use of CAN
netdevice specific flags which are only accessible when the CAN device
driver infrastructure is built.
Therefore check for CONFIG_CAN_DEV and fall back to MTU testing when the
CAN device driver infrastructure is absent.
Fixes: 1a620a723853 ("can: raw: instantly reject unsupported CAN frames")
Reported-by: Vincent Mailhol <mailhol@...nel.org>
Suggested-by: Marc Kleine-Budde <mkl@...gutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@...tkopp.net>
---
v2: use #if IS_ENABLED(CONFIG_CAN_DEV) instead of #ifdev CONFIG_CAN_DEV
v3: adopt Marc's suggestion to solve the problem in inclide/linux/can/dev.h
---
include/linux/can/dev.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 13b25b0dceeb..9f9e54e41702 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -109,11 +109,18 @@ struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max,
#define alloc_candev_mq(sizeof_priv, echo_skb_max, count) \
alloc_candev_mqs(sizeof_priv, echo_skb_max, count, count)
void free_candev(struct net_device *dev);
/* a candev safe wrapper around netdev_priv */
+#if IS_ENABLED(CONFIG_CAN_DEV)
struct can_priv *safe_candev_priv(struct net_device *dev);
+#else
+static inline struct can_priv *safe_candev_priv(struct net_device *dev)
+{
+ return NULL;
+}
+#endif
int open_candev(struct net_device *dev);
void close_candev(struct net_device *dev);
void can_set_default_mtu(struct net_device *dev);
int __must_check can_set_static_ctrlmode(struct net_device *dev,
--
2.47.3
Powered by blists - more mailing lists