From nobody Sat Apr 27 03:33:03 2024 X-Original-To: freebsd-net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VRFYJ2Hqqz5HNTS for ; Sat, 27 Apr 2024 03:33:24 +0000 (UTC) (envelope-from bakul@iitbombay.org) Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VRFYH5zk0z4wWM for ; Sat, 27 Apr 2024 03:33:23 +0000 (UTC) (envelope-from bakul@iitbombay.org) Authentication-Results: mx1.freebsd.org; none Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6ed32341906so2739549b3a.1 for ; Fri, 26 Apr 2024 20:33:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iitbombay-org.20230601.gappssmtp.com; s=20230601; t=1714188795; x=1714793595; darn=freebsd.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vbzShtrXGD92SiM+M5voAl/KIcHF9TtNlPlseqzKsFQ=; b=twzot3phMZxeyXrK+3AaSPjkTAdyMH2SPD0Xk5HiylmFFKlUM18D8Di/Ji4+oPtnFm vBJh/qWfo9CmEiNjpAVf4uHCnjOn8fTszpbHFNuNLA7TymOjfxRgEpyqx1cQJQVJvYuU CTu/9Ve98rwGBWTJoCYQ1FSmgv9FvEK0lkDrY5GEBiXFdCfBuuCu+xpFlSn+DSLUdbro zWTdRHWd9Mf48DlW4yWxVySKxHHlV0lOJ5SU7Pcr+BcDU1xL5TMlemoCRsxgCrvuFts1 NfoPtqOOlKtNoF1SwNVl3rAGxXWOFOiAlSNS2OvOa4c1tBAcYmhFFHg6mg4OXC7hXq4X RARg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714188795; x=1714793595; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vbzShtrXGD92SiM+M5voAl/KIcHF9TtNlPlseqzKsFQ=; b=YOhmpUG5sLe3oQJQzJ9hcW54nMaTMXp2sqqGa8D9CGb1URFIjZcVO/pogj8qNwq+ix 5E3iyAX4xLkOUX2XtvyYUu2j50Io3pTWxIoUelna+LzvjZk74L/nysS+lB0j/9BgNcp+ BW9PynzXxZnGSv0fsBGqWhD7tGy3qg9ifwSiLDPNmT/B1kyn5WMXttndNSrl7ad7/jAn rqTzzqUU0VkQ5E++jjQC+7niI4HpaJnlaRgPSCRPfHwNTX6lk5OO9twC6A4wsWY9ZETJ 7wVQVI56tzQ5+o9JU4/m7I77doI52SHx3R4Hjqr/XzDdN9nYZK8e+q6n9PESTs2K+PN7 utlg== X-Forwarded-Encrypted: i=1; AJvYcCWG3zqPHohY+tnP6P0MfC2dyFqXkIZAUsmcZnbLI3wiqhYoL3xZX8BXUHcIgmKWnlUi9NOfUaHHLQ3k0HqJTymnNx0btPx1Aw== X-Gm-Message-State: AOJu0YzYLLj9vSGoMEzbzadaf452n6+shuMGeOe35+EOt73i1V3h6NYi zwOxSiehKia9d671zt5EEp6k8jXHYsU7miBLG6ugUdwW4ZfOZsFxzMvnD5BDgbntwb8mf5mw0TI = X-Google-Smtp-Source: AGHT+IFL7qDPOCN3+JyCPYgccjJgIrKFYH/bL7TFKBVNdKp4sUSbGaaaRDzQV/4LSaEJtmV9fHTOyA== X-Received: by 2002:a05:6a20:1b1c:b0:1a7:78d2:a142 with SMTP id ch28-20020a056a201b1c00b001a778d2a142mr4516862pzb.38.1714188795501; Fri, 26 Apr 2024 20:33:15 -0700 (PDT) Received: from smtpclient.apple (107-215-223-229.lightspeed.sntcca.sbcglobal.net. [107.215.223.229]) by smtp.gmail.com with ESMTPSA id e13-20020a17090ab38d00b0029c49ed3974sm15213877pjr.37.2024.04.26.20.33.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Apr 2024 20:33:14 -0700 (PDT) Content-Type: text/plain; charset=utf-8 List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@FreeBSD.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Subject: Re: Question about netinet6/in6.h From: Bakul Shah In-Reply-To: <4AF50212-9141-44FF-937F-A06AF8B15121@karels.net> Date: Fri, 26 Apr 2024 20:33:03 -0700 Cc: Warner Losh , FreeBSD Net Content-Transfer-Encoding: quoted-printable Message-Id: <54E63C68-2713-4247-A57C-D3AA9C571327@iitbombay.org> References: <229EB3F8-FB68-461C-BF1F-3B2846510EBA@karels.net> <4AF50212-9141-44FF-937F-A06AF8B15121@karels.net> To: Mike Karels X-Mailer: Apple Mail (2.3774.500.171.1.1) X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] X-Rspamd-Queue-Id: 4VRFYH5zk0z4wWM > On Apr 26, 2024, at 5:02=E2=80=AFPM, Mike Karels = wrote: >=20 > On 26 Apr 2024, at 18:06, Warner Losh wrote: >=20 >> On Fri, Apr 26, 2024 at 4:21=E2=80=AFPM Mike Karels = wrote: >>=20 >>> On 26 Apr 2024, at 15:49, Mike Karels wrote: >>>=20 >>>> On 26 Apr 2024, at 15:01, Warner Losh wrote: >>>>=20 >>>>> This has to be a FAQ >>>>>=20 >>>>> I'm porting a program from Linux, I often see an error like: >>>>> ./test/mock-ifaddrs.c:95:19: error: no member named 's6_addr32' in >>> 'struct >>>>> in6_addr' >>>>> 95 | ipv6->sin6_addr.s6_addr32[3] =3D 0; >>>>> | ~~~~~~~~~~~~~~~ ^ >>>>> but yet, we kinda define them, but only for the kernel and boot = loader: >>>>> /* >>>>> * IPv6 address >>>>> */ >>>>> struct in6_addr { >>>>> union { >>>>> uint8_t __u6_addr8[16]; >>>>> uint16_t __u6_addr16[8]; >>>>> uint32_t __u6_addr32[4]; >>>>> } __u6_addr; /* 128-bit IP6 address */ >>>>> }; >>>>>=20 >>>>> #define s6_addr __u6_addr.__u6_addr8 >>>>> #if defined(_KERNEL) || defined(_STANDALONE) /* XXX nonstandard */ >>>>> #define s6_addr8 __u6_addr.__u6_addr8 >>>>> #define s6_addr16 __u6_addr.__u6_addr16 >>>>> #define s6_addr32 __u6_addr.__u6_addr32 >>>>> #endif >>>>>=20 >>>>> I'm wondering if anybody why it's like that? git blame suggests we >>> imported >>>>> that from kame, with >>>>> only tweaks by people that are now deceased*.* >>>>>=20 >>>>> Why not just expose them? >>>>=20 >>>> Looks like only s6_addr is specified in the RFCs (2553 and 3493). = Oddly, >>>> though, the RFCs give an example implementation using that union = with >>>> different element names (like _S6_u8), and show the one #define. >>>> Similarly, POSIX specifies only s6_addr, but it allows other = members >>>> of the structure, so I don't see a problem with exposing them all = even >>>> in a POSIX environment. >>>>=20 >>>> I would have no objection to exposing all four definitions, = especially >>>> if Linux apps use them. >>>=20 >>> I put the change, along with an explanatory comment, in >>> https://reviews.freebsd.org/D44979. Comments welcome. >>>=20 >>=20 >> Thanks! I was testing a similar change, but I like yours better... = though >> maybe >> we should just make it visible when __BSD_VISIBLE is true.... I'll = have to >> look >> closely at what Linux does here... I think they have it always = visible, or >> at least >> musl does that (glibc is harder to track down due to the many layers = of >> indirection). >=20 > I thought briefly about __BSD_VISIBLE, but wasn't sure it was = necessary. > Let me know what you find out. I think it should work either way; = in.h > includes cdefs.h, so it's guaranteed to have been included. If the -ms-extensions option is used with gcc or clang, this ugliness = can go away as you can have nested anonymous unions or -structs and their = fields can be referenced as if they're directly in the parent struct/union. [IIRC this was present in Plan9 C from very early on. Also in C11 or = later]=