Skip to content

Update CNAME resolution - #1518

Merged
marc-vanderwal merged 9 commits into
zonemaster:developfrom
tgreenx:update-cname
Sep 25, 2026
Merged

marc-vanderwal merged 9 commits into
zonemaster:developfrom
tgreenx:update-cname

Conversation

@tgreenx

@tgreenx tgreenx commented Apr 7, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

This PR slightly updates the CNAME resolution of Engine's recursor. See the Changes section below.
Updated test scenarios are defined in zonemaster/zonemaster#1477.

Context

zonemaster/zonemaster#1477

Also fixes zonemaster/zonemaster#1505

Changes

  • Zonemaster::Engine::Recursor::_resolve_cname() now returns undef when the CNAME resolution fails, along with new message tags: CNAME_UNRESOLVABLE (ERROR level) and CNAME_TO_NODATA (DEBUG level)
  • Fix case-sensitiveness of CNAME records
  • Update unit tests:
    • Move the content of scenario TOO-LONG-CNAME-CHAIN to a new scenario TOO-MANY-CNAME,
    • Update scenario TOO-LONG-CNAME-CHAIN to check for tag CNAME_CHAIN_TOO_LONG instead
    • Add scenario UNRESOLVABLE-CNAME
    • Add scenario CNAME-CHAIN-TO-NODATA

How to test this PR

Unit tests are updated and should pass.

@tgreenx tgreenx added this to the v2026.1 milestone Apr 7, 2026
@tgreenx tgreenx added V-Patch Versioning: The change gives an update of patch in version. RC-Fixes Release category: Fixes. labels Apr 7, 2026

@marc-vanderwal marc-vanderwal left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, so good.

Comment thread lib/Zonemaster/Engine/Recursor.pm Outdated
Comment thread t/recursor-A.t Outdated
Comment thread lib/Zonemaster/Engine/Recursor.pm
@marc-vanderwal

Copy link
Copy Markdown
Contributor

The CNAME_UNRESOLVABLE tag is output in some cases where the final query for a CNAME chain gives NODATA. That case can happen fairly frequently and should simply be treated like a negative response (i.e. NXDOMAIN), not like a resolution failure (as if we had gotten SERVFAIL).

I’d suggest a different name for that tag. How about CNAME_TO_NODATA?

@matsduf

matsduf commented May 26, 2026

Copy link
Copy Markdown
Contributor

I’d suggest a different name for that tag. How about CNAME_TO_NODATA?

It think that is a good suggestion. Should there be another tag, CNAME_TO_NXDOMAIN?

For me CNAME_UNRESOLVABLE sounds like we cannot resolve the CNAME record.

@marc-vanderwal

Copy link
Copy Markdown
Contributor

Yes, a CNAME_TO_NXDOMAIN might make sense too.

In any case, I don’t think the ERROR level is appropriate for these tags because they do not indicate a problem so severe that the zone is unresolvable.

@matsduf

matsduf commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@tgreenx, will you fix the conflict?

@tgreenx

tgreenx commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@tgreenx, will you fix the conflict?

@matsduf @marc-vanderwal done, please re-review.

@tgreenx

tgreenx commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

I’d suggest a different name for that tag. How about CNAME_TO_NODATA?

Added.

I’d suggest a different name for that tag. How about CNAME_TO_NODATA?

It think that is a good suggestion. Should there be another tag, CNAME_TO_NXDOMAIN?

Not needed, NXDOMAIN responses are already handled by the calling method (_recurse()).

marc-vanderwal
marc-vanderwal previously approved these changes Jun 10, 2026
Comment thread lib/Zonemaster/Engine/Recursor.pm Outdated
Comment thread lib/Zonemaster/Engine/Recursor.pm
Comment thread lib/Zonemaster/Engine/Recursor.pm
@tgreenx tgreenx modified the milestones: v2026.1, v2026.1.1 Jun 11, 2026
@marc-vanderwal
marc-vanderwal dismissed their stale review June 24, 2026 11:46

There’s a subtle bug that I missed when reviewing. I’ll propose a change.

Comment thread lib/Zonemaster/Engine/Recursor.pm Outdated
tgreenx and others added 2 commits September 1, 2026 16:45
- `Zonemaster::Engine::Recursor::_resolve_cname()` now returns undef when the CNAME resolution fails, along with a new message tag: `CNAME_UNRESOLVABLE`
- Update unit tests: move the content of scenario `TOO-LONG-CNAME-CHAIN` to a new scenario `TOO-MANY-CNAME`, and update scenario `TOO-LONG-CNAME-CHAIN` to check for tag `CNAME_CHAIN_TOO_LONG` instead
Co-authored-by: Marc van der Wal <103426270+marc-vanderwal@users.noreply.github.com>
@tgreenx tgreenx linked an issue Sep 1, 2026 that may be closed by this pull request
Comment thread lib/Zonemaster/Engine/Recursor.pm Outdated
Comment thread lib/Zonemaster/Engine/Recursor.pm
tgreenx and others added 2 commits September 22, 2026 19:39
@tgreenx
tgreenx requested a review from matsduf September 22, 2026 17:41
Comment thread lib/Zonemaster/Engine/Recursor.pm Outdated
Comment thread lib/Zonemaster/Engine/Recursor.pm Outdated
Comment thread lib/Zonemaster/Engine/Recursor.pm Outdated

=item CNAME_LOOP_INNER

This message tag indicates that there is a loop in the CNAME RRset of the current response.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what you mean. All members of an RRset has always the same owner name. Is the following what you mean?

Suggested change
This message tag indicates that there is a loop in the CNAME RRset of the current response.
This message tag indicates that there is a loop in the CNAME record, i.e. the target name is identical to the owner name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, rather that there is a loop in the CNAME chain from within a single DNS response, e.g.:

example.tld           CNAME   target1.example.tld
target1.example.tld   CNAME   example.tld

Comment thread lib/Zonemaster/Engine/Recursor.pm Outdated

=item CNAME_LOOP_OUTER

This message tag indicates that the CNAME target has already been followed in a previous lookup.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear. Is the following what you mean?

Suggested change
This message tag indicates that the CNAME target has already been followed in a previous lookup.
This message tag indicates that the target name of the last CNAME record in a chain is identical to a previous CNAME record in the same chain.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess yes, but specifically when doing additional CNAME lookups. So it is a loop too, but not from within a single response (i.e lookup) this time but another one, e.g:

Query 1 (example.tld) -> Response 1:

example.tld     CNAME   example.other

Query 2 (example.other) -> Response 2:

example.other   CNAME   example.tld

Comment thread lib/Zonemaster/Engine/Recursor.pm Outdated

=item CNAME_NO_MATCH

This message tag indicates that there is a record of the requested type but with different owner name than the CNAME target.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this refer to the answer section? That it contains a CNAME record and another DNS record matching the QTYPE but not the CNAME target name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly.

Comment thread lib/Zonemaster/Engine/Recursor.pm Outdated
Comment thread lib/Zonemaster/Engine/Recursor.pm Outdated
Comment thread lib/Zonemaster/Engine/Recursor.pm Outdated
Co-authored-by: Mats Dufberg <mats.dufberg@iis.se>
@tgreenx
tgreenx requested a review from matsduf September 24, 2026 13:37
@tgreenx

tgreenx commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@matsduf As discussed I've made another pass on the documentation, please re-review

@marc-vanderwal
marc-vanderwal merged commit d2d86d5 into zonemaster:develop Sep 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RC-Fixes Release category: Fixes. V-Patch Versioning: The change gives an update of patch in version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Address02: Errors at PTR records with CNAME

3 participants