Skip to content

net: listen on an unspecified address binds any family - #10

Open
david-yu wants to merge 1 commit into
ipv6/08-address-typesfrom
ipv6/09-listen-unspecified
Open

david-yu wants to merge 1 commit into
ipv6/08-address-typesfrom
ipv6/09-listen-unspecified

Conversation

@david-yu

@david-yu david-yu commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Part 9 of 10 of the IPv6 series, split out of #1 and rebased on current scylladb/seastar master. Based on #9, so the diff here is only this PR's commit.

Why

A default-constructed socket_address has been AF_UNSPEC since 453d531b0 (scylladb/seastar#694), but listen() still turned it into 0.0.0.0, so listen(socket_address{}) ("any address, any port") was unreachable on an IPv6-only host.

What

  • net: listen on an unspecified address binds any family, not just IPv4 (20cade105) — binds [::] with IPV6_V6ONLY off where the stack has IPv6, so IPv4 peers still arrive, and 0.0.0.0 where it does not, both through inet_address(family) (669685c78) as the IPv4 branch always did. An explicitly set listen_options::ipv6_only is kept.

Behaviour change

On a host with IPv6, listen(socket_address{}) binds [::] instead of 0.0.0.0. IPv4 clients still connect; the socket reports them as ::ffff:a.b.c.d, and http_server/rpc::server unmap them (PR 4).

Testing

Listening on socket_address{} and connecting from 127.0.0.1: the listener is AF_INET6 on the any-address, and the peer reads as IPv4 after unmapping.

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, websocket and unix_domain with SEASTAR_TEST_REQUIRE_IPV6=1, so none of their IPv6 cases skipped.

Stack

  1. tests, ci: fail instead of skip when IPv6 is expected #2 tests, ci: fail instead of skip when IPv6 is expected
  2. dns: reach nameservers over IPv6 #3 dns: reach nameservers over IPv6
  3. dns: literals for any family, c-ares error text, link-local nameservers #4 dns: literals for any family, c-ares error text, link-local nameservers
  4. net, http, rpc: dual-stack listeners (IPV6_V6ONLY, IPv4-mapped peers) #5 net, http, rpc: dual-stack listeners (IPV6_V6ONLY, IPv4-mapped peers)
  5. net: IPv6 zones and strict literal parsing #6 net: IPv6 zones and strict literal parsing
  6. tls: do not send IP literals in the SNI extension #7 tls: do not send IP literals in the SNI extension
  7. tls: verify server_name on OpenSSL, opt-in #8 tls: verify server_name on OpenSSL, opt-in
  8. net: ipv6_addr equality and hash, ipv4_addr(socket_address) throws instead of terminating #9 net: ipv6_addr equality and hash, ipv4_addr(socket_address) throws instead of terminating
  9. net: listen on an unspecified address binds any family #10 net: listen on an unspecified address binds any family ← this PR
  10. http: build the Host header from an address in authority form #11 http: build the Host header from an address in authority form

A default-constructed socket_address has been AF_UNSPEC since 453d531,
but posix_network_stack::listen still turned it into 0.0.0.0, so
listen(socket_address{}) — "any address, any port" — was unreachable on
an IPv6-only host, with no way to ask for any family.

Bind [::] instead where the stack has IPv6, with IPV6_V6ONLY off so IPv4
peers still arrive, and keep 0.0.0.0 on a host without IPv6. A caller
who wants exactly one family passes that family's any-address
(inet_address(family), ipv4_addr(port), ipv6_addr(port)) or sets
listen_options::ipv6_only, which is kept here if it was set explicitly.

Tested by listening on socket_address{} and connecting from 127.0.0.1:
the listener is AF_INET6 and on the any-address, and the peer reads as
IPv4 after unmapping.
@david-yu
david-yu force-pushed the ipv6/09-listen-unspecified branch from 6873997 to 20cade1 Compare September 25, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant