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

Allow config & checking of nameserver rotation option #48

Closed
wants to merge 1 commit into from

Conversation

daviddrysdale
Copy link
Member

For discussion, particular around whether this is suitably back-compatible.

Fix up a couple of problems with configuring whether c-ares rotates
between different name servers between requests.

Firstly, ares_save_options() returns (in *optmask) the value of
(channel->optmask & ARES_OPT_ROTATE), which doesn't necessarily
indicate whether the channel is or is not actually doing rotation.
This can be confusing/incorrect if:
 - the channel was originally configured without ARES_OPT_ROTATE
   (so it appears that the channel is not rotating)
 - the /etc/resolv.conf file includes the 'rotate' option
   (so the channel is actually performing rotation).

Secondly, it is not possible to reliably configure a channel
to not-rotate; leaving off ARES_OPT_ROTATE is not enough, since
a 'rotate' option in /etc/resolv.conf will turn it on again.

Therefore:
 - add an ARES_OPT_NOROTATE optmask value to allow explicit
   configuration of no-rotate behaviour
 - in ares_save_options(), report the value of channel->rotate
   as exactly one of (optmask & ARES_OPT_ROTATE) or
   (optmask & ARES_OPT_NOROTATE).

In terms of back-compatibility:
 - existing apps that set ARES_OPT_ROTATE will continue to rotate,
   and to have ARES_OPT_ROTATE reported back from ares_save_options()
 - existing apps that don't set ARES_OPT_ROTATE will continue to
   use local config/defaults to decide whether to rotate, and will
   now get ARES_OPT_ROTATE or ARES_OPT_NOROTATE reported back from
   ares_save_options() rather than 0.
@daviddrysdale
Copy link
Member Author

Any thoughts?

@bagder
Copy link
Member

bagder commented Sep 23, 2016

The only thought I have about this, is if ares_save_options should save the options that was set with init_options or if it should also save options that were set in /etc/resolv.confetc. Ie what the users asked for with the API or what the current "state" is...

I think it looks like most of the existing code does the latter: it stores the current state. That seems to match what your patch here does, which makes 👍 it.

@daviddrysdale daviddrysdale deleted the norotate branch September 24, 2016 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants