musl/include
Rich Felker 85050ac5a2 getaddrinfo: add EAI_NODATA error code to distinguish NODATA vs NxDomain
this was apparently omitted long ago out of a lack of understanding of
its importance and the fact that POSIX doesn't specify it. despite not
being officially standardized, however, it turns out that at least
AIX, glibc, NetBSD, OpenBSD, QNX, and Solaris document and support it.

in certain usage cases, such as implementing a DNS gateway on top of
the stub resolver interfaces, it's necessary to distinguish the case
where a name does not exit (NxDomain) from one where it exists but has
no addresses (or other records) of the requested type (NODATA). in
fact, even the legacy gethostbyname API had this distinction, which we
were previously unable to support correctly because the backend lacked
it.

apart from fixing an important functionality gap, adding this
distinction helps clarify to users how search domain fallback works
(falling back in cases corresponding to EAI_NONAME, not in ones
corresponding to EAI_NODATA), a topic that has been a source of
ongoing confusion and frustration.

as a result of this change, EAI_NONAME is no longer a valid universal
error code for getaddrinfo in the case where AI_ADDRCONFIG has
suppressed use of all address families. in order to return an accurate
result in this case, getaddrinfo is modified to still perform at least
one lookup. this will almost surely fail (with a network error, since
there is no v4 or v6 network to query DNS over) unless a result comes
from the hosts file or from ip literal parsing, but in case it does
succeed, the result is replaced by EAI_NODATA.

glibc has a related error code, EAI_ADDRFAMILY, that could be used for
the AI_ADDRCONFIG case and certain NODATA cases, but distinguishing
them properly in full generality seems to require additional DNS
queries that are otherwise not useful. on glibc, it is only used for
ip literals with mismatching family, not for DNS or hosts file results
where the name has addresses only in the opposite family. since this
seems misleading and inconsistent, and since EAI_NODATA already covers
the semantic case where the "name" exists but doesn't have any
addresses in the requested family, we do not adopt EAI_ADDRFAMILY at
this time. this could be changed at some point if desired, but the
logic for getting all the corner cases with AI_ADDRCONFIG right is
slightly nontrivial.
2022-09-20 18:09:42 -04:00
..
arpa remove duplicate definitions of INET[6]_ADDRSTRLEN 2020-03-04 12:33:35 -05:00
net net/if_arp.h: add ARPHRD_RAWIP from linux v4.14 2018-02-22 18:47:49 -05:00
netinet netinet/in.h: add INADDR_DUMMY from linux v5.13 2022-03-08 17:21:26 -05:00
netpacket add PACKET_IGNORE_OUTGOING sockopt from linux v4.20 2019-03-13 12:32:19 -04:00
scsi
sys sys/ptrace.h: add PTRACE_GET_RSEQ_CONFIGURATION from linux v5.13 2022-03-08 17:21:26 -05:00
aio.h add time64 symbol name redirects to public headers, under arch control 2019-10-28 19:26:52 -04:00
alloca.h unconditonally define alloca as __builtin_alloca 2020-01-01 15:07:11 -05:00
alltypes.h.in fix regression with applications that expect struct winsize in ioctl.h 2020-08-30 16:47:40 -04:00
ar.h
assert.h
byteswap.h
complex.h
cpio.h
crypt.h
ctype.h suppress isascii() macro for C++ 2021-02-25 16:35:54 -05:00
dirent.h move struct dirent to bits header, allow NAME_MAX to vary 2020-01-25 23:08:55 -05:00
dlfcn.h add time64 redirect for, and redirecting implementation of, dlsym 2019-11-02 18:30:56 -04:00
elf.h ldso: support DT_RELR relative relocation format 2022-08-02 17:27:45 -04:00
endian.h make endian.h expose unprefixed macros, functions in standard profile 2019-10-17 16:26:22 -04:00
err.h
errno.h restore attribute((const)) to pthread_self and errno location decls 2018-10-16 14:10:27 -04:00
fcntl.h fcntl.h: add AT_RECURSIVE from linux v5.2 2019-09-11 10:40:31 -04:00
features.h add time64 symbol name redirects to public headers, under arch control 2019-10-28 19:26:52 -04:00
fenv.h
float.h
fmtmsg.h
fnmatch.h
ftw.h
getopt.h
glob.h glob: implement GLOB_TILDE and GLOB_TILDE_CHECK 2019-08-06 14:03:31 -04:00
grp.h
iconv.h
ifaddrs.h
inttypes.h
iso646.h
langinfo.h add _NL_LOCALE_NAME extension to nl_langinfo 2017-07-31 23:08:27 -04:00
lastlog.h
libgen.h
libintl.h
limits.h move struct dirent to bits header, allow NAME_MAX to vary 2020-01-25 23:08:55 -05:00
link.h
locale.h define NULL as nullptr when used in C++11 or later 2021-11-29 17:45:21 -05:00
malloc.h
math.h define FP_FAST_FMA* when fma* can be inlined 2019-04-17 13:02:47 -04:00
memory.h
mntent.h
monetary.h
mqueue.h add time64 symbol name redirects to public headers, under arch control 2019-10-28 19:26:52 -04:00
netdb.h getaddrinfo: add EAI_NODATA error code to distinguish NODATA vs NxDomain 2022-09-20 18:09:42 -04:00
nl_types.h
paths.h
poll.h add time64 symbol name redirects to public headers, under arch control 2019-10-28 19:26:52 -04:00
pthread.h add pthread_getname_np function 2021-04-20 15:34:30 -04:00
pty.h
pwd.h
regex.h
resolv.h
sched.h sched.h: add CLONE_NEWTIME from linux v5.6 2020-09-09 17:20:34 -04:00
search.h
semaphore.h add time64 symbol name redirects to public headers, under arch control 2019-10-28 19:26:52 -04:00
setjmp.h guard against compilers failing to handle setjmp specially by default 2021-02-22 15:52:21 -05:00
shadow.h
signal.h signal.h: add new sa_flags from linux v5.11 2022-03-08 17:19:49 -05:00
spawn.h add posix_spawn [f]chdir file actions 2019-08-30 16:21:36 -04:00
stdalign.h
stdarg.h
stdbool.h
stdc-predef.h define __STDC_UTF_{16,32}__ macros 2021-04-19 09:49:20 -04:00
stddef.h define NULL as nullptr when used in C++11 or later 2021-11-29 17:45:21 -05:00
stdint.h
stdio_ext.h
stdio.h define NULL as nullptr when used in C++11 or later 2021-11-29 17:45:21 -05:00
stdlib.h define NULL as nullptr when used in C++11 or later 2021-11-29 17:45:21 -05:00
stdnoreturn.h
string.h define NULL as nullptr when used in C++11 or later 2021-11-29 17:45:21 -05:00
strings.h fix strings.h feature test macro usage due to missing features.h 2022-08-01 13:57:11 -04:00
stropts.h
syscall.h
sysexits.h
syslog.h
tar.h expose TSVTX unconditionally in tar.h 2019-03-13 10:42:57 -04:00
termios.h fix regression with applications that expect struct winsize in ioctl.h 2020-08-30 16:47:40 -04:00
tgmath.h
threads.h add time64 symbol name redirects to public headers, under arch control 2019-10-28 19:26:52 -04:00
time.h define NULL as nullptr when used in C++11 or later 2021-11-29 17:45:21 -05:00
uchar.h uchar.h: define char16_t and char32_t for old c++ 2018-07-17 22:24:03 -04:00
ucontext.h fix signature of function accepted by makecontext 2019-04-05 17:29:00 -04:00
ulimit.h
unistd.h add sysconf keys/values for signal stack size 2022-08-26 10:20:46 -04:00
utime.h add time64 symbol name redirects to public headers, under arch control 2019-10-28 19:26:52 -04:00
utmp.h
utmpx.h adjust utmpx struct layout for time64, 32-/64-bit arch compat 2019-12-22 12:37:16 -05:00
values.h
wait.h
wchar.h define NULL as nullptr when used in C++11 or later 2021-11-29 17:45:21 -05:00
wctype.h
wordexp.h