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

Get rid of some allocs/copies in DNS parsing #6831

Merged
merged 5 commits into from Aug 8, 2018

Conversation

rgacogne
Copy link
Member

@rgacogne rgacogne commented Aug 7, 2018

Short description

This PR:

  • Prevents an allocation and copy of the DNS query or response passed to MOADNSParser, and get rid of the weird -12 dance (auth, rec) ;
  • Makes PacketReader accepts a string instead of a vector<uint18_t> so we don't need to allocate a vector and copy our data to it (auth, rec, dnsdist) ;
  • Removes a useless copy of the response in arecvfrom() (rec) ;
  • Removes some string allocations and copies during EDNS processing (dnsdist) ;
  • replaces a fixed 65k buffer allocated for every TCP connection by a dynamically allocated one (rec).

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)

Copy link
Member

@chbruyand chbruyand left a comment

Choose a reason for hiding this comment

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

LGTM!

pdns/dnsdist.cc Outdated
@@ -273,11 +273,12 @@ bool fixUpResponse(char** response, uint16_t* responseLen, size_t* responseSize,
}

if (ednsAdded || ecsAdded) {
char * optStart = NULL;
uint16_t optStart = NULL;
Copy link
Member

Choose a reason for hiding this comment

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

Initializing this to NULL is confusing

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed!

@rgacogne rgacogne merged commit f8c8066 into PowerDNS:master Aug 8, 2018
@rgacogne rgacogne deleted the no-moadns-copy branch August 8, 2018 10:11
@rgacogne rgacogne mentioned this pull request Aug 8, 2018
10 tasks
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.

None yet

2 participants