Fix best gateway selection over netlink
A message that is not in the archive (sent off-list or not yet received): 011701d6858cyandex-team.ru
PATCH v3 1/1 Fix best gateway selection over netlink
Netlink route request with NLM_F_DUMP flag set means to return all entries matching criteria passed in message content - matching supplied family & dst address in our case. So, gateway from the first ipv4 route was always used.
On kernels earlier than 2.6.38 default routes are the last ones, so arbitrary host/net route w/o gateway is likely be returned as first, causing gateway to be invalid or empty.
After refactoring in 2.6.38 kernel default routes are on top, so the problem with older kernels was hidden.
Fix this behavior by selecting first 0.0.0.0/0 if dst was not set or empty. For IPv6, no behavior is changed - request ::/128 route, so just clarify the sizes via netlink route api.
Tested on 5.4.0, 4.1.51, 2.6.36 and 2.6.22 kernels.
--- doc/man-sections/advanced-options.rst | 7 +++-- src/openvpn/networking_sitnl.c | 44 ++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-)
doc/man-sections/advanced-options.rst +5 -2
@@ -11,8 +11,11 @@ Standalone Debug Options --show-gateway --show-gateway IPv6-target - If an IPv6 target address is passed as argument, the IPv6 route for this - host is reported. + For IPv6 this queries the route towards ::/128, or the specified IPv6 + target address if passed as argument. + For IPv4 on Linux, Windows, MacOS and BSD it looks for a 0.0.0.0/0 route. + If there are more specific routes, the result will not always be matching + the route of the IPv4 packets to the VPN gateway. Advanced Expert Options
src/openvpn/networking_sitnl.c +40 -4
84 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 5 lines · Vladislav Grishenko
On kernels earlier than 2.6.38 default routes are the last ones, so arbitrary host/net route w/o gateway is likely be returned as first, causing gateway to be invalid or empty.
After refactoring in 2.6.38 kernel default routes are on top, so the problem with older kernels was hidden.
I haven't paid too much attention here, but I don't think I've seen this point being brought up. But do we really care about such old kernels at all?
AFAIK, RHEL-6 (which goes EOL in November this year and which is not planned to be supported in OpenVPN 2.5+) is the only distro carrying such an old kernel release (2.6.32 baseline). Even an internal OpenWRT 19.07 box of mine (which should be upgraded, I know!) ships with 4.14. Unless I'm completely clueless (which is a possibility), 2.4 and 2.6 kernels are mostly interesting for boards with 4MB flash memory. And I would suspect such boards with that little flash memory to belong to that past. (And OpenVPN 2.4 is perfectly fine too for some time forward anyhow, which should work just fine).
If this fix has other qualities, then it's fine to consider such a patch. But I don't see the need for this if it is primarily to enable support for ancient kernel releases which are no longer supported by the upstream kernel community (where 4.4 is the oldest one).
I would lean on what Antonio says here as well, as he kinda owns the sitnl implementation and API.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Inc
Hi,
Quoted 10 lines · David Sommerseth
Quoted 5 lines · Vladislav Grishenko
On kernels earlier than 2.6.38 default routes are the last ones, so arbitrary host/net route w/o gateway is likely be returned as first, causing gateway to be invalid or empty.
After refactoring in 2.6.38 kernel default routes are on top, so the problem with older kernels was hidden.I haven't paid too much attention here, but I don't think I've seen this point being brought up. But do we really care about such old kernels at all?
Quoted 8 lines
AFAIK, RHEL-6 (which goes EOL in November this year and which is not planned to be supported in OpenVPN 2.5+) is the only distro carrying such an old kernel release (2.6.32 baseline). Even an internal OpenWRT 19.07 box of mine (which should be upgraded, I know!) ships with 4.14. Unless I'm completely clueless (which is a possibility), 2.4 and 2.6 kernels are mostly interesting for boards with 4MB flash memory. And I would suspect such boards with that little flash memory to belong to that past. (And OpenVPN 2.4 is perfectly fine too for some time forward anyhow, which should work just fine).
Well, this is an actual flaw in the sitnl code.
It now works, but it may break at some point (it is apparently relying on a self-made assumption which may not hold true in the future).
For this reason sitnl *needs* fixing.
On the other hand, helping out people that are stuck on old platforms to upgrade to modern (aka more secure) OpenVPN versions is also not a bad idea.
Since the fix is relatively small, I'd consider it for inclusion.
I'll try to review it ASAP so that it can be considered for going into the next beta (2.5 compiles with sitnl by default - this is how this issue was exposed)
Regards,
Signature · 1 line
Antonio Quartulli
Hi,
Quoted 11 lines · Vladislav Grishenko
Netlink route request with
NLM_F_DUMPflag set means to return all entries matching criteria passed in message content - matching supplied family & dst address in our case. So, gateway from the first ipv4 route was always used.On kernels earlier than 2.6.38 default routes are the last ones, so arbitrary host/net route w/o gateway is likely be returned as first, causing gateway to be invalid or empty.
After refactoring in 2.6.38 kernel default routes are on top, so the problem with older kernels was hidden.
Quoted 7 lines
Fix this behavior by selecting first 0.0.0.0/0 if dst was not set or empty. For IPv6, no behavior is changed - request ::/128 route, so just clarify the sizes via netlink route api.
Tested on 5.4.0, 4.1.51, 2.6.36 and 2.6.22 kernels.
Signed-off-by Vladislav Grishenko <[email protected]...>
Thanks for taking care of this issue and for digging into the sitnl code.
The change is really contained and and easy to review. Tested a bit and it works as expected.
Signature · 1 line
Antonio Quartulli
Hi, Antonio
Thank you for review
--
Best Regards, Vladislav Grishenko
Quoted 39 lines
-----Original Message-----
From: Antonio Quartulli <[email protected]...>
Sent: Thursday, September 10, 2020 2:02 PM
To: Vladislav Grishenko <[email protected]...>; openvpn- [email protected]
Subject: Re: [Openvpn-devel] [PATCH v3] Fix best gateway selection over netlinkHi,
Quoted 11 lines · Vladislav Grishenko
Netlink route request with
NLM_F_DUMPflag set means to return all entries matching criteria passed in message content - matching supplied family & dst address in our case.
So, gateway from the first ipv4 route was always used.On kernels earlier than 2.6.38 default routes are the last ones, so arbitrary host/net route w/o gateway is likely be returned as first, causing gateway to be invalid or empty.
After refactoring in 2.6.38 kernel default routes are on top, so the problem with older kernels was hidden.Quoted 7 lines
Fix this behavior by selecting first 0.0.0.0/0 if dst was not set or empty. For IPv6, no behavior is changed - request ::/128 route, so just clarify the sizes via netlink route api.
Tested on 5.4.0, 4.1.51, 2.6.36 and 2.6.22 kernels.
Signed-off-by Vladislav Grishenko <[email protected]...>Thanks for taking care of this issue and for digging into the sitnl code.
The change is really contained and and easy to review. Tested a bit and it works as expected.
--
Antonio Quartulli
Thanks a lot.
Your patch has been applied to the master and release/2.5 branch.
(I have lightly tested this on Linux 4.19.9 and stared a bit at the code. Antonio is the master of this code and if he says it's good, it is :-) )
commit 505d5ad8fadcdc56bae07f4b95c05acd93a47c24 (master) commit 7a9fefb6e2ea28967a09956eeb041b687ca0e335 (release/2.5)
Author: Vladislav Grishenko Date: Tue Sep 8 17:36:25 2020 +0500
Fix best gateway selection over netlink
Signed-off-by: Vladislav Grishenko <[email protected]...>
Acked-by: Antonio Quartulli <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg20900.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Hi Gert,
Great, many thanks
--
Best Regards, Vladislav Grishenko
Quoted 7 lines
-----Original Message-----
From: Gert Doering <[email protected]...>
Sent: Thursday, September 10, 2020 2:23 PM
To: Vladislav Grishenko <[email protected]...>
Cc: [email protected]
Subject: [PATCH applied] Re: Fix best gateway selection over netlink
Quoted 5 lines
Thanks a lot.
Your patch has been applied to the master and release/2.5 branch.
(I have lightly tested this on Linux 4.19.9 and stared a bit at the code.
Antonio is
Quoted 21 lines
the master of this code and if he says it's good, it is :-) )
commit
505d5ad8fadcdc56bae07f4b95c05acd93a47c24(master) commit7a9fefb6e2ea28967a09956eeb041b687ca0e335(release/2.5)Author: Vladislav Grishenko Date: Tue Sep 8 17:36:25 2020 +0500Fix best gateway selection over netlink Signed-off-by: Vladislav Grishenko <[email protected]...> Acked-by: Antonio Quartulli <[email protected]...> Message-Id: <[email protected]...> URL: https://www.mail-archive.com/openvpn- [email protected]/msg20900.html Signed-off-by: Gert Doering <[email protected]...>--
kind regards,Gert Doering