Skip to content

Commit 375629c

Browse files
can: dev: alloc_candev_mqs(): add missing default CAN capabilities
The idea behind series 6c1f514 ("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 166e873 ("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 166e873 ("can: propagate CAN device capabilities via ml_priv") [2] commit faba586 ("can: raw: instantly reject disabled CAN frames") Fixes: 166e873 ("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>
1 parent a74c7a5 commit 375629c

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

drivers/net/can/dev/dev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max,
332332

333333
can_ml = (void *)priv + ALIGN(sizeof_priv, NETDEV_ALIGN);
334334
can_set_ml_priv(dev, can_ml);
335+
can_set_cap(dev, CAN_CAP_CC);
335336

336337
if (echo_skb_max) {
337338
priv->echo_skb_max = echo_skb_max;

0 commit comments

Comments
 (0)