Skip to content

Add ERCodeRule#6147

Merged
rgacogne merged 5 commits intoPowerDNS:masterfrom
zeha:dnsdist-ercode
Jan 9, 2018
Merged

Add ERCodeRule#6147
rgacogne merged 5 commits intoPowerDNS:masterfrom
zeha:dnsdist-ercode

Conversation

@zeha
Copy link
Collaborator

@zeha zeha commented Jan 5, 2018

Short description

Add ERCodeRule to match on EDNS Extended RCodes.

Separate rule to avoid performance cost for non-EDNS packets. Unclear if this is a good idea for correctness.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled and tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

@zeha zeha requested a review from rgacogne January 5, 2018 17:18
Copy link
Member

@rgacogne rgacogne left a comment

Choose a reason for hiding this comment

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

Nice work, just a few minor nits!

bool matches(const DNSQuestion* dq) const override
{
// avoid parsing EDNS OPT RR when not needed.
if (d_rcode != dq->dh->rcode) {
Copy link
Member

Choose a reason for hiding this comment

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

Given that dq->dh->rcode is unsigned, perhaps d_rcode should be too? Same for d_extrcode since edns0.extRCode is an uint8_t.

char * optStart = NULL;
size_t optLen = 0;
bool last = false;
int res = locateEDNSOptRR((char*)dq->dh, dq->len, &optStart, &optLen, &last);
Copy link
Member

Choose a reason for hiding this comment

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

const_cast<char*>(reinterpret_cast<const char*>(dq->dh)) ? I don't think we'll manage to get rid of the existing C-style casts, but it would be nice to add new ones as few as possible :)

}
EDNS0Record edns0;
static_assert(sizeof(EDNS0Record) == sizeof(uint32_t), "sizeof(EDNS0Record) must match sizeof(uint32_t) AKA RR TTL size");
memcpy(&edns0, optStart + 5, sizeof edns0);
Copy link
Member

Choose a reason for hiding this comment

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

Adding a comment explaining where does the 5 comes from might be nice for later review.

@zeha
Copy link
Collaborator Author

zeha commented Jan 8, 2018

Nits addressed

@rgacogne rgacogne merged commit 1a26cc5 into PowerDNS:master Jan 9, 2018
@zeha zeha deleted the dnsdist-ercode branch January 29, 2018 17:40
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