Re: VCAN and CAN-FD DLC versus data length

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andre,

On 17/01/2020 14.26, Andre Naujoks wrote:

If I send a CAN-FD frame with a length, which is not directly representable by the DLC field, the vcan driver conserves this value. E.g. a Length of 11 is sent and received in userspace, even though there is no DLC representation for 11.

I talked to a colleague about this and we could not think of a case, in which this behaviour presents a problem. It is just a small discrepancy from how a real CAN would behave.

Right.

Last time when we changed the can-gw we had a discussion about this "sanitizing" of CAN specific data length here:

https://marc.info/?l=linux-can&m=156537620228658

1. When we get a CAN skb from the real CAN interface this is correct (in CAN length)

2. When we send stuff to the real CAN interface the value is fixed before writing the content into the CAN controllers registers.

cansend from the can-utils package actually makes sure not to use a data length, which is not directly representable. This is the output of a candump oagainst a patched version, which does not "fix" the length.

$ candump any & ./patched-cansend vcan0 123##011223344556677889900AA
   vcan0  123  [11]  11 22 33 44 55 66 77 88 99 00 AA

Yes. vcan is just forwarding frames without sanitizing. And even the can-gw can be used to (intentionally) create weird values in the length field - but makes sure that the length boundaries of CAN (0 .. 8) and CAN FD (0 .. 64) are met.

So using the len value e.g. in a for-statement never lets you write outside the CAN(FD) frame data[].

Does anyone have a real case, which would warrant a patch to the vcan driver to change this? Or should the CAN stack even return EINVAL on a data length, that is not representable?

As we had that discussion in the URL above and I can't see anything breaking I would tend to leave it as-is.

When we would sanitize the vcan skb flow we might end up with many skb_copy() cases instead of skb_clone() (permormance!). And as people may create skbs with PF_PACKET we are also not able to fix-up the length until it reaches the driver layer anyway.

Does that fit for you?

Best,
Oliver



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux