Repository navigation
mod_http3: Bind the QUIC socket to the address given to Listen - #1069
Open
arturobernalg wants to merge 2 commits into
Open
arturobernalg wants to merge 2 commits into
arturobernalg wants to merge 2 commits into
Conversation
h3_socket_open() always bound the IPv6 dual-stack wildcard and took only the port, so with "Listen 127.0.0.1:443" HTTP/3 was still served on every address of the host, while TCP was not. Take the address from the Listen directives for the TCP port of the HTTP/3 host, or from every listener for a host without a port: a wildcard keeps the dual-stack wildcard, a single address is bound alone, in its own family. One QUIC socket cannot serve several addresses, so then HTTP/3 is not started and no Alt-Svc is sent. A graceful restart that changes the address binds the socket again. * modules/http3/h3_server.c (choose_quic_addr, h3_server_enabled): New. (h3_server_post_config): Take the configuration pool. Choose the address, or leave HTTP/3 off. Keep the bound address and bind again when it changes. (acquire_port, h3_child_init): Bind the chosen address. * modules/http3/h3_socket.c (h3_socket_open): Take the address to bind. * modules/http3/h3_hooks.c: Send no Alt-Svc while HTTP/3 is off. * modules/http3/h3_config.c: Pass the configuration pool. * modules/http3/README.md: Say so. * test/modules/http3/test_017_listen_address.py: New. * test/modules/http3/env.py (rewrite_test_conf): New.
jfclere
requested changes
Nov 23, 2026
|
|
||
| /* The address the QUIC socket binds, chosen in post_config; NULL while | ||
| * HTTP/3 is off. The children inherit it. */ | ||
| static apr_sockaddr_t* quic_addr = NULL; |
Contributor
There was a problem hiding this comment.
Shouldn't we add apr_sockaddr_t* quic_addr; next to h3_port in h3_config.h?
Member
Author
There was a problem hiding this comment.
Done in 24ccc22: quic_addr now lives in h3_server_conf, next to h3_port.
| /* The address the QUIC socket binds, chosen in post_config; NULL while | ||
| * HTTP/3 is off. The children inherit it. */ | ||
| static apr_sockaddr_t* quic_addr = NULL; | ||
| static int quic_refused = 0; |
Contributor
There was a problem hiding this comment.
Do we really need it, quic_addr=NULL has the same meaning no?
Member
Author
There was a problem hiding this comment.
Right, removed in 24ccc22. A NULL quic_addr now means HTTP/3 was not started, and the Alt-Svc check uses that.
Store the address chosen in post_config in each HTTP/3 host's configuration instead of a file static, and drop quic_refused: a NULL address already means HTTP/3 was not started.
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.
With
Listen 127.0.0.1:443, TCP is served on 127.0.0.1 only, but mod_http3 binds its UDP socket to::dual-stack and serves HTTP/3 on every address of the host: LAN, global IPv6, other loopback addresses.h3_socket_open()only ever took the port.This takes the address from the Listen directives for the TCP port of the HTTP/3 host, or from every listener for a host without a port such as the main server. A wildcard keeps today's dual-stack socket; a single address is bound alone, in its own family (V6ONLY for IPv6). One QUIC socket cannot serve several addresses, so in that case HTTP/3 is not started, an error says why, and no Alt-Svc is sent; TCP is unaffected. A graceful restart that changes the address binds the parent's socket again.
Serving one socket per address would need the module's one-socket-per-port design to change, so I kept to this; an explicit IPv4 plus IPv6 pair on the port currently leaves HTTP/3 off.
Tests:
test/modules/http3/test_017_listen_address.py, using 127.0.0.2 as the other address (Linux only). On trunk 6 of the 7 fail (the wildcard case passes, as it should); with this change all pass. Built like the CI mod_http3 job, 0 warnings. The rest of modules/http3: 148 passed; test_003_03 and test_106_01/02 fail at teardown on trunk as well, and test_016, 203, 204 and 205 need aioquic, which I don't have locally. test_202_01 (graceful restart) hung twice in 29 local runs with this change and not in 12 trunk runs; with a wildcard Listen the change takes the same path as trunk, so I think it is the existing graceful-restart race, but flagging it.No CVE: mod_http3 is trunk-only and unreleased.
@jfclere this touches the socket setup in h3_server.c, would you take a look?