Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Feb 2010 10:05:10 -0800
From:      "Li, Qing" <qing.li@bluecoat.com>
To:        "M. Warner Losh" <imp@bsdimp.com>, <net@freebsd.org>
Subject:   RE: struct sockaddr * and alignment
Message-ID:  <B583FBF374231F4A89607B4D08578A43046737A7@bcs-mail03.internal.cacheflow.com>
References:  <20100209.103411.506052712871889475.imp@bsdimp.com>

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

>
> Sure enough, that fixes this warning.  Yea.  But, sadly, it causes
> other problems.  If you look at sbin/atm/atmconfig/natm.c you'll see
> code like:
>=20
> static void
> store_route(struct rt_msghdr *rtm)
> {
> ...
> 	char *cp
> 	struct sockaddr *sa;
> 	...
>=20
> 	cp =3D (char *)(rtm + 1);
> ...
> 			sa =3D (struct sockaddr *)cp;
> 			cp +=3D roundup(sa->sa_len, sizeof(long));
> ...
>=20
> which breaks because we're now casting from an __aligned(1) char * to
> an __aligned(8) sockaddr *.

> And it is only rounding the size of the structure to long, rather than
> int64 like sockaddr_storage suggests is the proper alignment.  But I
> haven't looked in the kernel to see if there's an issue there with
> routing sockets or not.
>=20

In the kernel route.h, the macro SA_SIZE is used by the routing socket
code and may the root of the problem.

-- Qing






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