Repository navigation
core: Fix ListenCoresBucketsRatio losing IPv6 on duplicated listeners - #1042
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
arturobernalg
force-pushed
the
fix/bz69804-listencbratio-ipv6-family
branch
from
November 16, 2026 07:43
5b0a29a to
9a3b3f6
Compare
|
Thank you. I'm the poster of bug report to apache bugzilla. If needed, the workaround is to ONLY listen on IPv6 (which also accepts IPv4 connections) # IPv6 listen to workaround bug: https://bz.apache.org/bugzilla/show_bug.cgi?id=69804
# Listen on port 80
Listen [::]:80
# Listen on port 443 if mod_ssl is enabled
<IfModule mod_ssl.c>
Listen [::]:443
</IfModule>
# Listen on port 443 if mod_gnutls is enabled
<IfModule mod_gnutls.c>
Listen [::]:443
</IfModule> |
Member
|
Looks good. I think we could also use: to avoid a DNS resolution (and preserve multiple addresses for e.g. |
ap_duplicate_listeners() resolved each listener's hostname again with apr_sockaddr_info_get(hostname, APR_UNSPEC, ...) to create the extra per-bucket sockets, so a duplicate could bind a different address than the original listener: - for a wildcard "Listen <port>", the duplicated buckets came back as plain IPv4 sockets while the original was IPv6 dual-stack, leaving a single socket able to accept IPv6 connections; - for a link-local "Listen [fe80::...%iface]", the scope was lost and the bind failed with EINVAL, so httpd did not start. Copy each listener's bound address with apr_sockaddr_info_copy() instead, as suggested by Yann, and keep a lookup with the listener's family for APR < 1.6. PR: 69804
arturobernalg
force-pushed
the
fix/bz69804-listencbratio-ipv6-family
branch
from
November 30, 2026 13:14
9a3b3f6 to
b783b44
Compare
Member
Author
|
Thanks Yann, done. The copy also fixes a link-local "Listen [fe80::...%iface]": the new lookup lost the scope, so the duplicated listeners failed to bind (EINVAL) and httpd did not start. Test added. |
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.
ap_duplicate_listeners()re-resolves each original listener's address withapr_sockaddr_info_get(hostname, APR_UNSPEC, ...)to create the extra per-bucket sockets. For a wildcardListen <port>(hostname is NULL),APR_UNSPECleaves the resolution to the system, which can return a different family than the original listener actually bound (IPv6 dual-stack on Linux here): all duplicated buckets came back as plain IPv4 sockets, leaving only the original socket able to accept IPv6 connections.Pass the original listener's own family instead of APR_UNSPEC, so every duplicated bucket matches it.
Verified on a real server: with
Listen <port>+ListenCoresBucketsRatio 1(16 cores), before the fixssshowed 15 IPv4 sockets and 1 IPv6 socket for the port; after the fix, all 16 are IPv6. Added a pytest regression test asserting this via/proc/net/tcp[6].PR: https://bz.apache.org/bugzilla/show_bug.cgi?id=69804
Checklist: not a security report (SECURITY.md); follows the style guide; no new log messages added; changes-entries/69804.txt included; pytest test added under test/modules/core.