mirror-linux/drivers/net/can/dev
Marc Kleine-Budde 375629c92f can: dev: alloc_candev_mqs(): add missing default CAN capabilities
The idea behind series 6c1f5146b2 ("Merge patch series "can: raw: better
approach to instantly reject unsupported CAN frames"") is to set the
capabilities of a CAN device (CAN-CC, CAN-FD, CAN-XL, and listen only) [1]
and, based on these capabilities, reject unsupported CAN frames in the
CAN-RAW protocol [2].

This works perfectly for CAN devices configured in CAN-FD or CAN-XL mode.
CAN devices with static CAN control modes define their capabilities via
can_set_static_ctrlmode() -> can_set_cap_info(). CAN devices configured by
the user space for CAN-FD or CAN-XL set their capabilities via
can_changelink() -> can_ctrlmode_changelink() -> can_set_cap_info().

However, in commit 166e87329c ("can: propagate CAN device capabilities
via ml_priv"), the capabilities of CAN devices are not initialized.
This results in CAN-RAW rejecting all CAN frames on devices directly
after ifup if the user space has not changed the CAN control mode.

Fix this problem by setting the default capabilities to CAN-CC in
alloc_candev_mqs() as soon as the CAN specific ml_priv is allocated.

[1] commit 166e87329c ("can: propagate CAN device capabilities via ml_priv")
[2] commit faba5860fc ("can: raw: instantly reject disabled CAN frames")

Fixes: 166e87329c ("can: propagate CAN device capabilities via ml_priv")
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Tested-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://patch.msgid.link/20260116-can_add_missing_set_caps-v1-1-7525126d8b20@pengutronix.de
[mkl: fix typo in subject]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2026-01-16 18:06:56 +01:00
..
Makefile Revert "can: raw: instantly reject unsupported CAN frames" 2026-01-15 09:52:04 +01:00
bittiming.c can: bittiming: add PWM validation 2025-11-26 11:20:43 +01:00
calc_bittiming.c can: dev: print bitrate error with two decimal digits 2025-11-26 11:20:44 +01:00
dev.c can: dev: alloc_candev_mqs(): add missing default CAN capabilities 2026-01-16 18:06:56 +01:00
length.c can: length: refactor frame lengths definition to add size in bits 2023-06-22 09:43:40 +02:00
netlink.c can: propagate CAN device capabilities via ml_priv 2026-01-15 09:52:04 +01:00
rx-offload.c netdev: replace napi_reschedule with napi_schedule 2023-10-11 17:28:06 -07:00
skb.c can: dev: can_put_echo_skb(): don't crash kernel if can_priv::echo_skb is accessed out of bounds 2023-10-05 21:34:13 +02:00