From: "Theo de Raadt" Subject: Re: netstat(1): get rid of inet_aton To: tech@openbsd.org Date: Mon, 12 Aug 2024 09:21:22 -0600 Florian Obser wrote: > On 2024-08-12 00:07 +02, Kirill A. Korinsky wrote: > > > > The current code handles the case where localhost is 127.0.0.2 and > > /etc/hosts has relevant records. > > not since rev 1.60 of lib/libc/asr/getaddrinfo_async.c > > > > > As far as I can see in RFC 1122 and 6890, any address from 127.0.0.0/8 can > > be used as a loopback. > > > > Am I missing the place where 127.0.0.1 is required to be the only possible > > localhost address? > > > > The commit message quotes this: > > RFC 6761, 6.3 Domain Name Reservation Considerations for "localhost.": > 3. Name resolution APIs and libraries SHOULD recognize localhost > names as special and SHOULD always return the IP loopback address > for address queries and negative responses for all other query > types. Name resolution APIs SHOULD NOT send queries for > localhost names to their configured caching DNS server(s). > > Now, you could hagle a bit what "the IP loopback address" actually > means. On OpenBSD it means 127.0.0.1 for IPv4 and ::1 for IPv6. There's nothing to haggle about, because getaddrinfo_async.c hard-codes 127.0.0.1. It does not open a socket and ioctl to see what "lo0" is configured for.