git: a5a2e963f9a0 - stable/14 - in6.h: expose s6_addr* definitions to user level

From: Mike Karels <karels_at_FreeBSD.org>
Date: Fri, 10 May 2024 14:37:55 UTC
The branch stable/14 has been updated by karels:

URL: https://cgit.FreeBSD.org/src/commit/?id=a5a2e963f9a0a4bc65aa1c70a361243328e23961

commit a5a2e963f9a0a4bc65aa1c70a361243328e23961
Author:     Mike Karels <karels@FreeBSD.org>
AuthorDate: 2024-05-02 15:24:37 +0000
Commit:     Mike Karels <karels@FreeBSD.org>
CommitDate: 2024-05-10 14:37:43 +0000

    in6.h: expose s6_addr* definitions to user level
    
    The only element of of in6_addr that is specified in RFC 3493 or
    in POSIX.1-2017 is s6_addr, implemented via a #define to a union
    member.  However, FreeBSD and other BSD systems have additional
    definitions for the other union members, s6_addr{8,16,32} which
    are defined for the kernel and loader.  Some Linux applications
    also use them, and they seem to be allowed by the RFC and POSIX.
    Remove the current ifdefs, exposing the additional fields to user
    level, and replace with #if __BSD_VISIBLE.  Add an explanatory
    comment expanding on the previous "nonstandard" comment.
    
    Reviewed by:    bz
    Differential Revision:  https://reviews.freebsd.org/D44979
    
    (cherry picked from commit eb3dbf2dbe22ed6d4df54aebbf23f5b555a21cf1)
---
 sys/netinet6/in6.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h
index 78c9cd56ed60..ce3bbea6b8e6 100644
--- a/sys/netinet6/in6.h
+++ b/sys/netinet6/in6.h
@@ -102,7 +102,13 @@ struct in6_addr {
 };
 
 #define s6_addr   __u6_addr.__u6_addr8
-#if defined(_KERNEL) || defined(_STANDALONE) /* XXX nonstandard */
+#if __BSD_VISIBLE
+/*
+ * s6_addr is the only in6_addr element specified in RFCs 2553 and 3493,
+ * also in POSIX 1003.1-2017.  The following three definitions were not
+ * exposed to user programs in FreeBSD before 14.1, or in other BSDs,
+ * and are thus less portable than s6_addr.
+ */
 #define s6_addr8  __u6_addr.__u6_addr8
 #define s6_addr16 __u6_addr.__u6_addr16
 #define s6_addr32 __u6_addr.__u6_addr32