From owner-freebsd-net@freebsd.org Thu Jun 7 20:15:58 2018 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB926FEA57E for ; Thu, 7 Jun 2018 20:15:58 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from CAN01-TO1-obe.outbound.protection.outlook.com (mail-eopbgr670070.outbound.protection.outlook.com [40.107.67.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "Microsoft IT TLS CA 4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 530707CE7D for ; Thu, 7 Jun 2018 20:15:58 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from YTOPR0101MB0953.CANPRD01.PROD.OUTLOOK.COM (52.132.44.24) by YTOPR0101MB0858.CANPRD01.PROD.OUTLOOK.COM (52.132.50.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.841.15; Thu, 7 Jun 2018 20:15:56 +0000 Received: from YTOPR0101MB0953.CANPRD01.PROD.OUTLOOK.COM ([fe80::a860:9237:2e9f:f87f]) by YTOPR0101MB0953.CANPRD01.PROD.OUTLOOK.COM ([fe80::a860:9237:2e9f:f87f%3]) with mapi id 15.20.0820.015; Thu, 7 Jun 2018 20:15:56 +0000 From: Rick Macklem To: FreeBSD Net Subject: alignment of ai_addr in struct addrinfo Thread-Topic: alignment of ai_addr in struct addrinfo Thread-Index: AQHT/ptIPMhnOKQpvkyfQBuJqnt6Qg== Date: Thu, 7 Jun 2018 20:15:56 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=rmacklem@uoguelph.ca; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; YTOPR0101MB0858; 7:XxY+zGr+Rzp91XkbSobP9J41SczQ/AaGhAvsnxWlfq+KplL8FluCkr6RpX2oZ6+XBI6eYy+LcxmuoQfsNyl2O/pi2ydRFF0Sqr7H3Poj/roUqUMXLeUzv4EKugChZlt/h1v+2Ge7ZUt6B9HJfyJMh8Otev8vKATkPZEx5RET3NX3M/8NxLhwz+xymYEVUxghwROAu5SXrvG8YakiqQTpDIxOaUUD0y0+C0GkMY0bJV0OXIzS0spErs2lDK7OrFTD x-ms-exchange-antispam-srfa-diagnostics: SOS; x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989080)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(8990040)(2017052603328)(7153060)(7193020); SRVR:YTOPR0101MB0858; x-ms-traffictypediagnostic: YTOPR0101MB0858: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281529075)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:YTOPR0101MB0858; BCL:0; PCL:0; RULEID:; SRVR:YTOPR0101MB0858; x-forefront-prvs: 06968FD8C4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(39860400002)(396003)(39380400002)(376002)(199004)(189003)(786003)(5250100002)(105586002)(99286004)(14454004)(316002)(8936002)(6916009)(478600001)(106356001)(476003)(2906002)(7696005)(25786009)(86362001)(9686003)(2900100001)(33656002)(6436002)(186003)(97736004)(55016002)(305945005)(486006)(74316002)(53936002)(3280700002)(3660700001)(8676002)(74482002)(5660300001)(26005)(81156014)(102836004)(68736007)(81166006)(6506007); DIR:OUT; SFP:1101; SCL:1; SRVR:YTOPR0101MB0858; H:YTOPR0101MB0953.CANPRD01.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: uoguelph.ca does not designate permitted sender hosts) x-microsoft-antispam-message-info: Pn6aJW5s1pMYJdTazFF6zfuZMPe5rRZ2Bm/Tv9T1wjO0lkciN2TfYOU3n0dBZ7zljEa0ZOXtohY2+IibN+VVX3g4YKG3sRnxPJM0KU609eju2ElrE8Gqf/jgaY777XnNUzRwYWwPFT6AtwzvrpuiFUmQKweYD46IOhbu0Aj7gEYSlT4gq+nlqGMNhuQilTku spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 312a16df-40b7-4623-aef1-08d5ccb37a84 X-OriginatorOrg: uoguelph.ca X-MS-Exchange-CrossTenant-Network-Message-Id: 312a16df-40b7-4623-aef1-08d5ccb37a84 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jun 2018 20:15:56.8896 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: be62a12b-2cad-49a1-a5fa-85f4f3156a7d X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTOPR0101MB0858 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jun 2018 20:15:59 -0000 I have been doing "make universe" for the first time in a long time and I ran into an interesting one. I had code that looked like: struct sockaddr_in *sin; struct addrinfo *res; - did a getaddrinfo() and then after this I had: ... sin =3D (struct sockaddr_in *)res->ai_addr; For mips, it complained that the alignment requirement for "struct sockaddr= _in" is different than "struct sockaddr" related to the type cast. I've worked around this by: struct sockaddr_in sin; ... memcpy(&sin, res->ai_addr, sizeof(sin)); Is this a real problem or a compiler quirk? If it is real, it seems to me it would be nice if the alignment requirement= for "struct sockaddr" was the same as "struct sockaddr_in" and "struct sockaddr= _in6". Is there a "trick" that could be applied to "struct sockaddr" to force good= alignment? rick