linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] can: rework the CAN MTU logic (CAN XL preparation step 2/3)
@ 2025-09-23  6:37 Vincent Mailhol
  2025-09-23  6:37 ` [PATCH v3 1/4] can: annotate mtu accesses with READ_ONCE() Vincent Mailhol
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Vincent Mailhol @ 2025-09-23  6:37 UTC (permalink / raw)
  To: Oliver Hartkopp, Marc Kleine-Budde
  Cc: linux-can, linux-kernel, Vincent Mailhol

The CAN MTU logic is currently broken. can_change_mtu() will update
both the MTU and the CAN_CTRLMODE_FD flag.

Back then, commit bc05a8944a34 ("can: allow to change the device mtu
for CAN FD capable devices") stated that:

  The configuration can be done either with the 'fd { on | off }'
  option in the 'ip' tool from iproute2 or by setting the CAN
  netdevice MTU to CAN_MTU (16) or to CANFD_MTU (72).

  Link: https://git.kernel.org/torvalds/c/bc05a8944a34

The problem is that after doing for example:

  $ ip link set can0 mtu 72 bittiming 500000

on a CAN FD interface, we are left with a device on which CAN FD is
enabled but which does not have the FD databittiming parameters
configured.

The same goes on when setting the mtu back to 16:

  ip link set can0 type can bitrate 500000 fd on dbitrate 5000000
  ip link set can0 mtu 16

The device is now in Classical CAN mode but iproute2 is still
reporting the databittiming values (although this time, the issue
seems less critical as it is only a reporting problem).

The only way to resolve the problem and bring the device back to a
coherent state is to call again the netlink interface using the
"fd on" or "fd off" options.

The idea of being able to infer the CAN_CTRLMODE_FD flag from the MTU
value is just incorrect for physical devices. Note that this logic
remains valid on virtual interfaces (vcan and vxcan) because those do
not have control mode flags and thus no conflict occurs.

This series reworks the CAN MTU logic. The goal is to always maintain
a coherent state between the MTU and the control mode flags as listed
in below table:

		fd off, xl off		fd on, xl off		fd any, xl on
  ---------------------------------------------------------------------------
  default mtu	CAN_MTU			CANFD_MTU		CANXL_MTU
  min mtu	CAN_MTU			CANFD_MTU		CANXL_MIN_MTU
  max mtu	CAN_MTU			CANFD_MTU		CANXL_MAX_MTU

In order to switch between one column to another, the user must use
the fd/xl on/off flags. Directly modifying the MTU from one column to
the other is not permitted any more.

The CAN XL is not yet supported at the moment, so the last column is
just given as a reference to better understand what is coming up. This
series will just implement the first two columns.

While doing the rewrite, the logic is adjusted to reuse as much as
possible the net core infrastructure. By populating:

  net_device->min_mtu

and

  net_device->max_mtu

the net core infrastructure will automatically:

  1. validate that the user's inputs are in range.

  2. report those min and max MTU values through the netlink
     interface.

Point 1. will allow us to get rid of the can_change_mtu() in a near
future for all the physical devices and point 2. allows the end user
to see the valid MTU range by doing a:

  $ ip --details link show can0

Finally, because using the net core, it will be possible after the
removal of can_change_mtu() to modify the MTU while the device is up.
As stated previously, the only modifications allowed will be within
the MTU range of a given CAN protocol. So for Classical CAN and CAN
FD, the MTU is fixed to, respectively, CAN_MTU and CANFD_MTU. For the
upcoming CAN XL, the user will be able to change the MTU to anything
between CANXL_MIN_MTU and CANXL_MAX_MTU even if the device is up.

The first patch of this series annotates the read access on
net_device->mtu. This preparation is needed to prevent any race
condition to occur when modifying the MTU while the device is up.

The second patch is another preparation change which moves
can_set_static_ctrlmode() from dev.h to dev.c.

The third patch populates the MTU minimum and maximum value.

The fourth patch is just a clean-up to remove the old
can_change_mtu().

The fourth and last patch comes as a bonus content and modifies the
default MTU of the vcan and vxcan so that CAN XL is on by default.

Note that after this series, the old can_change_mtu() becomes
useless. That function can not yet be removed because some pending
changes from other maintainers' trees still depend on it. It will be
removed in the next development window once all those changes reach
net-next.

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
Changes in v3:

  - v2 was based on Linus tree and, as a result, my other series which
    depends on this one did not apply smoothly:

      https://lore.kernel.org/linux-can/13f98eed-b535-4360-a545-0a11dbc8aa12@kernel.org/

    Rebase on net-next.

Link to v2: https://lore.kernel.org/r/20250923-can-fix-mtu-v2-0-984f9868db69@kernel.org

Changes in v2:

  - Drop RFC prefix

  - Patch "can: treewide: remove can_change_mtu()" is removed because
    it depends on the MTU fix:

      https://lore.kernel.org/linux-can/20250918-can-fix-mtu-v1-0-0d1cada9393b@kernel.org/

    which at the time of writing, does not yet appear in net-next. It
    is also still used in the Nuvoton driver which is also not yet
    merged. This patch will be resent in the next development window.

Link to v1: https://lore.kernel.org/r/20250918-can-fix-mtu-v1-0-471edb942295@kernel.org

---
Vincent Mailhol (4):
      can: annotate mtu accesses with READ_ONCE()
      can: dev: turn can_set_static_ctrlmode() into a non-inline function
      can: populate the minimum and maximum MTU values
      can: enable CAN XL for virtual CAN devices by default

 drivers/net/can/dev/dev.c     | 38 +++++++++++++++++++++++++++++++++++++-
 drivers/net/can/dev/netlink.c |  9 ++++-----
 drivers/net/can/vcan.c        |  2 +-
 drivers/net/can/vxcan.c       |  2 +-
 include/linux/can/dev.h       | 24 +++---------------------
 net/can/af_can.c              |  2 +-
 net/can/isotp.c               |  2 +-
 net/can/raw.c                 |  2 +-
 8 files changed, 49 insertions(+), 32 deletions(-)
---
base-commit: 9b277fca90c39c8b749e659bf5c23e924c46c93b
change-id: 20250915-can-fix-mtu-050a94b563a0

Best regards,
-- 
Vincent Mailhol <mailhol@kernel.org>


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

* [PATCH v3 1/4] can: annotate mtu accesses with READ_ONCE()
  2025-09-23  6:37 [PATCH v3 0/4] can: rework the CAN MTU logic (CAN XL preparation step 2/3) Vincent Mailhol
@ 2025-09-23  6:37 ` Vincent Mailhol
  2025-09-23  6:37 ` [PATCH v3 2/4] can: dev: turn can_set_static_ctrlmode() into a non-inline function Vincent Mailhol
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Vincent Mailhol @ 2025-09-23  6:37 UTC (permalink / raw)
  To: Oliver Hartkopp, Marc Kleine-Budde
  Cc: linux-can, linux-kernel, Vincent Mailhol

As hinted in commit 501a90c94510 ("inet: protect against too small mtu
values."), net_device->mtu is vulnerable to race conditions if it is
written and read without holding the RTNL.

At the moment, all the writes are done while the interface is down,
either in the devices' probe() function or in can_changelink(). So
there are no such issues yet. But upcoming changes will allow to
modify the MTU while the CAN XL devices are up.

In preparation to the introduction of CAN XL, annotate all the
net_device->mtu accesses which are not yet guarded by the RTNL with a
READ_ONCE().

Note that all the write accesses are already either guarded by the
RTNL or are already annotated and thus need no changes.

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
 net/can/af_can.c | 2 +-
 net/can/isotp.c  | 2 +-
 net/can/raw.c    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/can/af_can.c b/net/can/af_can.c
index b2387a46794a576973f3d865a5ca8e2ba696d167..770173d8db42813d5c085248d1bcf5fbe717955b 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -221,7 +221,7 @@ int can_send(struct sk_buff *skb, int loop)
 	}
 
 	/* Make sure the CAN frame can pass the selected CAN netdevice. */
-	if (unlikely(skb->len > skb->dev->mtu)) {
+	if (unlikely(skb->len > READ_ONCE(skb->dev->mtu))) {
 		err = -EMSGSIZE;
 		goto inval_skb;
 	}
diff --git a/net/can/isotp.c b/net/can/isotp.c
index dee1412b3c9c1ffcfc43a109b448701459fcf8b9..74ee1e52249b232813a06c5d2c6e404a38dce990 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -1313,7 +1313,7 @@ static int isotp_bind(struct socket *sock, struct sockaddr *uaddr, int len)
 		err = -ENODEV;
 		goto out;
 	}
-	if (dev->mtu < so->ll.mtu) {
+	if (READ_ONCE(dev->mtu) < so->ll.mtu) {
 		dev_put(dev);
 		err = -EINVAL;
 		goto out;
diff --git a/net/can/raw.c b/net/can/raw.c
index 76b867d21def209f5c6d236604c0e434a1c55a4d..6cb959e3dcd3e54972628ee59572a749009d1323 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -950,7 +950,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 	err = -EINVAL;
 
 	/* check for valid CAN (CC/FD/XL) frame content */
-	txmtu = raw_check_txframe(ro, skb, dev->mtu);
+	txmtu = raw_check_txframe(ro, skb, READ_ONCE(dev->mtu));
 	if (!txmtu)
 		goto free_skb;
 

-- 
2.49.1


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

* [PATCH v3 2/4] can: dev: turn can_set_static_ctrlmode() into a non-inline function
  2025-09-23  6:37 [PATCH v3 0/4] can: rework the CAN MTU logic (CAN XL preparation step 2/3) Vincent Mailhol
  2025-09-23  6:37 ` [PATCH v3 1/4] can: annotate mtu accesses with READ_ONCE() Vincent Mailhol
@ 2025-09-23  6:37 ` Vincent Mailhol
  2025-09-23  6:37 ` [PATCH v3 3/4] can: populate the minimum and maximum MTU values Vincent Mailhol
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Vincent Mailhol @ 2025-09-23  6:37 UTC (permalink / raw)
  To: Oliver Hartkopp, Marc Kleine-Budde
  Cc: linux-can, linux-kernel, Vincent Mailhol

can_set_static_ctrlmode() is declared as a static inline. But it is
only called in the probe function of the devices and so does not
really benefit from any kind of optimization.

Transform it into a "normal" function by moving it to

  drivers/net/can/dev/dev.c

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
This also serves as a preparation for the next patch in which we are
adding can_set_default_mtu(). That function will only be used by the
can_dev.ko module and so we do not need to export its GPL
symbol. However, if can_set_static_ctrlmode() stays as a static
inline, then the call to set_default_mtu(), which we plan to add in
can_set_static_ctrlmode(), would also be inlined and thus would become
visible to the users of can_set_static_ctrlmode().

Making can_set_static_ctrlmode() a non-inline function resolves this
dependency.
---
 drivers/net/can/dev/dev.c | 21 +++++++++++++++++++++
 include/linux/can/dev.h   | 23 ++---------------------
 2 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/net/can/dev/dev.c b/drivers/net/can/dev/dev.c
index 3913971125de0ab16b4ad9f36712954141014ddf..a0ae659beedcd1fa0979662c12614ae7846032c0 100644
--- a/drivers/net/can/dev/dev.c
+++ b/drivers/net/can/dev/dev.c
@@ -347,6 +347,27 @@ int can_change_mtu(struct net_device *dev, int new_mtu)
 }
 EXPORT_SYMBOL_GPL(can_change_mtu);
 
+/* helper to define static CAN controller features at device creation time */
+int can_set_static_ctrlmode(struct net_device *dev, u32 static_mode)
+{
+	struct can_priv *priv = netdev_priv(dev);
+
+	/* alloc_candev() succeeded => netdev_priv() is valid at this point */
+	if (priv->ctrlmode_supported & static_mode) {
+		netdev_warn(dev,
+			    "Controller features can not be supported and static at the same time\n");
+		return -EINVAL;
+	}
+	priv->ctrlmode = static_mode;
+
+	/* override MTU which was set by default in can_setup()? */
+	if (static_mode & CAN_CTRLMODE_FD)
+		dev->mtu = CANFD_MTU;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(can_set_static_ctrlmode);
+
 /* generic implementation of netdev_ops::ndo_eth_ioctl for CAN devices
  * supporting hardware timestamps
  */
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 9a92cbe5b2cb7ccdfca3121718856d096e9ecfa6..5dc58360c2d74a1711d4e02d28fe52ae20b146e0 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -125,27 +125,6 @@ static inline s32 can_get_relative_tdco(const struct can_priv *priv)
 	return (s32)priv->fd.tdc.tdco - sample_point_in_tc;
 }
 
-/* helper to define static CAN controller features at device creation time */
-static inline int __must_check can_set_static_ctrlmode(struct net_device *dev,
-						       u32 static_mode)
-{
-	struct can_priv *priv = netdev_priv(dev);
-
-	/* alloc_candev() succeeded => netdev_priv() is valid at this point */
-	if (priv->ctrlmode_supported & static_mode) {
-		netdev_warn(dev,
-			    "Controller features can not be supported and static at the same time\n");
-		return -EINVAL;
-	}
-	priv->ctrlmode = static_mode;
-
-	/* override MTU which was set by default in can_setup()? */
-	if (static_mode & CAN_CTRLMODE_FD)
-		dev->mtu = CANFD_MTU;
-
-	return 0;
-}
-
 static inline u32 can_get_static_ctrlmode(struct can_priv *priv)
 {
 	return priv->ctrlmode & ~priv->ctrlmode_supported;
@@ -188,6 +167,8 @@ struct can_priv *safe_candev_priv(struct net_device *dev);
 int open_candev(struct net_device *dev);
 void close_candev(struct net_device *dev);
 int can_change_mtu(struct net_device *dev, int new_mtu);
+int __must_check can_set_static_ctrlmode(struct net_device *dev,
+					 u32 static_mode);
 int can_eth_ioctl_hwts(struct net_device *netdev, struct ifreq *ifr, int cmd);
 int can_ethtool_op_get_ts_info_hwts(struct net_device *dev,
 				    struct kernel_ethtool_ts_info *info);

-- 
2.49.1


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

* [PATCH v3 3/4] can: populate the minimum and maximum MTU values
  2025-09-23  6:37 [PATCH v3 0/4] can: rework the CAN MTU logic (CAN XL preparation step 2/3) Vincent Mailhol
  2025-09-23  6:37 ` [PATCH v3 1/4] can: annotate mtu accesses with READ_ONCE() Vincent Mailhol
  2025-09-23  6:37 ` [PATCH v3 2/4] can: dev: turn can_set_static_ctrlmode() into a non-inline function Vincent Mailhol
@ 2025-09-23  6:37 ` Vincent Mailhol
  2025-09-23  6:37 ` [PATCH v3 4/4] can: enable CAN XL for virtual CAN devices by default Vincent Mailhol
  2025-09-23  9:10 ` [PATCH v3 0/4] can: rework the CAN MTU logic (CAN XL preparation step 2/3) Marc Kleine-Budde
  4 siblings, 0 replies; 6+ messages in thread
From: Vincent Mailhol @ 2025-09-23  6:37 UTC (permalink / raw)
  To: Oliver Hartkopp, Marc Kleine-Budde
  Cc: linux-can, linux-kernel, Vincent Mailhol

By populating:

  net_device->min_mtu

and

  net_device->max_mtu

the net core infrastructure will automatically:

  1. validate that the user's inputs are in range.

  2. report those min and max MTU values through the netlink
     interface.

Add can_set_default_mtu() which sets the default mtu value as well as
the minimum and maximum values. The logic for the default mtu value
remains unchanged:

  - CANFD_MTU if the device has a static CAN_CTRLMODE_FD.

  - CAN_MTU otherwise.

Call can_set_default_mtu() each time the CAN_CTRLMODE_FD is modified.
This will guarantee that the MTU value is always consistent with the
control mode flags.

With this, the checks done in can_change_mtu() become fully redundant
and will be removed in an upcoming change and it is now possible to
confirm the minimum and maximum MTU values on a physical CAN interface
by doing:

  $ ip --details link show can0

The virtual interfaces (vcan and vxcan) are not impacted by this
change.

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
With this, when adding the CAN XL netlink interface, all we have to do
is to add one if branch to can_set_default_mtu() like this:

	void can_set_default_mtu(struct net_device *dev)
	{
		struct can_priv *priv = netdev_priv(dev);

		if (priv->ctrlmode & CAN_CTRLMODE_XL) {
			if (can_is_canxl_dev_mtu(dev->mtu))
				return;
			dev->mtu = CANXL_MTU;
			dev->min_mtu = CANXL_MIN_MTU;
			dev->max_mtu = CANXL_MAX_MTU;
		} else if (priv->ctrlmode & CAN_CTRLMODE_FD) {
			dev->mtu = CANFD_MTU;
			dev->min_mtu = CANFD_MTU;
			dev->max_mtu = CANFD_MTU;
		} else {
			dev->mtu = CAN_MTU;
			dev->min_mtu = CAN_MTU;
			dev->max_mtu = CAN_MTU;
		}
	}

and we will be done!
---
 drivers/net/can/dev/dev.c     | 21 ++++++++++++++++++---
 drivers/net/can/dev/netlink.c |  9 ++++-----
 include/linux/can/dev.h       |  1 +
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/net/can/dev/dev.c b/drivers/net/can/dev/dev.c
index a0ae659beedcd1fa0979662c12614ae7846032c0..69c00720e9956cad986ea86fbba49285d76f51db 100644
--- a/drivers/net/can/dev/dev.c
+++ b/drivers/net/can/dev/dev.c
@@ -239,11 +239,12 @@ EXPORT_SYMBOL_GPL(can_bus_off);
 void can_setup(struct net_device *dev)
 {
 	dev->type = ARPHRD_CAN;
-	dev->mtu = CAN_MTU;
 	dev->hard_header_len = 0;
 	dev->addr_len = 0;
 	dev->tx_queue_len = 10;
 
+	can_set_default_mtu(dev);
+
 	/* New-style flags. */
 	dev->flags = IFF_NOARP;
 	dev->features = NETIF_F_HW_CSUM;
@@ -309,6 +310,21 @@ void free_candev(struct net_device *dev)
 }
 EXPORT_SYMBOL_GPL(free_candev);
 
+void can_set_default_mtu(struct net_device *dev)
+{
+	struct can_priv *priv = netdev_priv(dev);
+
+	if (priv->ctrlmode & CAN_CTRLMODE_FD) {
+		dev->mtu = CANFD_MTU;
+		dev->min_mtu = CANFD_MTU;
+		dev->max_mtu = CANFD_MTU;
+	} else {
+		dev->mtu = CAN_MTU;
+		dev->min_mtu = CAN_MTU;
+		dev->max_mtu = CAN_MTU;
+	}
+}
+
 /* changing MTU and control mode for CAN/CANFD devices */
 int can_change_mtu(struct net_device *dev, int new_mtu)
 {
@@ -361,8 +377,7 @@ int can_set_static_ctrlmode(struct net_device *dev, u32 static_mode)
 	priv->ctrlmode = static_mode;
 
 	/* override MTU which was set by default in can_setup()? */
-	if (static_mode & CAN_CTRLMODE_FD)
-		dev->mtu = CANFD_MTU;
+	can_set_default_mtu(dev);
 
 	return 0;
 }
diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c
index d9f6ab3efb9767409c318b714f19df8a30e51137..248f607e3864ffbda6f0b8daf4e2484179cf9cd5 100644
--- a/drivers/net/can/dev/netlink.c
+++ b/drivers/net/can/dev/netlink.c
@@ -223,17 +223,16 @@ static int can_changelink(struct net_device *dev, struct nlattr *tb[],
 		priv->ctrlmode &= ~cm->mask;
 		priv->ctrlmode |= maskedflags;
 
-		/* CAN_CTRLMODE_FD can only be set when driver supports FD */
-		if (priv->ctrlmode & CAN_CTRLMODE_FD) {
-			dev->mtu = CANFD_MTU;
-		} else {
-			dev->mtu = CAN_MTU;
+		/* Wipe potential leftovers from previous CAN FD config */
+		if (!(priv->ctrlmode & CAN_CTRLMODE_FD)) {
 			memset(&priv->fd.data_bittiming, 0,
 			       sizeof(priv->fd.data_bittiming));
 			priv->ctrlmode &= ~CAN_CTRLMODE_FD_TDC_MASK;
 			memset(&priv->fd.tdc, 0, sizeof(priv->fd.tdc));
 		}
 
+		can_set_default_mtu(dev);
+
 		fd_tdc_flag_provided = cm->mask & CAN_CTRLMODE_FD_TDC_MASK;
 		/* CAN_CTRLMODE_TDC_{AUTO,MANUAL} are mutually
 		 * exclusive: make sure to turn the other one off
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 5dc58360c2d74a1711d4e02d28fe52ae20b146e0..3354f70ed2c684d7d482549560d4cb5838cbebd5 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -166,6 +166,7 @@ struct can_priv *safe_candev_priv(struct net_device *dev);
 
 int open_candev(struct net_device *dev);
 void close_candev(struct net_device *dev);
+void can_set_default_mtu(struct net_device *dev);
 int can_change_mtu(struct net_device *dev, int new_mtu);
 int __must_check can_set_static_ctrlmode(struct net_device *dev,
 					 u32 static_mode);

-- 
2.49.1


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

* [PATCH v3 4/4] can: enable CAN XL for virtual CAN devices by default
  2025-09-23  6:37 [PATCH v3 0/4] can: rework the CAN MTU logic (CAN XL preparation step 2/3) Vincent Mailhol
                   ` (2 preceding siblings ...)
  2025-09-23  6:37 ` [PATCH v3 3/4] can: populate the minimum and maximum MTU values Vincent Mailhol
@ 2025-09-23  6:37 ` Vincent Mailhol
  2025-09-23  9:10 ` [PATCH v3 0/4] can: rework the CAN MTU logic (CAN XL preparation step 2/3) Marc Kleine-Budde
  4 siblings, 0 replies; 6+ messages in thread
From: Vincent Mailhol @ 2025-09-23  6:37 UTC (permalink / raw)
  To: Oliver Hartkopp, Marc Kleine-Budde
  Cc: linux-can, linux-kernel, Vincent Mailhol

In commit 97edec3a11cf ("can: enable CAN FD for virtual CAN devices by
default"), vcan and vxcan default MTU was set to CANFD_MTU by default.
The reason was that users were confused on how to activate CAN FD on
virtual interfaces.

Following the introduction of CAN XL, the same logic should be
applied. Set the MTU to CANXL_MTU by default.

The users who really wish to use a Classical CAN only or a CAN FD
virtual device can do respectively:

  $ ip link set vcan0 mtu 16

or

  $ ip link set vcan0 mtu 72

to force the old behaviour.

Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
---
 drivers/net/can/vcan.c  | 2 +-
 drivers/net/can/vxcan.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
index f67e858071007acd5f34fa00a76212f1a77997a6..fdc662aea2798125b3aa373f09958363b427ced2 100644
--- a/drivers/net/can/vcan.c
+++ b/drivers/net/can/vcan.c
@@ -156,7 +156,7 @@ static const struct ethtool_ops vcan_ethtool_ops = {
 static void vcan_setup(struct net_device *dev)
 {
 	dev->type		= ARPHRD_CAN;
-	dev->mtu		= CANFD_MTU;
+	dev->mtu		= CANXL_MTU;
 	dev->hard_header_len	= 0;
 	dev->addr_len		= 0;
 	dev->tx_queue_len	= 0;
diff --git a/drivers/net/can/vxcan.c b/drivers/net/can/vxcan.c
index 99a78a75716749bf858cc78eadb41ca2588fcf94..b2c19f8c5f8e5101b8be343401afe9a4f388c4da 100644
--- a/drivers/net/can/vxcan.c
+++ b/drivers/net/can/vxcan.c
@@ -156,7 +156,7 @@ static void vxcan_setup(struct net_device *dev)
 	struct can_ml_priv *can_ml;
 
 	dev->type		= ARPHRD_CAN;
-	dev->mtu		= CANFD_MTU;
+	dev->mtu		= CANXL_MTU;
 	dev->hard_header_len	= 0;
 	dev->addr_len		= 0;
 	dev->tx_queue_len	= 0;

-- 
2.49.1


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

* Re: [PATCH v3 0/4] can: rework the CAN MTU logic (CAN XL preparation step 2/3)
  2025-09-23  6:37 [PATCH v3 0/4] can: rework the CAN MTU logic (CAN XL preparation step 2/3) Vincent Mailhol
                   ` (3 preceding siblings ...)
  2025-09-23  6:37 ` [PATCH v3 4/4] can: enable CAN XL for virtual CAN devices by default Vincent Mailhol
@ 2025-09-23  9:10 ` Marc Kleine-Budde
  4 siblings, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2025-09-23  9:10 UTC (permalink / raw)
  To: Vincent Mailhol; +Cc: Oliver Hartkopp, linux-can, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 478 bytes --]

On 23.09.2025 15:37:07, Vincent Mailhol wrote:
> The CAN MTU logic is currently broken. can_change_mtu() will update
> both the MTU and the CAN_CTRLMODE_FD flag.

Added to linux-can-next.

Thanks,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2025-09-23  9:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23  6:37 [PATCH v3 0/4] can: rework the CAN MTU logic (CAN XL preparation step 2/3) Vincent Mailhol
2025-09-23  6:37 ` [PATCH v3 1/4] can: annotate mtu accesses with READ_ONCE() Vincent Mailhol
2025-09-23  6:37 ` [PATCH v3 2/4] can: dev: turn can_set_static_ctrlmode() into a non-inline function Vincent Mailhol
2025-09-23  6:37 ` [PATCH v3 3/4] can: populate the minimum and maximum MTU values Vincent Mailhol
2025-09-23  6:37 ` [PATCH v3 4/4] can: enable CAN XL for virtual CAN devices by default Vincent Mailhol
2025-09-23  9:10 ` [PATCH v3 0/4] can: rework the CAN MTU logic (CAN XL preparation step 2/3) Marc Kleine-Budde

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