git: a467b5003320 - stable/13 - gai_strerror.[c3]: re-enable EAI_ADDRFAMILY, EAI_NODATA

From: Mike Karels <karels_at_FreeBSD.org>
Date: Sat, 03 Dec 2022 16:01:51 UTC
The branch stable/13 has been updated by karels:

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

commit a467b5003320b53ff153c91f8dccdf40f29e6181
Author:     Mike Karels <karels@FreeBSD.org>
AuthorDate: 2022-11-02 15:55:32 +0000
Commit:     Mike Karels <karels@FreeBSD.org>
CommitDate: 2022-12-03 15:16:24 +0000

    gai_strerror.[c3]: re-enable EAI_ADDRFAMILY, EAI_NODATA
    
    gai_strerror.c still has messages for EAI_ADDRFAMILY and EAI_NODATA,
    but not the man page.  Re-add to the man page, and update comments
    in the source.  Document the errors that are not in RFC 3493 or
    POSIX.
    
    Reviewed in https://reviews.freebsd.org/D37139 with related changes.
    
    Reviewed by:    bz, pauamma
    
    (cherry picked from commit e34adc71d3724a8b1add483310efbc63db9290a6)
---
 lib/libc/net/gai_strerror.3 | 17 ++++++++++++++---
 lib/libc/net/gai_strerror.c | 10 ++++++----
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/lib/libc/net/gai_strerror.3 b/lib/libc/net/gai_strerror.3
index d948083447db..2653fc6d371a 100644
--- a/lib/libc/net/gai_strerror.3
+++ b/lib/libc/net/gai_strerror.3
@@ -18,7 +18,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 23, 2018
+.Dd November 2, 2022
 .Dt GAI_STRERROR 3
 .Os
 .Sh NAME
@@ -42,7 +42,9 @@ or
 The following error codes and their meaning are defined in
 .In netdb.h :
 .Pp
-.Bl -tag -width ".Dv EAI_BADFLAGS" -offset indent -compact
+.Bl -tag -width ".Dv EAI_ADDRFAMILY" -offset indent -compact
+.It Dv EAI_ADDRFAMILY
+Address family for hostname not supported
 .It Dv EAI_AGAIN
 Name could not be resolved at this time
 .It Dv EAI_BADFLAGS
@@ -56,6 +58,8 @@ Non-recoverable failure in name resolution
 Address family was not recognized
 .It Dv EAI_MEMORY
 Memory allocation failure
+.It Dv EAI_NODATA
+No address associated with hostname
 .It Dv EAI_NONAME
 Name does not resolve
 .It Dv EAI_OVERFLOW
@@ -83,7 +87,14 @@ is out of range, an implementation-specific error message string is returned.
 .Xr getaddrinfo 3 ,
 .Xr getnameinfo 3
 .Sh STANDARDS
-.Bl -tag -width ".It RFC 2743"
+.Bl -tag -width ".It RFC 3493"
 .It RFC 3493
 Basic Socket Interface Extensions for IPv6
 .El
+.Pp
+EAI_ADDRFAMILY and EAI_NODATA were in previous RFCs, but not in RFC 3493.
+They are not in POSIX (IEEE Std 1003.1-2017).
+They were in
+.Fx
+before 5.2, and were re-added for 14.0.
+EAI_BADHINTS, EAI_OVERFLOW, and EAI_PROTOCOL are not in RFC 3493 or POSIX.
diff --git a/lib/libc/net/gai_strerror.c b/lib/libc/net/gai_strerror.c
index f168c3093735..276ba91b95fd 100644
--- a/lib/libc/net/gai_strerror.c
+++ b/lib/libc/net/gai_strerror.c
@@ -44,17 +44,19 @@ __FBSDID("$FreeBSD$");
 #endif
 #include "un-namespace.h"
 
-/* Entries EAI_ADDRFAMILY (1) and EAI_NODATA (7) are obsoleted, but left */
-/* for backwards compatibility with userland code prior to RFC2553bis-02 */
+/*
+ * Entries EAI_ADDRFAMILY (1) and EAI_NODATA (7) were omitted from RFC 3493,
+ * but are or may be used as extensions or in old code.
+ */
 static const char *ai_errlist[] = {
 	"Success",					/* 0 */
-	"Address family for hostname not supported",	/* 1: Obsolete */
+	"Address family for hostname not supported",	/* EAI_ADDRFAMILY */
 	"Name could not be resolved at this time",	/* EAI_AGAIN */
 	"Flags parameter had an invalid value",		/* EAI_BADFLAGS */
 	"Non-recoverable failure in name resolution",	/* EAI_FAIL */
 	"Address family not recognized",		/* EAI_FAMILY */
 	"Memory allocation failure", 			/* EAI_MEMORY */
-	"No address associated with hostname",		/* 7: Obsolete*/
+	"No address associated with hostname",		/* EAI_NODATA*/
 	"Name does not resolve",			/* EAI_NONAME */
 	"Service was not recognized for socket type",	/* EAI_SERVICE */
 	"Intended socket type was not recognized",	/* EAI_SOCKTYPE */