Probable Bug in tcp.h
Bruce M. Simpson
bms at FreeBSD.org
Fri Jun 6 07:40:13 UTC 2008
Marc Lörner wrote:
> th_x2 and th_off are created as a bitfield. But C-Standard says that bitfields
> are accessed as integers => 4-bytes
>
> On itanium integers are read with ld4-command but the address of th_x2/th_off
> may not be aligned to 4-bytes => we get an unaligned reference fault.
>
> If we'd change to 1 byte-accesses => I won't get any misaligned faults
> anymore.
>
It's worth noting that Linux implements its version of tcphdr using a
32-bit-wide bitfield and the TCP header flags live there as bits instead
of as integer quantities.
I think it should be OK to change the u_int to a uint8_t as NetBSD has.
The problem with bitfields in "signed char" is that they can become
unintentionally sign extended on a read, and for many years compilers
only supported "char", not "unsigned char".
Does anyone see a reason why we should not make this change?
More information about the freebsd-net
mailing list