From owner-freebsd-net@FreeBSD.ORG Tue Feb 9 18:09:03 2010 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 49DC5106566B for ; Tue, 9 Feb 2010 18:09:03 +0000 (UTC) (envelope-from qing.li@bluecoat.com) Received: from whisker.bluecoat.com (whisker.bluecoat.com [216.52.23.28]) by mx1.freebsd.org (Postfix) with ESMTP id 347488FC0C for ; Tue, 9 Feb 2010 18:09:01 +0000 (UTC) Received: from bcs-mail03.internal.cacheflow.com ([10.2.2.95]) by whisker.bluecoat.com (8.14.2/8.14.2) with ESMTP id o19I8ijP025933; Tue, 9 Feb 2010 10:08:44 -0800 (PST) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Tue, 9 Feb 2010 10:05:10 -0800 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: struct sockaddr * and alignment Thread-Index: Acqpr4wkT9PnCl9mR4yZk0PbiugUKwAAt7/2 References: <20100209.103411.506052712871889475.imp@bsdimp.com> From: "Li, Qing" To: "M. Warner Losh" , Cc: Subject: RE: struct sockaddr * and alignment X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Feb 2010 18:09:03 -0000 > > 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