From: Vincent Mailhol <mailhol@kernel.org>
To: Marc Kleine-Budde <mkl@pengutronix.de>,
Oliver Hartkopp <socketcan@hartkopp.net>
Cc: "Vincent Mailhol" <mailhol@kernel.org>,
"Stéphane Grosjean" <stephane.grosjean@hms-networks.com>,
"Robert Nawrath" <mbro1689@gmail.com>,
"Minh Le" <minh.le.aj@renesas.com>,
"Duy Nguyen" <duy.nguyen.rh@renesas.com>,
linux-can@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/9] can: dev: can_dev_dropped_skb: drop CAN FD skbs if FD is off
Date: Mon, 13 Oct 2025 20:01:23 +0900 [thread overview]
Message-ID: <20251013-canxl-netlink-v1-1-f422b7e2729f@kernel.org> (raw)
In-Reply-To: <20251013-canxl-netlink-v1-0-f422b7e2729f@kernel.org>
Currently, the CAN FD skb validation logic is based on the MTU: the
interface is deemed FD capable if and only if its MTU is greater or
equal to CANFD_MTU.
This logic is showing its limit with the introduction of CAN XL. For
example, consider the two scenarios below:
1. An interface configured with CAN FD on and CAN XL on
2. An interface configured with CAN FD off and CAN XL on
In those two scenarios, the interfaces would have the same MTU:
CANXL_MTU
making it impossible to differentiate which one has CAN FD turned on
and which one has it off.
Because of the limitation, the only non-UAPI-breaking workaround is to
do the check at the device level using the can_priv->ctrlmode flags.
Unfortunately, the virtual interfaces (vcan, vxcan), which do not have
a can_priv, are left behind.
Add a check on the CAN_CTRLMODE_FD flag in can_dev_dropped_skb() and
drop FD frames whenever the feature is turned off.
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
Changelog:
RFC -> v1:
- add an netdev_info_once() message.
- this was sent as a standalone patch for discussion, it is now
integrated in the CAN XL series.
Link: https://lore.kernel.org/linux-can/20250907080504.598419-2-mailhol@kernel.org/
---
include/linux/can/dev.h | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 0fe8f80f223e..d59b283c981a 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -103,12 +103,20 @@ static inline bool can_dev_dropped_skb(struct net_device *dev, struct sk_buff *s
if (priv->ctrlmode & CAN_CTRLMODE_LISTENONLY) {
netdev_info_once(dev,
"interface in listen only mode, dropping skb\n");
- kfree_skb(skb);
- dev->stats.tx_dropped++;
- return true;
+ goto invalid_skb;
+ }
+
+ if (!(priv->ctrlmode & CAN_CTRLMODE_FD) && can_is_canfd_skb(skb)) {
+ netdev_info_once(dev, "CAN FD is disabled, dropping skb\n");
+ goto invalid_skb;
}
return can_dropped_invalid_skb(dev, skb);
+
+invalid_skb:
+ kfree_skb(skb);
+ dev->stats.tx_dropped++;
+ return true;
}
void can_setup(struct net_device *dev);
--
2.49.1
next prev parent reply other threads:[~2025-10-13 11:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-13 11:01 [PATCH 0/9] can: netlink: add CAN XL Vincent Mailhol
2025-10-13 11:01 ` Vincent Mailhol [this message]
2025-10-17 8:28 ` [PATCH 1/9] can: dev: can_dev_dropped_skb: drop CAN FD skbs if FD is off Marc Kleine-Budde
2025-10-17 13:27 ` Marc Kleine-Budde
2025-10-17 15:30 ` Vincent Mailhol
2025-10-17 15:34 ` Marc Kleine-Budde
2025-10-13 11:01 ` [PATCH 2/9] can: netlink: add CAN_CTRLMODE_RESTRICTED Vincent Mailhol
2025-10-13 11:01 ` [PATCH 3/9] can: netlink: add initial CAN XL support Vincent Mailhol
2025-10-13 11:01 ` [PATCH 4/9] can: netlink: add CAN_CTRLMODE_XL_TMS flag Vincent Mailhol
2025-10-13 11:01 ` [PATCH 5/9] can: netlink: add CAN_CTRLMODE_XL_ERR_SIGNAL Vincent Mailhol
2025-10-13 11:01 ` [PATCH 6/9] can: bittiming: add PWM parameters Vincent Mailhol
2025-10-13 11:01 ` [PATCH 7/9] can: bittiming: add PWM validation Vincent Mailhol
2025-10-13 11:01 ` [PATCH 8/9] can: calc_bittiming: add PWM calculation Vincent Mailhol
2025-10-13 21:21 ` kernel test robot
2025-10-14 2:05 ` Vincent Mailhol
2025-10-14 2:19 ` Vincent Mailhol
2025-10-14 2:32 ` Vincent Mailhol
2025-10-13 11:01 ` [PATCH 9/9] can: netlink: add PWM netlink interface Vincent Mailhol
2025-10-13 11:44 ` [PATCH 0/9] can: netlink: add CAN XL Vincent Mailhol
2025-10-17 13:53 ` Marc Kleine-Budde
2025-10-17 15:40 ` Vincent Mailhol
2025-10-17 16:02 ` Marc Kleine-Budde
2025-10-17 16:20 ` Vincent Mailhol
2025-10-17 16:34 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251013-canxl-netlink-v1-1-f422b7e2729f@kernel.org \
--to=mailhol@kernel.org \
--cc=duy.nguyen.rh@renesas.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbro1689@gmail.com \
--cc=minh.le.aj@renesas.com \
--cc=mkl@pengutronix.de \
--cc=socketcan@hartkopp.net \
--cc=stephane.grosjean@hms-networks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).