|
|
Message-ID: <1a155af0984.640f3471785851.5285478396862105130@soss.website>
Date: Mon, 19 Oct 2026 14:41:37 -0500
From: Skye Soss <skye@...s.website>
To: "musl" <musl@...ts.openwall.com>
Subject: [PATCH] getaddrinfo: link-local scope for IPv4 addresses
RFC 6724 section 3.2 assigns the IPv4 loopback prefix (127/8) and the
IPv4 link-local prefix (169.254/16) as having link-local scope.
This changes the order of some getaddrinfo queries as IPv4 addresses in
those prefixes will now sort lower than IPv6 ULAs.
---
src/network/lookup_name.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/network/lookup_name.c b/src/network/lookup_name.c
index 35218185..6b7ed85e 100644
--- a/src/network/lookup_name.c
+++ b/src/network/lookup_name.c
@@ -277,6 +277,10 @@ static int scopeof(const struct in6_addr *a)
if (IN6_IS_ADDR_LINKLOCAL(a)) return 2;
if (IN6_IS_ADDR_LOOPBACK(a)) return 2;
if (IN6_IS_ADDR_SITELOCAL(a)) return 5;
+ if (IN6_IS_ADDR_V4MAPPED(a)) {
+ if (a->s6_addr[12] == 127) return 2;
+ if (a->s6_addr[12] == 169 && a->s6_addr[13] == 254) return 2;
+ }
return 14;
}
--
2.55.0
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.