GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@tsegismont

@tsegismont tsegismont commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tsegismont @claude
Only mirror 127.0.0.1 to the IPv6 loopback in DnsQueryContextManager
0f676db
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, 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]>
This was referenced Nov 4, 2026
DnsQueryContextManager: "DnsQueryContextMap already exists" thrown when two IPv4 loopback name servers are configured #18249
Closed
Support TCP keep-alive probe options with the NIO transport eclipse-vertx/vert.x#6513
Merged
@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Nov 4, 2026
normanmaurer
normanmaurer approved these changes Nov 4, 2026
View reviewed changes
@testlens-app

testlens-app Bot commented Nov 4, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 0f676db
▶️ Tests: 41708 executed
⚪️ Checks: 30/30 completed


Learn more about TestLens at testlens.app/docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer
normanmaurer merged commit 0197c31 into netty:4.2 Nov 4, 2026
31 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added this to the 4.2.21.Final milestone Nov 4, 2026
@netty-project-bot netty-project-bot mentioned this pull request Nov 4, 2026
Auto-port 4.1: Only mirror 127.0.0.1 to the IPv6 loopback in DnsQueryContextManager #18265
Merged
@netty-project-bot

netty-project-bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #18265

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Nov 4, 2026
@netty-project-bot

netty-project-bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #18266

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot netty-project-bot mentioned this pull request Nov 4, 2026
Auto-port 5.0: Only mirror 127.0.0.1 to the IPv6 loopback in DnsQueryContextManager #18266
Merged
@github-actions github-actions Bot removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Nov 4, 2026
@tsegismont

tsegismont commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @normanmaurer !

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tsegismont
tsegismont deleted the dns-loopback-mirror-key-18249 branch November 5, 2026 09:50
@vietj

vietj commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

FWIW we used this work around in our CI temporarily : eclipse-vertx/vert.x#6518

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 Nov 5, 2026
@netty-project-bot @tsegismont
@claude @normanmaurer
Auto-port 4.1: Only mirror 127.0.0.1 to the IPv6 loopback in DnsQuery…
4a0498d
…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 Nov 5, 2026
@netty-project-bot @tsegismont
@claude @normanmaurer
Auto-port 5.0: Only mirror 127.0.0.1 to the IPv6 loopback in DnsQuery…
130f908
…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]>
@lhotari lhotari mentioned this pull request Nov 17, 2026
[improve][build] Upgrade Netty to 4.2.21.Final to restore the aarch64 glibc floor and pick up bug fixes apache/pulsar#27654
Merged
1 of 11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@normanmaurer normanmaurer normanmaurer approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.2.21.Final

Development

Successfully 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.

4 participants

@tsegismont @netty-project-bot @vietj @normanmaurer
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.