Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 06 Jun 2008 08:40:10 +0100
From:      "Bruce M. Simpson" <bms@FreeBSD.org>
To:        =?ISO-8859-1?Q?Marc_L=F6rner?= <marc.loerner@hob.de>
Cc:        freebsd-net@freebsd.org, Rui Paulo <rpaulo@FreeBSD.org>
Subject:   Re: Probable Bug in tcp.h
Message-ID:  <4848E9DA.8090802@FreeBSD.org>
In-Reply-To: <200806060930.28527.marc.loerner@hob.de>
References:  <200806051712.47048.marc.loerner@hob.de>	<20080605155646.GC6864@epsilon.local> <200806060930.28527.marc.loerner@hob.de>

next in thread | previous in thread | raw e-mail | index | archive | help

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?




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4848E9DA.8090802>