public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org,
	kernel@pengutronix.de, Marc Kleine-Budde <mkl@pengutronix.de>,
	Oliver Hartkopp <socketcan@hartkopp.net>
Subject: [PATCH net 1/7] can: dev: alloc_candev_mqs(): add missing default CAN capabilities
Date: Fri, 16 Jan 2026 20:55:47 +0100	[thread overview]
Message-ID: <20260116200323.366877-2-mkl@pengutronix.de> (raw)
In-Reply-To: <20260116200323.366877-1-mkl@pengutronix.de>

The idea behind series 6c1f5146b214 ("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 166e87329ce6 ("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 166e87329ce6 ("can: propagate CAN device capabilities via ml_priv")
[2] commit faba5860fcf9 ("can: raw: instantly reject disabled CAN frames")

Fixes: 166e87329ce6 ("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>
---
 drivers/net/can/dev/dev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/can/dev/dev.c b/drivers/net/can/dev/dev.c
index 7ab9578f5b89..769745e22a3c 100644
--- a/drivers/net/can/dev/dev.c
+++ b/drivers/net/can/dev/dev.c
@@ -332,6 +332,7 @@ struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max,
 
 	can_ml = (void *)priv + ALIGN(sizeof_priv, NETDEV_ALIGN);
 	can_set_ml_priv(dev, can_ml);
+	can_set_cap(dev, CAN_CAP_CC);
 
 	if (echo_skb_max) {
 		priv->echo_skb_max = echo_skb_max;

base-commit: a74c7a58ca2ca1cbb93f4c01421cf24b8642b962
-- 
2.51.0


  reply	other threads:[~2026-01-16 20:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-16 19:55 [PATCH net 0/7] pull-request: can 2026-01-16 Marc Kleine-Budde
2026-01-16 19:55 ` Marc Kleine-Budde [this message]
2026-01-19 18:30   ` [PATCH net 1/7] can: dev: alloc_candev_mqs(): add missing default CAN capabilities patchwork-bot+netdevbpf
2026-01-16 19:55 ` [PATCH net 2/7] can: gs_usb: gs_usb_receive_bulk_callback(): unanchor URL on usb_submit_urb() error Marc Kleine-Budde
2026-01-19 18:19   ` [net,2/7] " Jakub Kicinski
2026-01-23 17:36     ` Marc Kleine-Budde
2026-01-16 19:55 ` [PATCH net 3/7] can: ems_usb: ems_usb_read_bulk_callback(): fix URB memory leak Marc Kleine-Budde
2026-01-16 19:55 ` [PATCH net 4/7] can: esd_usb: esd_usb_read_bulk_callback(): " Marc Kleine-Budde
2026-01-16 19:55 ` [PATCH net 5/7] can: kvaser_usb: kvaser_usb_read_bulk_callback(): " Marc Kleine-Budde
2026-01-16 19:55 ` [PATCH net 6/7] can: mcba_usb: mcba_usb_read_bulk_callback(): " Marc Kleine-Budde
2026-01-16 19:55 ` [PATCH net 7/7] can: usb_8dev: usb_8dev_read_bulk_callback(): " 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=20260116200323.366877-2-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=socketcan@hartkopp.net \
    /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