Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zone walking to include non-leaf CNAMEs #352

Merged
merged 2 commits into from
Oct 2, 2024

Conversation

ximon18
Copy link
Member

@ximon18 ximon18 commented Jul 11, 2024

Querying a zone for a CNAME works, but when walking the zone (e.g. for diagnostic dumping or to do AXFR) a CNAME that is not at a leaf node (i.e. a CNAME at a.example.com while there also exists a deeper b.a.example.com leaf node) is incorrectly skipped by the current zone walking code.

This PR adds the missing code to emit the non-leaf CNAME to the zone walker callback operation.

This PR does NOT include unit tests to cover this fix because (a) there are no existing unit tests for this code and writing an entire set would time that I don't have right now, (b) strict unit tests are not really possible because they would also have to exercise the code in nodes.rs to construct the tree before wakling it and so some sort of "integration" test is needed, and (c) the new XFR work being done for PR #335 will include Stelline tests that walk zones (for AXFR) and should visit all parts of the tree.

While the Stelline tests will be at the outermost testing layer, exercising domain as a black box, so one could perhaps argue that testing somewhere nearer to the tree walking code would also be good to have, they will at least address the immediate need to exercise the entire zone walking code.

Add code to emit the non-leaf CNAMEs to the zone walker callback operation.
@ximon18 ximon18 requested a review from a team July 11, 2024 07:42
ximon18 added a commit that referenced this pull request Jul 12, 2024
- Fixed a bug in TSIG client sequence verification introduced by an earlier fix for server sequence signing (also pushed to PR 345).
- Fixed issues with AXFR response batching.
- Fixed a Stelline test bug where a request for a UDP client was treated as a request for a TCP client.
- Fixed an errant blank line per zone entry bug in processing of the `local-data` Stelline server config setting.
- Fixed a zone walking bug that omitted CNAMEs at non-leaf nodes (also pushed as PR #352).
- Made the zone argument to net::client::xfr optional.
- Made net::client::xfr pass on the messages it receives after it has checked/processed them.
- Added a multi-response large zone variant of the AXFR test.
- Added a Stelline TSIG variant of the AXFR test.
- Renamed the XFR Stelline tests.
- Renamed the TSIG client from net::client::auth to net::client::tsig.
- Added the NOTIFY middleware back in to the server Stelline tests.
- Added the TSIG middleware to the server Stelline tests.
- Extended the server Stelline tests to:
  - Create a 'TESTKEY' in the key store.
  - Wrap TCP connections created by the client factory in the tsig and xfr clients.
  - Wrap UDP connections created by the client factory in the tsig client.
  - Accept a named TSIG key in the `provide-xfr` server config setting.
  - Accept a named TSIG key in the `STEP N QUERY` Stelline command.
  - Take the entire ENTRY as input to the client factory, not just the client IP address.
    (so that any specified TSIG key for the client can be configured)
  - Accept `$ORIGIN` in `ANSWER SECTION` response RRs.
    (so that many RRs with a shared origin can be expressed more succinctly)
  - Change in-memory zone tree node ordering to be deterministic (BTreeMap based instead of HashMap based) in #[cfg(test)] mode.
    (so that the new large AXFR response test can know which response RRs will be present in which response message)
- Removed unused stream connection ID numbering and related Tokio tracing span that was causing unwanted test output indentation.
- Removed some unnecessary calls to the zone walking callback op fn.
@ximon18
Copy link
Member Author

ximon18 commented Jul 23, 2024

No test is included in this PR, partly because the state of the Stelline server testing in this PR isn't able to test AXFR which is what needs to be queried to exercise zone walking which is what this PR fixes.

A manual test however with NSD, domain without the fix and domain with the fix shows that this PR resolves an issue.

Given the zone file:

com.               900     IN  SOA     a.gtld-servers.net. nstld.verisign-grs.com. 1720688795 1800 900 604800 86400
alt.com.           3600    IN  A       1.2.3.4
a.alt.com.           3600  IN  CNAME   example.com.
b.a.alt.com.         3600  IN  A       1.2.3.4
www.terminal.com.   3600   IN  A       1.2.3.4
alt.terminal.com.   3600   IN  CNAME   www.example.com.

A sorted AXFR dig query output when run against NSD and domain with the fix in this PR (applied to the xfr branch which has full support for AXFR) looks the same:

(with dig command: dig +noall +answer @127.0.0.1 -p <PORT> -t AXFR com | sort where <PORT> is the local port on which either NSD or domain are serving the zone)

a.alt.com.              3600    IN      CNAME   example.com.
alt.com.                3600    IN      A       1.2.3.4
alt.terminal.com.       3600    IN      CNAME   www.example.com.
b.a.alt.com.            3600    IN      A       1.2.3.4
com.                    900     IN      SOA     a.gtld-servers.net. nstld.verisign-grs.com. 1720688795 1800 900 604800 86400
com.                    900     IN      SOA     a.gtld-servers.net. nstld.verisign-grs.com. 1720688795 1800 900 604800 86400
www.terminal.com.       3600    IN      A       1.2.3.4

Without the fix in this PR domain misses some records in the AXFR output:

alt.com.                3600    IN      A       1.2.3.4
b.a.alt.com.            3600    IN      A       1.2.3.4
com.                    900     IN      SOA     a.gtld-servers.net. nstld.verisign-grs.com. 1720688795 1800 900 604800 86400
com.                    900     IN      SOA     a.gtld-servers.net. nstld.verisign-grs.com. 1720688795 1800 900 604800 86400
www.terminal.com.       3600    IN      A       1.2.3.4

@ximon18 ximon18 mentioned this pull request Sep 26, 2024
@ximon18 ximon18 added the bug Something isn't working label Oct 1, 2024
@ximon18 ximon18 merged commit 56aa3e3 into main Oct 2, 2024
26 checks passed
@ximon18 ximon18 deleted the fix-zone-walking-to-include-non-leaf-cnames branch October 2, 2024 19:04
ximon18 added a commit that referenced this pull request Oct 3, 2024
Add code to emit the non-leaf CNAMEs to the zone walker callback operation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants