From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: linux-can@vger.kernel.org
Subject: Re: [PATCH v2] can: raw: fix CAN FD frame transmissions over CAN XL devices
Date: Tue, 31 Jan 2023 12:06:00 +0100 [thread overview]
Message-ID: <20230131110600.pfydrujxthmokmsc@pengutronix.de> (raw)
In-Reply-To: <20230131091824.51026-1-socketcan@hartkopp.net>
[-- Attachment #1: Type: text/plain, Size: 2347 bytes --]
On 31.01.2023 10:18:24, Oliver Hartkopp wrote:
> A CAN XL device is always capable to process CAN FD frames. The former
> check when sending CAN FD frames relied on the existence of a CAN FD
> device and did not check for a CAN XL device that would be correct too.
>
> With this patch the CAN FD feature is enabled automatically when CAN XL
> is switched on - and CAN FD cannot be switch off while CAN XL is enabled.
>
> This precondition also leads to a clean up and reduction of checks in the
> hot path in raw_rcv() and raw_sendmsg().
>
> Fixes: 626332696d75 ("can: raw: add CAN XL support")
> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
> ---
>
> V2: fixed typo: devive -> device
>
> net/can/raw.c | 45 ++++++++++++++++++++++++++++++---------------
> 1 file changed, 30 insertions(+), 15 deletions(-)
>
> diff --git a/net/can/raw.c b/net/can/raw.c
> index 81071cdb0301..c505d315a7a9 100644
> --- a/net/can/raw.c
> +++ b/net/can/raw.c
> @@ -130,11 +130,11 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
> /* check the received tx sock reference */
> if (!ro->recv_own_msgs && oskb->sk == sk)
> return;
>
> /* make sure to not pass oversized frames to the socket */
> - if ((can_is_canfd_skb(oskb) && !ro->fd_frames && !ro->xl_frames) ||
> + if ((can_is_canfd_skb(oskb) && !ro->fd_frames) ||
> (can_is_canxl_skb(oskb) && !ro->xl_frames))
> return;
>
> /* eliminate multiple filter matches for the same skb */
> if (this_cpu_ptr(ro->uniq)->skb == oskb &&
> @@ -668,19 +668,27 @@ static int raw_setsockopt(struct socket *sock, int level, int optname,
> return -EINVAL;
>
> if (copy_from_sockptr(&ro->fd_frames, optval, optlen))
> return -EFAULT;
>
> + /* Enabling CAN XL includes CAN FD */
> + if (ro->xl_frames && !ro->fd_frames) {
> + ro->fd_frames = ro->xl_frames;
> + return -EINVAL;
> + }
This looks a bit weird. Maybe copy to a local variable first, then
check, then assign ->fd_frames or exit with error (instead of rolling
back)?
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2023-01-31 11:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-31 9:18 [PATCH v2] can: raw: fix CAN FD frame transmissions over CAN XL devices Oliver Hartkopp
2023-01-31 11:06 ` Marc Kleine-Budde [this message]
2023-01-31 12:00 ` Oliver Hartkopp
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=20230131110600.pfydrujxthmokmsc@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=linux-can@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;
as well as URLs for NNTP newsgroup(s).