hartkopp/can-isotp

Backward compatibility for Linux 5.4+ versions in bind()

Closed this issue · 2 comments

Hi,
I've been flagged an issue with my Python Iso-TP module (pylessard/python-can-isotp#22) regarding a backward compatibility issue. After diving into it, I believe the issue is a conflict between Python and this module.

Apparently, opening an ISOTP socket with Python 3.7.6 and a can-isotp.ko built under Linux 5.4 doesn't work. I believe the problem arise from the addition of J1939 support that modified the size of the sockaddr_can structure (change acknowledges by yourself :) ).

Python create the address object for the user and deduce the length of the address object by using sizeof(*addr). If Python has been compiled with a headers of Linux 5.3, then the this value should be smaller than what one would get with Linux headers of Linux 5.4+.

This line here, checks for conflicts by validating the size of the address object. This verification will prevent the creation of ISO-TP socket if an older Python is used with a freshly compiled kernel module.

Is there a way to be backward compatible with this or should one make sure to keep his Python version aligned with his Kernel version?

Thanks!

Fixed in
fbed98a
and
ced84ca
Thanks @pylessard !

Very interesting, I wasn't aware of the existence of the offsetof macro! That makes a very nice fix.
Thank you