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

dnsdist: Add an option to use several source ports toward a backend #6317

Merged
merged 5 commits into from Mar 22, 2018

Conversation

rgacogne
Copy link
Member

@rgacogne rgacogne commented Mar 1, 2018

Short description

This is very useful if the backend is distributing queries based only on (source IP, source port, destination IP, destination port), which is for example the case of PowerDNS Recursor with several
threads, reuseport set and pdns-distribute-queries not set.

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)

@@ -216,6 +217,10 @@ void setupLuaConfig(bool client)
}
}

if(vars.count("sockets")) {
numberOfSockets=std::stoi(boost::get<string>(vars["sockets"]));
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe add a check > 0

@rgacogne rgacogne changed the title [WIP] dnsdist: Add an option to use several source ports toward a backend dnsdist: Add an option to use several source ports toward a backend Mar 5, 2018
@rgacogne
Copy link
Member Author

rgacogne commented Mar 5, 2018

Added a check that the number of sockets is greater than 0, handle more gracefully a failed (re-)connection, and updated the file descriptors check to account for more than one socket per backend.

@rgacogne
Copy link
Member Author

rgacogne commented Mar 5, 2018

Note that the current implementation will not perform well with a large number of sockets per backend since it currently uses poll(). It would be better to use our existing multiplexer classes, but it requires:

  • removing / adding the socket descriptors to the multiplexer on reconnection ;
  • refactoring the existing code to support the multiplexer callback interface, or adding a new function to the multiplexer interface that would return a list of 'ready' file descriptors.

This is very useful if the backend is distributing queries based
only on (source IP, source port, destination IP, destination port),
which is for example the case of PowerDNS Recursor with several
threads, reuseport set and pdns-distribute-queries not set.
@rgacogne
Copy link
Member Author

Pushed an additional commit using our existing multiplexer code. I went with the second option described above, adding a new function to the multiplexer interface that returns a list of 'ready' file descriptors. This code needs a serious review before merging!

@pieterlexis pieterlexis merged commit bb066a4 into PowerDNS:master Mar 22, 2018
@rgacogne rgacogne deleted the dnsdist-source-ports branch March 22, 2018 13:54
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

3 participants