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=F6rner wrote:
> th_x2 and th_off are created as a bitfield. But C-Standard says that bi=
tfields=20
> are accessed as integers =3D> 4-bytes
>
> On itanium integers are read with ld4-command but the address of th_x2/=
th_off=20
> may not be aligned to 4-bytes =3D> we get an unaligned reference fault.=

>
> If we'd change to 1 byte-accesses =3D> I won't get any misaligned fault=
s=20
> anymore.
>  =20

It's worth noting that Linux implements its version of tcphdr using a=20
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.=20
The problem with bitfields in "signed char" is that they can become=20
unintentionally sign extended on a read, and for many years compilers=20
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>