All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Vincent MAILHOL <mailhol.vincent@wanadoo.fr>,
	Jimmy Assarsson <extja@kvaser.com>,
	Jimmy Assarsson <jimmyassarsson@gmail.com>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	linux-can <linux-can@vger.kernel.org>
Subject: Re: [Question] Sending CAN error frames
Date: Tue, 2 Feb 2021 09:41:38 +0100	[thread overview]
Message-ID: <8050d433-591c-2d1f-f0c7-ffa92e33032d@pengutronix.de> (raw)
In-Reply-To: <20210202082340.GA23043@x1.vandijck-laurijssen.be>


[-- Attachment #1.1: Type: text/plain, Size: 2252 bytes --]

On 2/2/21 9:23 AM, Kurt Van Dijck wrote:
>>>> Right, it would be nice to sort this out. I prefer to keep the
>>>> functionality, since we got customers using it.
>>>
>>> Basically, I would see this as an expert function: add a
>>> CAN_CTRLMODE_TX_ERR and have the user explicitly enable the
>>> feature through netlink when configuring the interface. The
>>> rationale is to prevent by default an unprivileged application
>>> from messing with the bus.
>>
>> The CAN_CTRLMODE_TX_ERR would be a per device option. Another option might be a
>> sockopt, where you have to enable the TX_ERR explicitly. I'm not sure, which
>> option is the best here.
> 
> a sockopt is only correct if it can detect that the device underneath
> has CAN_CTRLMODE_TX_ERR capability.

ACK

The user space use case would be:

- fd = socket()
- bind(fd, "can0")
- setsockopt(fd, SOCKOPT_TX_ERR)

The raw_setsockopt() in the kernel can check the CAN devices supported ctrl modes.

> So I'd think we start with adding the CAN_CTRLMODE_TX_ERR to the driver
> level.

ACK

> It would allow to see if a driver will behave properly with CAN_ERR_FLAG 
> can_frames in the tx path.

ACK

>>> If CAN_CTRLMODE_TX_ERR is on the device generates an error
>>> flag. Else, the CAN_ERR_FLAG is simply ignored (masked out).
>>> The CAN ID, DLC and payload of the TX error frames are
>>> ignored (i.e. reserved for future).
> 
> IMO, can_frames in the tx path with CAN_ERR_FLAG should be dropped
> if the driver can't handle them. vcan in this regard is capable of
> handling those, as does the kvaser usb.

Makes sense. The implementation steps could be:
- convert can_dropped_invalid_skb() from static inline to
  regular function
- add check for CAN_ERR_FLAG and enabled CAN_CTRLMODE_TX_ERR
  to can_dropped_invalid_skb()

> I think it's wrong that CAN_ERR_FLAG messages would appear as regular
> frame on CAN, as happens today if I understood well.

ACK

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: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2021-02-02  8:42 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-31  6:22 [Question] Sending CAN error frames Vincent MAILHOL
     [not found] ` <87e3dd54-50ab-1190-efdb-18ddb3b21a02@hartkopp.net>
2021-01-31 14:12   ` Vincent MAILHOL
2021-01-31 20:42   ` Jimmy Assarsson
2021-02-01 14:19     ` Vincent MAILHOL
2021-02-01 15:41       ` Jimmy Assarsson
2021-02-02  0:22         ` Vincent MAILHOL
2021-02-02  7:35           ` Marc Kleine-Budde
2021-02-02  8:23             ` Kurt Van Dijck
2021-02-02  8:41               ` Marc Kleine-Budde [this message]
2021-02-02  9:00                 ` Oliver Hartkopp
2021-02-02  9:05                   ` Marc Kleine-Budde
2021-02-02  9:16                     ` Oliver Hartkopp
2021-02-02 10:00                       ` Vincent MAILHOL
2021-02-02 10:14                         ` Oliver Hartkopp
2021-02-02 11:12                           ` Vincent MAILHOL
2021-02-02 19:19                             ` Oliver Hartkopp
2021-02-03  6:42                               ` Jimmy Assarsson
2021-02-03  8:26                                 ` Vincent MAILHOL
2021-02-03 20:06                                   ` Kurt Van Dijck
2021-02-04  4:13                                     ` Vincent MAILHOL
2021-02-04  7:38                                       ` Kurt Van Dijck
2021-02-04  9:42                                         ` Vincent MAILHOL
2021-02-02 12:14                         ` Jimmy Assarsson
2021-02-02  9:59           ` Jimmy Assarsson

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=8050d433-591c-2d1f-f0c7-ffa92e33032d@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=extja@kvaser.com \
    --cc=jimmyassarsson@gmail.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol.vincent@wanadoo.fr \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.