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

WIP ZONEVERSION (RFC9660) support #14818

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft

Conversation

Habbie
Copy link
Member

@Habbie Habbie commented Nov 4, 2024

Short description

$ pdns/sdig 127.0.0.1 5300 www.example.com soa   zoneversion
Reply to question for qname='www.example.com.', qtype=SOA
Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
1	example.com.	3005	IN	SOA	a.misconfigured.dns.server.invalid. hostmaster.example.com. 1731417315 10800 3600 604800 3600
2	.	0	IN	OPT	ABMABgIAZzNU4wATAAYC9nilCsY=
EDNS Zone Version (SOA serial) for labelcount 2: 1731417315
EDNS Zone Version (type 246) for labelcount 2: 2024082118

SOA serial is the served serial. type 246 is the unedited serial in our backend storage.

TODO:

  • support in auth
  • tests
  • meson updates
  • good code
  • an enum for version types

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)
  • checked that this code was merged to master

@coveralls
Copy link

coveralls commented Nov 4, 2024

Pull Request Test Coverage Report for Build 11839521381

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 10 of 56 (17.86%) changed or added relevant lines in 3 files are covered.
  • 121 unchanged lines in 12 files lost coverage.
  • Overall coverage decreased (-0.04%) to 64.657%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pdns/packethandler.cc 2 5 40.0%
pdns/dnspacket.cc 8 23 34.78%
pdns/ednszoneversion.cc 0 28 0.0%
Files with Coverage Reduction New Missed Lines %
pdns/backends/gsql/gsqlbackend.hh 1 97.71%
pdns/pollmplexer.cc 1 83.66%
pdns/rcpgenerator.cc 2 90.59%
pdns/recursordist/rec-main.cc 3 62.32%
pdns/shuffle.cc 4 39.71%
pdns/recursordist/rec-tcp.cc 10 65.13%
pdns/recursordist/taskqueue.cc 11 34.15%
ext/json11/json11.cpp 12 62.72%
pdns/recursordist/syncres.cc 13 79.47%
pdns/recursordist/test-syncres_cc1.cc 15 88.98%
Totals Coverage Status
Change from base Build 11826615167: -0.04%
Covered Lines: 125749
Relevant Lines: 163651

💛 - Coveralls

@Habbie Habbie added this to the auth-5 milestone Nov 4, 2024
auto& edited_serial = auth_serial.second.second;

uint8_t labelcount = name.countLabels();
EDNSZoneVersion unedited = {labelcount, 0 /* FIXME enum */, unedited_serial};

Check notice

Code scanning / CodeQL

FIXME comment Note

FIXME comment: enum
pdns/dnspacket.cc Fixed Show fixed Hide fixed
{
uint8_t labelcount;
uint8_t type;
char version[256]; // FIXME they can be bigger

Check notice

Code scanning / CodeQL

FIXME comment Note

FIXME comment: they can be bigger

bool getEDNSZoneVersionFromString(const string& options, EDNSZoneVersion& zoneversion)
{
// cerr<<"options.size:"<<options.size()<<endl;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
bool getEDNSZoneVersionFromString(const char* options, unsigned int len, EDNSZoneVersion& zoneversion)
{
EDNSZoneVersionWire zoneversionw{};
// static_assert(sizeof(zoneversionw) == 4, "sizeof(EDNSSubnetOptsWire) must be 4 bytes");

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
EDNSZoneVersionWire zoneversionw{};
// static_assert(sizeof(zoneversionw) == 4, "sizeof(EDNSSubnetOptsWire) must be 4 bytes");
if (len > sizeof(zoneversionw)) {
return false; // FIXME this silently breaks on >256 bytes of version

Check notice

Code scanning / CodeQL

FIXME comment Note

FIXME comment: this silently breaks on >256 bytes of version
} else if (iter->first == EDNSOptionCode::ZONEVERSION) {
EDNSZoneVersion zoneversion;
if (getEDNSZoneVersionFromString(iter->second, zoneversion)) {
if (zoneversion.type == 0) { // FIXME enum

Check notice

Code scanning / CodeQL

FIXME comment Note

FIXME comment: enum

uint8_t labelcount = name.countLabels();
EDNSZoneVersion unedited = {labelcount, 0 /* FIXME enum */, unedited_serial};
EDNSZoneVersion edited = {labelcount, 246 /* FIXME enum and wrong number */, edited_serial};

Check notice

Code scanning / CodeQL

FIXME comment Note

FIXME comment: enum and wrong number
this works:

./sdig 200.1.122.30 53 dateserial.example.com A zoneversion
Reply to question for qname='dateserial.example.com.', qtype=A
Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
1	dateserial.example.com.	43200	IN	SOA	ns.dateserial.example.com. hsalgado.nic.cl. 2023050202 21600 7200 2592000 43200
2	.	0	IN	OPT	ABMABgMAeJVL2g==
EDNS Zone Version for labelcount 3: 2023050202

missing:
* support in auth
* meson updates
* good code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants