Conversation
phirince
force-pushed
the
qname_minimisation_fix
branch
from
September 7, 2026 09:30
2e731bb to
ebb067a
Compare
Restores the terminal-label type-hiding "A" probe for non-A/DS qtypes (the original qname-minimisation behavior), but fixes the actual bug: when that probe gets a non-NOERROR response, the best-effort minimisation fallback now restores the query target's attempt budget before retrying with the real qtype, instead of leaving a single- nameserver zone with no usable target at all for the real query. Previously, the terminal A probe consumed the zone's only available query-target attempt. If that probe NXDOMAINed (e.g. a wildcard TXT-only zone with no A record), the real query had nowhere left to go, and unbound returned an avoidable SERVFAIL for a record that genuinely exists (GitHub issue NLnetLabs#1500). This also preserves an incidental but real-world-relevant benefit of the probe: some authoritative/GSLB-managed zones (e.g. CDN-backed CNAMEs on managed DNS providers) only answer certain record types correctly and NODATA on others (a pre-existing upstream misconfiguration). The terminal A probe, when it succeeds, can warm the resolver's cache with a CNAME the real qtype then chases directly to the target's own correctly-configured nameservers, avoiding an otherwise-reproducible NODATA. Removing the probe outright (as originally proposed) would have exposed that class of upstream issue as user-facing NODATA/outage risk instead of fixing the actual correctness bug -- so this keeps the probe but makes its failure mode safe. Fix: add iter_qstate.minimise_terminal_probe, set when the terminal probe is sent, and checked in the best-effort minimisation fallback (processQueryResponse) to call iter_dec_attempts() -- the same attempt-budget-restoration idiom already used elsewhere in this file for other fallback scenarios -- before falling back to the real qtype. Testing: - testdata/iter_resolve_minimised.rpl and testdata/iter_resolve_minimised_timeout.rpl reverted to their original content; both pass unmodified, confirming this change is additive and doesn't alter the existing successful-probe and probe-timeout scenarios. - testdata/iter_minimise_terminal_qtype.rpl rewritten: single-NS zone, outbound-msg-retry: 1, terminal A probe genuinely NXDOMAINs (no A record exists), asserts the real TXT query is still sent to the same nameserver afterward and succeeds. - Full make test regression suite passes. - Verified against both real-world repros: dig zurhbjwo-4.t.nessus.org TXT (the original single-NS/NXDOMAIN-probe case) and dig www.scholastic.ca AAAA (the GSLB/CNAME-masking case) both now succeed. Fixes GitHub issue NLnetLabs#1500.
phirince
force-pushed
the
qname_minimisation_fix
branch
from
September 8, 2026 12:10
ebb067a to
1cda01c
Compare
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.
Problem
When qname-minimisation is enabled, the terminal (final) query uses a generic
Aprobe instead of the actual requested qtype. If the authoritative zone has a single nameserver and noArecord exists at the target name, the NXDOMAIN response exhausts the only available server address, and unbound returns SERVFAIL — even though the record genuinely exists.Reproduction:
dig zurhbjwo-4.t.nessus.org TXTwith qname-minimisation enabled. The zonet.nessus.orghas exactly one NS (ns.t.nessus.org→206.205.255.205) and only a wildcard TXT record — no A record.Vanilla unbound log (broken):
Closes #1500. Related to #870.
Root cause
In
iterator/iterator.c(processQueryTargets,MINIMISE_STATE), the condition that stops minimisation at the terminal label was:When
labdiff == 1(the outgoing qname IS already the full target name), the code only switched to the real qtype forDSandAqueries. For all other qtypes (TXT, AAAA, MX, …) it sent the full qname withqtype=Aas a type-hiding probe. If that probe fails and the zone has few/no other usable addresses, the real query can be left with nowhere to go.Fix (revised)
An earlier version of this PR removed the terminal-label
Aprobe entirely for all qtypes. Testing surfaced a real downside to that approach: some authoritative/GSLB-managed zones (e.g. CDN-backed CNAMEs on managed DNS providers) only answer certain record types correctly and return NODATA on others -- a pre-existing upstream misconfiguration, independently confirmed against multiple such zones. The terminalAprobe, when it succeeds, incidentally warms the resolver's cache with aCNAMEthat the real qtype then chases directly to the target's own correctly-configured nameservers, avoiding an otherwise-reproducible NODATA. Removing the probe outright would have turned that pre-existing upstream gap into a user-facing NODATA/outage risk for anyone relying on it, instead of just fixing the actual correctness bug.This revised version keeps the terminal-label probe, but fixes the real problem: when that probe gets a non-NOERROR response, the existing best-effort qname-minimisation fallback (which already exists in
processQueryResponsefor exactly this purpose) now also restores the query target's attempt budget viaiter_dec_attempts()-- the same idiom already used elsewhere in this file for other fallback scenarios -- before retrying with the real qtype. A newiq->minimise_terminal_probeflag marks which outbound query is the terminal-label probe, so this restoration is scoped precisely to that case and doesn't touch intermediate-label minimisation behavior.Testing
testdata/iter_resolve_minimised.rplandtestdata/iter_resolve_minimised_timeout.rplare unchanged frommaster-- this fix doesn't alter their code paths (successful-probe and probe-timeout scenarios respectively), confirming the change is additive.testdata/iter_minimise_terminal_qtype.rplrewritten: single-NS zone,outbound-msg-retry: 1, terminalAprobe genuinely NXDOMAINs (no A record exists), asserts the realTXTquery is still sent to the same nameserver afterward and succeeds.make testregression suite passes.dig zurhbjwo-4.t.nessus.org TXT(the original single-NS/NXDOMAIN-probe case from the bug report) anddig www.scholastic.ca AAAA(a GSLB-zone case where the probe's cache-warming side effect avoids an unrelated upstream NODATA) both now succeed, including repeated back-to-back queries against the live zone.