Conversation
This was referenced Sep 25, 2026
david-yu
added this pull request to stack #12
September 25, 2026 16:16
inet_address::invalid_scope (0xffffffff), from the zone support added in 3e479dc, is an in-memory "no zone" marker, but socket_address wrote it straight into sin6_scope_id, and addr() copied the kernel's sin6_scope_id (0 for the common no-zone case) straight back into _scope. Every accepted IPv6 peer therefore printed as [addr%0]:port and reported scope() == 0, while connect()/sendto() were handed a bogus zone for link-local destinations. Translate at the boundary: write 0 for invalid_scope, read 0 as invalid_scope, and key the link-local zone lookup in resolve_outgoing_address on sin6_scope_id == 0. Also fix the inet_pton result check in the /proc/net/ipv6_route parser (0 means 'not an address', not < 0), pin the sin_port/sin6_port aliasing that port() relies on with a static_assert, and document that socket_address equality deliberately ignores the zone (scylladb#704).
…rts must fit
inet_address::parse_numerical dropped a %zone that matched no interface
on the box, leaving the literal silently unscoped, and accepted a zone on
an IPv4 literal. Follow RFC 4007 §11 instead: an interface name that
matches nothing makes the literal invalid, and a numeric zone is kept as
given so literals written for another host survive.
ipv6_addr(const std::string&) converted the port with std::stoul and a
bare uint16_t cast, so "[::1]:70000" became port 4464. Parse the
bracketed form explicitly, range-check the port and reject stray text
after the bracket; an unbracketed string is the address alone ("::1:9092"
is a valid address, so it cannot carry a port). Zoned literals still
throw: ipv6_addr has no field for a zone, which the header now says.
david-yu
force-pushed
the
ipv6/05-zones-literals
branch
from
September 25, 2026 18:11
bc8140f to
5d77646
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 5 of 10 of the IPv6 series, split out of #1 and rebased on current
scylladb/seastarmaster. Based on #5, so the diff here is only this PR's 2 commits.Why
Zone support came with
3e479dc9e(scylladb/seastar#692), and link-local destinations get a zone picked automatically since75e189c6b. Two things around it are still off:inet_address::invalid_scope(0xffffffff), an in-memory "no zone" marker, was written intosin6_scope_id, and the kernel's 0 came back as zone 0, so every accepted IPv6 peer printed as[addr%0]:port.%zonethat matched no local interface was dropped silently, a zone was accepted on an IPv4 literal, and[::1]:70000became port 4464.What
6dadac58b) — translate at thesockaddr_in6boundary; also fixes theinet_ptonresult check in the/proc/net/ipv6_routeparser.5d7764650) — RFC 4007 §11: an unknown interface name makes the literal invalid, a numeric zone is kept as given; the port is range-checked.Equality still ignores the zone, as decided in
scylladb/seastar#704; the header now says so.Behaviour change
[::1]:70000std::invalid_argumentfe80::1%no-such-ifaceTesting
On the core-aws VM (Ubuntu 24.04, GCC 14, C++23, RelWithDebInfo, GnuTLS and OpenSSL in one tree), this PR's head builds and passes
dns,ipv6,socket,rpc,httpd,httpd_openssl,tls,tls_openssl,network_interface,websocketandunix_domainwithSEASTAR_TEST_REQUIRE_IPV6=1, so none of their IPv6 cases skipped.Stack