# Re: \[Question\] Sending CAN error frames

- From: Marc Kleine-Budde \<mkl@pengutronix.de\>
- Date: 2021-02-02 09:11:58 
- List: linux-can
- Page: https://ratatoskr.run/linux-can/2021/02/9355344
- Thread: https://ratatoskr.run/linux-can/2021/01/9355327/t.md

```text
On 2/2/21 10:00 AM, Oliver Hartkopp wrote:
>>> 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()
>>
> 
> Which means the vcan has to support CAN_CTRLMODE_TX_ERR too.
> 
>>> 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
> 
> What happens if you send a valid CAN frame with CAN_ERR_FLAG set?
> 
> I did not check it but I assume the frame is sent as normal frame and 
> the echo'ed CAN frame would *only* go through the error message filter 
> bank in af_can.c.

If CAN_CTRLMODE_TX_ERR has been added to the kernel and
can_dropped_invalid_skb() is updated, then a CAN frame with CAN_ERR_FLAG set
would be either send as an error frame or dropped by can_dropped_invalid_skb().

So it would be echoed only if the driver supports CAN_CTRLMODE_TX_ERR and it's
enabled.

> This is probably not what we want for 'real' CAN devices, so we might 
> have to take a look at this too.

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

- [signature.asc](https://ratatoskr.run/linux-can/2021/02/9355344/attachment/0) (application/pgp-signature, 488 bytes)
