GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||
GeezerVison is showing github.com — Only mirror 127.0.0.1 to the IPv6 loopback in DnsQueryContextManager by tsegismont · Pull Request #18263 · netty/netty Conversation
Contributor
Motivation:
That setup is not hypothetical. On GitHub Actions hosted runners The second name server then hits the Without assertions enabled it is not harmless either: the second name server silently replaces the first one's mirror entry, so a response attributed to Modification:
This is not a breaking change: Result: Fixes #18249. Several name servers from 🤖 Generated with Claude Code
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsMotivation: DnsQueryContextManager registers every name server under its own address and under a "mirror" key of the other IP family, so that a response is still matched if its sender address is reported in that other family. For IPv4 the mirror key was ::1 whenever Inet4Address.isLoopbackAddress() returned true, which is the case for all of 127.0.0.0/8 and not just for 127.0.0.1. Two distinct loopback name servers therefore collapsed onto the same mirror key. That setup is not hypothetical: on GitHub Actions hosted runners /etc/resolv.conf lists the egress-proxy resolver on 127.0.0.100, the systemd-resolved stub on 127.0.0.53 and the platform DNS server, so the second name server hits "assert old == null : DnsQueryContextMap already exists for ::1:53" with -ea. Without assertions it silently replaced the first server's mirror entry, so a response attributed to ::1 was looked up in the wrong server's id space and dropped, turning the query into a timeout. Modification: - DnsQueryContextManager.getOrCreateContextMap: mirror to NetUtil.LOCALHOST6 only when the address equals NetUtil.LOCALHOST4. Every other IPv4 address, loopback or not, is mirrored to its own IPv4-compatible IPv6 address, as before. The mapping stays involutive, and the lookup of the name server's own address still happens before any mirror key is registered, so a name server that is configured in both families keeps sharing a single context map. - Add DnsQueryContextManagerTest covering the collision, the full name server list of a hosted runner, both loopback mirror directions, the IPv4-compatible mirror in both directions, and the shared context map when the mirror address is registered first. The regression test does not depend on -ea: it also asserts that neither loopback name server is reachable under the ::1 key, which is the functional symptom when assertions are disabled. Result: Several name servers from 127.0.0.0/8 can be configured without colliding on a single mirror key. Fixes netty#18249. Co-Authored-By: Claude Opus 5 <[email protected]>
normanmaurer
approved these changes
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
normanmaurer
added a commit
that referenced
this pull request
…ContextManager (#18265) Auto-port of #18263 to 4.1 Cherry-picked commit: 0197c31 --- Motivation: `DnsQueryContextManager` registers every name server under its own address and under a "mirror" key of the other IP family, so that a response is still matched if its sender address is reported in that other family. For IPv4 the mirror key was `::1` whenever `Inet4Address.isLoopbackAddress()` returned true, which is the case for all of `127.0.0.0/8` and not just for `127.0.0.1`. Two distinct loopback name servers therefore collapsed onto the same mirror key. That setup is not hypothetical. On GitHub Actions hosted runners `/etc/resolv.conf` lists the egress-proxy resolver on `127.0.0.100`, the systemd-resolved stub on `127.0.0.53` and the platform DNS server: ``` options edns0 trust-ad search <...>.internal.cloudapp.net nameserver 127.0.0.100 nameserver 127.0.0.53 nameserver 168.63.129.16 ``` The second name server then hits the `assert old == null` on the mirror key: ``` java.lang.AssertionError: DnsQueryContextMap already exists for localhost/0:0:0:0:0:0:0:1:53 at io.netty.resolver.dns.DnsQueryContextManager.getOrCreateContextMap(DnsQueryContextManager.java:129) at io.netty.resolver.dns.DnsQueryContextManager.add(DnsQueryContextManager.java:50) at io.netty.resolver.dns.DnsQueryContext.writeQuery(DnsQueryContext.java:212) ``` Without assertions enabled it is not harmless either: the second name server silently replaces the first one's mirror entry, so a response attributed to `::1` is looked up in the wrong server's id space and dropped, turning the query into a timeout. Modification: - `DnsQueryContextManager.getOrCreateContextMap`: mirror to `NetUtil.LOCALHOST6` only when the address equals `NetUtil.LOCALHOST4`. Every other IPv4 address, loopback or not, is mirrored to its own IPv4-compatible IPv6 address, as before. The mapping stays involutive, and the lookup of the name server's own address still happens before any mirror key is registered, so a name server that is configured in both families keeps sharing a single context map. - Add `DnsQueryContextManagerTest` covering the collision, the full name server list of a hosted runner, both loopback mirror directions, the IPv4-compatible mirror in both directions, and the shared context map when the mirror address is registered first. The regression test does not depend on `-ea`: it also asserts that neither loopback name server is reachable under the `::1` key, which is the functional symptom when assertions are disabled. This is not a breaking change: `DnsQueryContextManager` is package-private and no validation behaviour changes. Result: Fixes #18249. Several name servers from `127.0.0.0/8` can be configured without colliding on a single mirror key. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Thomas Segismont <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: Norman Maurer <[email protected]>
normanmaurer
added a commit
that referenced
this pull request
…ContextManager (#18266) Auto-port of #18263 to 5.0 Cherry-picked commit: 0197c31 --- Motivation: `DnsQueryContextManager` registers every name server under its own address and under a "mirror" key of the other IP family, so that a response is still matched if its sender address is reported in that other family. For IPv4 the mirror key was `::1` whenever `Inet4Address.isLoopbackAddress()` returned true, which is the case for all of `127.0.0.0/8` and not just for `127.0.0.1`. Two distinct loopback name servers therefore collapsed onto the same mirror key. That setup is not hypothetical. On GitHub Actions hosted runners `/etc/resolv.conf` lists the egress-proxy resolver on `127.0.0.100`, the systemd-resolved stub on `127.0.0.53` and the platform DNS server: ``` options edns0 trust-ad search <...>.internal.cloudapp.net nameserver 127.0.0.100 nameserver 127.0.0.53 nameserver 168.63.129.16 ``` The second name server then hits the `assert old == null` on the mirror key: ``` java.lang.AssertionError: DnsQueryContextMap already exists for localhost/0:0:0:0:0:0:0:1:53 at io.netty.resolver.dns.DnsQueryContextManager.getOrCreateContextMap(DnsQueryContextManager.java:129) at io.netty.resolver.dns.DnsQueryContextManager.add(DnsQueryContextManager.java:50) at io.netty.resolver.dns.DnsQueryContext.writeQuery(DnsQueryContext.java:212) ``` Without assertions enabled it is not harmless either: the second name server silently replaces the first one's mirror entry, so a response attributed to `::1` is looked up in the wrong server's id space and dropped, turning the query into a timeout. Modification: - `DnsQueryContextManager.getOrCreateContextMap`: mirror to `NetUtil.LOCALHOST6` only when the address equals `NetUtil.LOCALHOST4`. Every other IPv4 address, loopback or not, is mirrored to its own IPv4-compatible IPv6 address, as before. The mapping stays involutive, and the lookup of the name server's own address still happens before any mirror key is registered, so a name server that is configured in both families keeps sharing a single context map. - Add `DnsQueryContextManagerTest` covering the collision, the full name server list of a hosted runner, both loopback mirror directions, the IPv4-compatible mirror in both directions, and the shared context map when the mirror address is registered first. The regression test does not depend on `-ea`: it also asserts that neither loopback name server is reachable under the `::1` key, which is the functional symptom when assertions are disabled. This is not a breaking change: `DnsQueryContextManager` is package-private and no validation behaviour changes. Result: Fixes #18249. Several name servers from `127.0.0.0/8` can be configured without colliding on a single mirror key. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Thomas Segismont <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: Norman Maurer <[email protected]>
1 of 11 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsDevelopmentSuccessfully merging this pull request may close these issues. DnsQueryContextManager: "DnsQueryContextMap already exists" thrown when two IPv4 loopback name servers are configured
Uh oh!
There was an error while loading. Please reload this page. 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. | |||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |