Thread (22 messages) 22 messages, 6 authors, 2021-02-04

Re: [Question] Sending CAN error frames

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: 2021-02-02 08:42:35

Possibly related (same subject, not in this thread)

On 2/2/21 9:23 AM, Kurt Van Dijck wrote:
quoted
quoted
quoted
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
quoted
quoted
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 |

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help