From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Nicolas Maier <nicolas.maier.dev@gmail.com>,
mkl@pengutronix.de, linux-can@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, corbet@lwn.net, netdev@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] can: bcm: add recvmsg flags for own, local and remote traffic
Date: Mon, 8 Jan 2024 19:57:36 +0100 [thread overview]
Message-ID: <14e86ea6-e038-4702-957a-39af27bfc280@hartkopp.net> (raw)
In-Reply-To: <1cf96afe-6a27-4fd5-975e-96122f72df2e@gmail.com>
Hi Nicolas,
thanks for the patch!
On 07.01.24 07:44, Nicolas Maier wrote:
> @@ -642,7 +666,7 @@ static enum hrtimer_restart bcm_rx_thr_handler(struct hrtimer *hrtimer)
> static void bcm_rx_handler(struct sk_buff *skb, void *data)
> {
> struct bcm_op *op = (struct bcm_op *)data;
> - const struct canfd_frame *rxframe = (struct canfd_frame *)skb->data;
> + struct canfd_frame *rxframe = (struct canfd_frame *)skb->data;
> unsigned int i;
>
> if (op->can_id != rxframe->can_id)
> @@ -657,6 +681,13 @@ static void bcm_rx_handler(struct sk_buff *skb, void *data)
> return;
> }
>
> + /* add flags to distinguish between own/local/remote CAN traffic */
> + if (skb->sk) {
> + rxframe->flags |= RX_LOCAL;
> + if (skb->sk == op->sk)
> + rxframe->flags |= RX_OWN;
> + }
> +
> /* disable timeout */
> hrtimer_cancel(&op->timer);
>
No. You are writing to a read-only skbuff, which is not yet cloned or
copied. The read-only handling of the skb is done in the NET_RX_SOFTIRQ
triggering can_rcv_filter() and friends.
See this note:
https://elixir.bootlin.com/linux/v6.7/source/net/can/af_can.c#L430
When you are also changing the CAN frames' content you need to
skb_copy() the provided skb, see:
https://elixir.bootlin.com/linux/v6.7/source/net/can/gw.c#L504
So if you want to pass these new flags to the user space you should
think of extending the parameter list of bcm_rx_update_and_send() and
bcm_rx_cmp_to_index().
But in the first place I'm interested to know what the use-case for this
extension is.
Best regards,
Oliver
next prev parent reply other threads:[~2024-01-08 19:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-07 6:44 Nicolas Maier
2024-01-08 18:57 ` Oliver Hartkopp [this message]
2024-01-14 13:21 ` Nicolas Maier
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=14e86ea6-e038-4702-957a-39af27bfc280@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=nicolas.maier.dev@gmail.com \
--cc=pabeni@redhat.com \
/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
all inboxes | Powered by JetHome®