Do not randomize resolving of IP addresses in getaddr()
PATCH v2 1/1 Do not randomize resolving of IP addresses in getaddr()
From: David Sommerseth <[email protected]...>
(I'm withdrawing the first version, and suggesting this patch to be used instead, as this one follows the new feature deprecation process.)
Based on a discussion on the mailing list and in the IRC meeting Feb 18, it was decided to remove get_random() from the getaddr() function as that can conflict with round-robin/randomization done by DNS servers.
For now this feature is enabled by default, but can be disabled by running ./configure with --disable-depr-random-resolv. In the future this will be changed to being disabled by default before getting removed.
--- configure.ac | 17 +++++++++++++++++ socket.c | 14 +++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-)
configure.ac +17 -0
@@ -911,6 +911,23 @@ if test -z "${htmldir}"; then fi # end workaround +# +# Deprecated features +# +# See http://www.secure-computing.net/wiki/index.php/OpenVPN/Developer_documentation +# for more info about the feature deprecation process. +# + +AC_ARG_ENABLE(depr-random-resolv, + [ --disable-depr-random-resolv Deprecated feature: Randomization of hostname resolving when more than one IP address], + [DEPRECATE_RANDRESOLV="$enableval"], + [DEPRECATE_RANDRESOLV="yes"] +) +if test "$DEPRECATE_RANDRESOLV" = "yes"; then + AC_DEFINE(DEPRECATED_RANDOM_RESOLV, 1, [Deprecated feature: Randomization of hostname resolving when more than one IP address]) +fi + + AC_OUTPUT([ Makefile openvpn.spec
socket.c +11 -3
@@ -205,6 +205,10 @@ getaddr (unsigned int flags, {if (h->h_addr_list[1 ])/* more than one address returned */ { +#ifdef DEPRECATED_RANDOM_RESOLV +#warning +#warning **** DEPRECATED FEATURE **** DEPRECATED_RANDOM_RESOLV is enabled +#warning int n =0 ;/* count address list */
@@ -212,12 +216,16 @@ getaddr (unsigned int flags, ++n;ASSERT (n >=2 ); -msg (D_RESOLVE_ERRORS ,"RESOLVE: NOTE: %s resolves to %d addresses, choosing one by random" , - hostname, - n); +msg (D_RESOLVE_ERRORS ,"RESOLVE: NOTE: %s resolves to %d addresses, choosing one by random." +" [DEPRECATED FEATURE]" , hostname, n);/* choose address randomly, for basic load-balancing capability */ ia.s_addr = *(in_addr_t *) (h->h_addr_list[get_random () % n]); + +#else /* preferred solution */ +msg (D_RESOLVE_ERRORS ,"RESOLVE: NOTE: %s resolves to more than one IP address, will " +"use the first resolved address" , hostname); +#endif /* ENABLE_RANDOM_RESOLV */ } }
Signature · 1 line
1.6.6
On 02/19/2010 04:57:30 PM, David Sommerseth wrote:
Am I wrong or does using --disable-depr-random-resolv not remove the random choice?
Quoted 66 lines
From: David Sommerseth <[email protected]...>
For now this feature is enabled by default, but can be disabled by running
./configure with --disable-depr-random-resolv. In the future this will be
changed to being disabled by default before getting removed.socket.c +3
-0@@ -205,6 +205,10 @@ getaddr (unsigned int flags, {if (h->h_addr_list[1 ])/* more than one address returned */ { +#ifdef DEPRECATED_RANDOM_RESOLV +#warning +#warning **** DEPRECATED FEATURE **** DEPRECATED_RANDOM_RESOLV isenabled
socket.c +2
-3+#warning int n =0 ;/* count address list */ @@ -212,12 +216,16 @@ getaddr (unsigned int flags, ++n;ASSERT (n >=2 ); - msg (D_RESOLVE_ERRORS, "RESOLVE: NOTE: %s resolves to %d addresses, choosing one by random", - hostname, - n); + msg (D_RESOLVE_ERRORS, "RESOLVE: NOTE: %s resolves to%d addresses, choosing one by random."
socket.c +1
-0+ " [DEPRECATED FEATURE]", hostname, n);/* choose address randomly, for basic load-balancing capability */
ia.s_addr = *(in_addr_t *) (h->h_addr_list[get_random
() % n]);socket.c +3
-0+ +#else /* preferred solution */ + msg (D_RESOLVE_ERRORS, "RESOLVE: NOTE: %s resolves tomore than one IP address, will "
socket.c +2
-0+ "use the first resolved address", hostname); +#endif /* ENABLE_RANDOM_RESOLV */ } }Signature · 14 lines
-- 1.6.6 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 4 lines · Karl O. Pinc
On 02/19/2010 04:57:30 PM, David Sommerseth wrote:
Am I wrong or does using --disable-depr-random-resolv not remove the random choice?
That is correct. According to the newly agreed feature removal process, deprecated features should in the beginning be enabled but give warnings when they are triggered. At some point, this behaviour will be switched to be disabled, and you need to do use --enable-depr-random-resolv. And if nobody complains in the end, this code will be removed completely.
See the "Feature deprecatoin" section here for more info:
<http://www.secure-computing.net/wiki/index.php/OpenVPN/Developer_documentation>
kind regards,
David Sommerseth
Quoted 65 lines
Quoted 65 lines
From: David Sommerseth <[email protected]...>
For now this feature is enabled by default, but can be disabled by running
./configure with --disable-depr-random-resolv. In the future this will be
changed to being disabled by default before getting removed.socket.c +3
-0@@ -205,6 +205,10 @@ getaddr (unsigned int flags, {if (h->h_addr_list[1 ])/* more than one address returned */ { +#ifdef DEPRECATED_RANDOM_RESOLV +#warning +#warning **** DEPRECATED FEATURE **** DEPRECATED_RANDOM_RESOLV isenabled
socket.c +2
-3+#warning int n =0 ;/* count address list */ @@ -212,12 +216,16 @@ getaddr (unsigned int flags, ++n;ASSERT (n >=2 ); - msg (D_RESOLVE_ERRORS, "RESOLVE: NOTE: %s resolves to %d addresses, choosing one by random", - hostname, - n); + msg (D_RESOLVE_ERRORS, "RESOLVE: NOTE: %s resolves to%d addresses, choosing one by random."
socket.c +1
-0+ " [DEPRECATED FEATURE]", hostname, n);/* choose address randomly, for basic load-balancing capability */
ia.s_addr = *(in_addr_t *) (h->h_addr_list[get_random
() % n]);socket.c +3
-0+ +#else /* preferred solution */ + msg (D_RESOLVE_ERRORS, "RESOLVE: NOTE: %s resolves tomore than one IP address, will "
socket.c +2
-0+ "use the first resolved address", hostname); +#endif /* ENABLE_RANDOM_RESOLV */ } }Signature · 14 lines
-- 1.6.6 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Quoted 10 lines
Quoted 1 line
Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkt/GqoACgkQDC186MBRfrpghACeMK7u3dl70KFe8lWQvaHw2qa5 qJAAnjD1h9hTJgzdMrS5TYS1ADNn0fHt
=JlPD
-----END PGP SIGNATURE-----
Quoted 6 lines · David Sommerseth
Quoted 4 lines · Karl O. Pinc
On 02/19/2010 04:57:30 PM, David Sommerseth wrote:
Am I wrong or does using --disable-depr-random-resolv not remove the random choice?
Quoted 9 lines
That is correct. According to the newly agreed feature removal process,
deprecated features should in the beginning be enabled but give warnings
when they are triggered. At some point, this behaviour will be switched
to be disabled, and you need to do use --enable-depr-random-resolv. And if nobody complains in the end, this code will be removed completely.
I understand the point of the policy, but it seems a bit crazy to ask for the feature to be disabled and have it _not_ be disabled but to get a warning instead.
What you have right now is (unless I mis-understand the code):
Regardless of whether you ask for the feature to be disabled or not the feature remains _enabled_ and you get a runtime warning.
If you ask for the feature to be enabled you get no warning.
What makes sense to me is:
By default the feature remains enabled but there _is_ a runtime warning.
If you explicitly ask for the feature to be disabled then it is disabled and there is _no_ runtime warning.
If you explicitly ask for the feature to be enabled then it is enabled and there is _no_ runtime warning.
This trinary choice conforms to the policy whereby depreciated features remain _by_ _default_ enabled but generate warnings. However it also allows those who make explicit choices to choose desired functionality, which not-incidentally allows those who wish a change in functionality to test out how the change works. And it recognizes that those who make explicit choices are aware of what those choices do and so do not need warnings. Especially because anyone who makes an explicit choice from this point forward will get the requested feature and does not care about the default
because they are not using the default.
If someone who explicitly chooses a functionality needs to get a warning about the default they should get this warning at ./configure time -- the time they make the choice. Not at runtime. (Of course those who rely on the default should, IMO, get a runtime warning message because most of these people won't be doing the ./configure step.)
Whatdayathink?
Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
Quoted 4 lines · Karl O. Pinc
If someone who explicitly chooses a functionality needs to get a warning about the default they should get this warning at ./configure time -- the time they make the choice.
The only time I can think of that a warning should be delivered to those who explicitly choose functionality in the process of deprecation is to, _after_ the default has changed, deliver a ./configure time warning to those who explicitly choose the default telling them that they no longer have to be explicit because they are choosing what is now the default.
It hardly seems worth it.
Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
[Openvpn-devel] Feature removal policy [WAS: Re: [PATCH v2] Do not randomize resolving of IP addresses in getaddr()]
Quoted 16 lines
Quoted 6 lines
If someone who explicitly chooses a functionality needs to get a warning about the default they should get this warning at ./configure time -- the time they make the choice.
The only time I can think of that a warning should be delivered to those who explicitly choose functionality in the process of deprecation is to, _after_ the default has changed, deliver a ./configure time warning to those who explicitly choose the default telling them that they no longer have to be explicit because they are choosing what is now the default.
Quoted 3 lines
It hardly seems worth it.
Runtime warnings about deprecated features are important for users who use packages rather than build from source.
Could you guys take a look at the current FRP draft and let me know if it needs modifications:
http://www.secure-computing.net/wiki/index.php/OpenVPN/Developer_documentation#Feature_deprecation
We of course need to decide what triggers the move, say, from step 2 to step 3. One alternative is to use the "stable" release cycle as a basis. James guestimated that it'd take 12 months to make a new release. So, if a feature is deprecated in "testing" just after a stable release is made, it would stay in the code for
12 months (in testing, outputs a runtime warning)
12 months (in stable, outputs a runtime warning)
12 months (in stable + 1, disabled but available)
So it'd take 24 - 36 months to get rid of a feature, depending on when (in the release cycle) it's deprecated. There are ways to speed up the process. We could, for example, have two processes depending on feature type:
1) longer process for features we know people depend on, but which need to be removed nevertheless (for whatever reason)
2) shorter process for features somebody _might_ use - like the randomization feature discussed earlier
The full FRP (see the wiki link) with steps 1-4 would suit type 1 features. Type 2 features could skip step 3 ("disabled but available") to save time. It should be relatively easy to spot type 1 features: a mail to the -users mailing list should trigger loud complaints if a feature is widely used. Also, users have plenty of time to react to the warnings during the 12-24 month period.
Signature · 5 lines
Samuli Seppänen Community Manager OpenVPN Technologies, Inc irc freenode net: mattock
Re: [Openvpn-devel] Feature removal policy [WAS: Re: [PATCH v2] Do not randomize resolving of IP addresses in getaddr()]
Quoted 16 lines · Samuli Seppänen
Quoted 16 lines
Quoted 6 lines
If someone who explicitly chooses a functionality needs to get a warning about the default they should get this warning at ./configure time -- the time they make the choice.
The only time I can think of that a warning should be delivered to those who explicitly choose functionality in the process of deprecation is to, _after_ the default has changed, deliver a ./configure time warning to those who explicitly choose the default telling them that they no longer have to be explicit because they are choosing what is now the default.
Quoted 6 lines
Quoted 3 lines
It hardly seems worth it.
Runtime warnings about deprecated features are important for users who
use packages rather than build from source.
Yes. I've since had second thoughts about this. It seems to me that there should be ./configure options for the use of package maintainers that allow the enable/disablement of such runtime warnings. Maintainers may decide to that some features are part of their distribution, put a note in their changelog, and move forward.
Quoted 4 lines
Could you guys take a look at the current FRP draft and let me know if
it needs modifications:
I need to re-read it. Particularly with an eye towards changes that are only enabled at compile time v.s. changes to defaults that the user requests at runtime in the OpenVPN config file.
...
Quoted 8 lines
So it'd take 24 - 36 months to get rid of a feature, depending on when
(in the release cycle) it's deprecated. There are ways to speed up the
process. We could, for example, have two processes depending on feature
type:
Quoted 5 lines
1) longer process for features we know people depend on, but which need
to be removed nevertheless (for whatever reason)
2) shorter process for features somebody _might_ use - like the randomization feature discussed earlier
By putting control over runtime warning messages into ./configure (along with the enablement of the feature iteslf)
you put control over deciding which features fall into category 1 and which in category 2 into the hands of the end-user. This becomes significant when you put such control into the hands of a distribution's package maintainer who can set policy for entire groups of users. A distro maintainer can enable the feature and turn off the warning and speed up the process of depreciation for their users if they think the change is trivial.
I would think that this would be the best way to make as many people happy as possible.
And of course OpenVPN retains
control over the ./configure defaults which can be nice and conservative. Taking 24-36 months to change something can be a good thing.
Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 32 lines · Karl O. Pinc
Quoted 6 lines · David Sommerseth
Quoted 4 lines · Karl O. Pinc
On 02/19/2010 04:57:30 PM, David Sommerseth wrote:
Am I wrong or does using --disable-depr-random-resolv not remove the random choice?
Quoted 9 lines
That is correct. According to the newly agreed feature removal process,
deprecated features should in the beginning be enabled but give warnings
when they are triggered. At some point, this behaviour will be switched
to be disabled, and you need to do use --enable-depr-random-resolv. And if nobody complains in the end, this code will be removed completely.I understand the point of the policy, but it seems a bit crazy to ask for the feature to be disabled and have it _not_ be disabled but to get a warning instead.
What you have right now is (unless I mis-understand the code):
Regardless of whether you ask for the feature to be disabled or not the feature remains _enabled_ and you get a runtime warning.
If you ask for the feature to be enabled you get no warning.
What makes sense to me is:
Quoted 8 lines
By default the feature remains enabled but there _is_ a runtime warning.
If you explicitly ask for the feature to be disabled then it is disabled and there is _no_ runtime warning.
If you explicitly ask for the feature to be enabled then it is enabled and there is _no_ runtime warning.
You are right, that was badly worded from my side. I will correct that when I implement the patch into the testing tree. The commit log will state that this begins the feature deprecation process, with a warning when this feature is used and the feature can be removed at compile time with --disable-depr-random-resolv.
- --
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkuCNmkACgkQDC186MBRfrqtbACfSu+hFWOI8dvMpZGs1s2RilfD HsgAnieBeWZLf924/IZxeLme+kR03vqG
=2sDe
-----END PGP SIGNATURE-----
On 02/22/2010 01:46:53 AM, David Sommerseth wrote:
The commit log
Quoted 6 lines
will
state that this begins the feature deprecation process, with a warning
when this feature is used and the feature can be removed at compile time
with --disable-depr-random-resolv.
I've thought a bit more about this. It seems to me that the warning message happens at the wrong time. In your patch (IIRC) it happens at dns resolve time, only when there are multiple A records returned. It should happen at OpenVPN startup time for the following reasons:
Someone may be relying on the behavior but, at the moment or depending on present dns circumstances, does not have multiple A records returned. In this case no warning will be generated.
Generating a message every time dns lookup is done could result in "too many" messages, increasing the log files and filling somebody's disk. (Unlikely, but...) In any case it adds additional noise in which legitimate messages could be lost.
Arguably, a message sent at startup time is more likely to be noticed than one buried amid others that occur over time.
Generating one message at startup time is "least invasive" to the code. Everybody will execute the code path and so (in the unlikely event) any bugs will be found and fixed early. Likewise, any introduced problem will occur during initialization rather than "runtime" and so will happen at a predictable point.
The code that actually "does something" will be untouched, removing any possibility of race conditions or anything else that might interfere with actual operation.
In the general case I would think you'd want warnings regarding features chosen/not chosen/ depreciated/etc. to be generated at config
parse time.
/brain dump
Regards,
Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
Quoted 4 lines · Karl O. Pinc
Someone may be relying on the behavior but, at the moment or depending on present dns circumstances, does not have multiple A records returned. In this case no warning will be generated.
The flip side of that coin is also valid I think.
Consider independent configuration of VPN and DNS. Early errors would restrict VPN setup and possibly shipment until after DNS has been set up, while lazy evaluation allows DNS changes to happen later.
May be particularly important since DNS has a builtin propagation delay of any changes.
I'm not saying I disagree, but that it may be a tradeoff.
//Peter
Quoted 11 lines · Peter Stuge
Quoted 4 lines · Karl O. Pinc
Someone may be relying on the behavior but, at the moment or depending on present dns circumstances, does not have multiple A records returned. In this case no warning will be generated.
The flip side of that coin is also valid I think.
Consider independent configuration of VPN and DNS. Early errors would restrict VPN setup and possibly shipment until after DNS has been set up, while lazy evaluation allows DNS changes to happen later.
Right, but there's nothing to "restrict" because in this case we're talking about a warning not an error; generating a warning that default behavior will change in a future release. OpenVPN _should_ continue happily along its way no matter where
the warning is generated.
It's a pretty trivial point really, but may provide a template for future changes.
Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 13 lines · Karl O. Pinc
Quoted 11 lines · Peter Stuge
Quoted 4 lines · Karl O. Pinc
Someone may be relying on the behavior but, at the moment or depending on present dns circumstances, does not have multiple A records returned. In this case no warning will be generated.
The flip side of that coin is also valid I think.
Consider independent configuration of VPN and DNS. Early errors would restrict VPN setup and possibly shipment until after DNS has been set up, while lazy evaluation allows DNS changes to happen later.
Quoted 8 lines
Right, but there's nothing to "restrict" because in this case we're talking about a warning not an error; generating a warning that default behavior will change in a future release. OpenVPN _should_ continue happily along its way no matter where
the warning is generated.It's a pretty trivial point really, but may provide a template for future changes.
Agreed! ... and I've sent out a patch giving such a simple "template", for the source code.
Now the code will present a very early warning about deprecated features which is enabled, and it will give yet another warning when the feature is triggered. That way, we should get the attention if it happens.
Having that said, it's probably wise to consider which features removals which will print a warning each it is called. In this case, I feel it is safe, as it's probably not too often you will trigger this.
On the other hand, we want to bother the users and really make them see these messages. If they dislike it, they then have a reason to discuss the planned feature removal.
Does that cover your concerns?
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkuC+zkACgkQDC186MBRfrpWYgCdEU6ime0X9b0kqdA2Nu0k0IvJ lwoAoJ8Pkc0wNyYNGP0DuxfbosdVeqjj
=1PLD
-----END PGP SIGNATURE-----
Quoted 2 lines · David Sommerseth
Does that cover your concerns?
Yes. It's all somewhat a matter of taste, so if you find it tasty that's good enough for me. :-)
Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
Quoted 6 lines · David Sommerseth
Quoted 4 lines · Karl O. Pinc
On 02/19/2010 04:57:30 PM, David Sommerseth wrote:
Am I wrong or does using --disable-depr-random-resolv not remove the random choice?
Quoted 7 lines
That is correct. According to the newly agreed feature removal process,
deprecated features should in the beginning be enabled but give warnings
when they are triggered. At some point, this behaviour will be switched
to be disabled, and you need to do use --enable-depr-random-resolv.
Irrespective of the actual change being made here, does it make sense to have a "next release" branch?
If changes to defaults/depreciation of features is to happen at major release number boundaries, or whatever defined point, it is important not to "miss" making such a planned change happen in the first version of the new major release. Likewise, having to go back and re-visit the code to make the actual change could be error prone. And we would not want these changes to conflict with any other changes either.
Having another branch to track changes that will happen in the next major release solves all of these problems. This branch would have the code that by default changes the existing behavior, enables the new feature, etc.
Just a thought.
Regards,
Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
Hi,
Quoted 2 lines · David Sommerseth
(I'm withdrawing the first version, and suggesting this patch to be used instead, as this one follows the new feature deprecation process.)
ACK!
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...David Sommerseth
Applied-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 9 lines · David Sommerseth
From: David Sommerseth <[email protected]...>
(I'm withdrawing the first version, and suggesting this patch to be used instead, as this one follows the new feature deprecation process.)
Based on a discussion on the mailing list and in the IRC meeting Feb 18, it was decided to remove
get_random()from thegetaddr()function as that can conflict with round-robin/randomization done by DNS servers.
Quoted 5 lines
For now this feature is enabled by default, but can be disabled by running ./configure with --disable-depr-random-resolv. In the future this will be changed to being disabled by default before getting removed.
Signed-off-by David Sommerseth <[email protected]...>
Applied to the feature_removal branch and merged into allmerged.
commit 684790552dde0475745015a76762ecc5a11eedab
Commit log changed to say:
FRP: Prepare to remove randomisation of resolved IP addresses in getaddr()
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkuCRq8ACgkQDC186MBRfrqyBQCfQPW8L78mbIDU9WI6ri5gUvax W/AAoJDNuqeriduNAMqZUxVwxKewoQl6
=Gpks
-----END PGP SIGNATURE-----