Linux-CAN / SocketCAN user space applications
 
 
 
 
Go to file
Oliver Hartkopp cda61171f1 can: avoid using timeval for uapi
Upstream commit ba61a8d9d780980e8284355a0be750897e7af212

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=ba61a8d9d780980e8284355a0be750897e7af212

The can subsystem communicates with user space using a bcm_msg_head
header, which contains two timestamps. This is problematic for
multiple reasons:

a) The structure layout is currently incompatible between 64-bit
   user space and 32-bit user space, and cannot work in compat
   mode (other than x32).

b) The timeval structure layout will change in 32-bit user
   space when we fix the y2038 overflow problem by redefining
   time_t to 64-bit, making new 32-bit user space incompatible
   with the current kernel interface.
   Cars last a long time and often use old kernels, so the actual
   users of this code are the most likely ones to migrate to y2038
   safe user space.

This tries to work around part of the problem by changing the
publicly visible user interface in the header, but not the binary
interface. Fortunately, the values passed around in the structure
are relative times and do not actually suffer from the y2038
overflow, so 32-bit is enough here.

We replace the use of 'struct timeval' with a newly defined
'struct bcm_timeval' that uses the exact same binary layout
as before and that still suffers from problem a) but not problem
b).

The downside of this approach is that any user space program
that currently assigns a timeval structure to these members
rather than writing the tv_sec/tv_usec portions individually
will suffer a compile-time error when built with an updated
kernel header. Fixing this error makes it work fine with old
and new headers though.

We could address problem a) by using '__u32' or 'int' members
rather than 'long', but that would have a more significant
downside in also breaking support for all existing 64-bit user
binaries that might be using this interface, which is likely
not acceptable.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: linux-can@vger.kernel.org
Cc: linux-api@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-11-05 21:36:42 +01:00
config/m4 add autotools infrastructure 2010-04-19 12:12:18 +00:00
include/linux can: avoid using timeval for uapi 2015-11-05 21:36:42 +01:00
.gitignore gitignore: add isotpperf 2015-03-06 10:02:35 +01:00
Android.mk can-utils: added isotpperf tool for performance measurements 2015-02-04 10:17:38 +01:00
GNUmakefile.am configure: switch to new libtool-2.0 macro 2015-03-04 21:09:39 +01:00
Makefile can-utils: added isotpperf tool for performance measurements 2015-02-04 10:17:38 +01:00
README.md Create README.md 2015-09-04 11:16:17 +02:00
asc2log.c janitorial: asc2log: properly close infile 2015-03-06 10:02:35 +01:00
autogen.sh do not use --symlink for autoreconf 2014-07-02 16:03:34 +02:00
bcmserver.c remove obsolete SVN ID tags 2012-11-14 20:57:16 +01:00
can-calc-bit-timing.c can-calc-bit-timing: add some more timings for mscan and flexcan 2015-06-30 21:04:13 +02:00
canbusload.c canbusload: print bitstuffing mode when showing current time is enabled 2014-02-01 21:30:12 +01:00
candump.c candump: check for joined filter support at runtime 2015-04-01 12:58:27 +02:00
canfdtest.c treewide: use if_nametoindex to avoid overflows 2015-06-30 21:00:04 +02:00
canframelen.c canbusload: Fix worst-case frame length estimation 2014-01-30 16:23:32 +01:00
canframelen.h Add license to canframelen.h 2014-01-31 11:52:15 +01:00
cangen.c cangen: added -b switch enabling bitrate switch in canfd frames. 2015-10-14 21:22:35 +02:00
cangw.c cangw: introduce uid command line option 2015-06-11 20:48:43 +02:00
canlogserver.c can-utils: trivial: fix typos concerning "separation" and "useful" 2013-08-15 21:09:27 +02:00
canplayer.c canplayer: convert skipgap to unsigned long 2015-04-10 21:20:58 +02:00
cansend.c treewide: use if_nametoindex to avoid overflows 2015-06-30 21:00:04 +02:00
cansniffer.c cansniffer: increase resolution for timeout values 2014-06-24 21:36:55 +02:00
configure.ac autotools: fix syntax error 2015-09-03 17:24:21 +02:00
isotpdump.c treewide: use if_nametoindex to avoid overflows 2015-06-30 21:00:04 +02:00
isotpperf.c isotp: fix printf warning on 32 bit systems 2015-03-03 08:29:36 +01:00
isotprecv.c treewide: use if_nametoindex to avoid overflows 2015-06-30 21:00:04 +02:00
isotpsend.c treewide: use if_nametoindex to avoid overflows 2015-06-30 21:00:04 +02:00
isotpserver.c treewide: use if_nametoindex to avoid overflows 2015-06-30 21:00:04 +02:00
isotpsniffer.c treewide: use if_nametoindex to avoid overflows 2015-06-30 21:00:04 +02:00
isotptun.c treewide: use if_nametoindex to avoid overflows 2015-06-30 21:00:04 +02:00
lib.c lib: Update error messages according to new state change handling 2014-12-18 14:40:42 +01:00
lib.h can-utils: trivial: fix typos concerning "separation" and "useful" 2013-08-15 21:09:27 +02:00
log2asc.c log2asc: include sys/time.h 2015-07-22 21:12:44 +02:00
log2long.c remove obsolete SVN ID tags 2012-11-14 20:57:16 +01:00
slcan_attach.c slcan: added listen-only flag 2015-10-15 10:18:15 +02:00
slcand.c Include linux/sockios.h to fix musl build 2015-07-22 21:12:51 +02:00
slcanpty.c treewide: use if_nametoindex to avoid overflows 2015-06-30 21:00:04 +02:00
terminal.h remove obsolete SVN ID tags 2012-11-14 20:57:16 +01:00

README.md

SocketCAN userspace utilities and tools

CAN is a message-based network protocol designed for vehicles originally initially created by Robert Bosch GmbH. SocketCAN is a set of open source CAN drivers and a networking stack contributed by Volkswagen Research to the Linux kernel.

This package contains some userspace utilities for Linux SocketCAN subsystem: asc2log, bcmserver, canbusload, can-calc-bit-timing, candump, canfdtest, cangen, cangw, canlogserver, canplayer, cansend, cansniffer, isotpdump, isotprecv, isotpperf, isotpsend, isotpserver, isotpsniffer, isotptun, log2asc, log2long, slcan_attach, slcand and slcanpty.


Description copied from https://packages.debian.org/sid/can-utils