Default gateway can't be determined on illumos/solaris
Hello.
In openvpn 2.3.4 on illumos/Solaris clients gateway for client can't be determined, because default stub is used instead of get_default_gateway() function. This means that the following push route option in server config is not working:
push "route remote_host 255.255.255.255 net_gateway"
OpenVPN client says that it doesn't know net_gateway.
The following patch mostly uses existing FreeBSD code to add get_default_gateway() implementation: https://github.com/pyhalov/oi-userland/blob/openvpn/components/openvpn/patches/get_default_gateway.patch .
The difference is that on Solaris there's no sa_len field.
I'm not absolutely sure that patch is correct, but as I see in route.c only sockaddr_in structures are supposed to be passed to NEXTADDR and ADVANCE macroses. This patch works for me.
Signature · 3 lines
Best regards, Alexander Pyhalov, system administrator of Southern Federal University IT department
Hi,
Quoted 11 lines · Alexander Pyhalov
In openvpn 2.3.4 on illumos/Solaris clients gateway for client can't be determined, because default stub is used instead of
get_default_gateway()function. This means that the following push route option in server config is not working:
push "routeremote_host255.255.255.255net_gateway"OpenVPN client says that it doesn't know
net_gateway. The following patch mostly uses existing FreeBSD code to addget_default_gateway()implementation:
https://github.com/pyhalov/oi-userland/blob/openvpn/components/openvpn/patches/get_default_gateway.patch
.
Thanks. Feature-ACK, but... please rebase against git master, as the code in question looks quite a bit different now, after
commit cab6305be749930eae9c4a1348fb90c4c515d8d7
Author: Gert Doering <[email protected]...> Date: Tue Jan 14 14:33:18 2014 +0100
Merge get_default_gateway() implementation for all 4+1 BSD variants.
(maybe send both patches, against 2.3.4 and git master, as the code is really different enough that "git cherry-pick" won't work... that's what you get for cleaning up - more maintenance work!)
Please then send to the list with "git-send-email" - our ACKing process works on what is here on the list, so "somthing on github" can't be properly archived.
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]...There are two patches here - against master and against 2.3 branch. It seems my first email didn't go to the list, because I used wrong From address...
From: [email protected]...
GIT: [PATCH] Default gateway can't be determined on illumos/Solaris
GIT: [PATCH] Default gateway can't be determined on illumos/Solaris
There are two patches here - against master and against 2.3 branch.
There are two patches here - against master and against 2.3 branch.
PATCH 1/1 Default gateway can't be determined on illumos/Solaris platforms
In reply to [email protected]...From: Alexander Pyhalov <[email protected]...>
The logic which is used on BSD is preserved. The only distinction is that illumos doesn't provide sa_len field in sockaddr structures.
--- src/openvpn/route.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
src/openvpn/route.c +19 -2
@@ -2601,7 +2601,7 @@ get_default_gateway (struct route_gateway_info *rgi) gc_free (&gc); } -#elif defined(TARGET_FREEBSD)||defined(TARGET_DRAGONFLY) +#elif defined(TARGET_FREEBSD)||defined(TARGET_DRAGONFLY)||defined(TARGET_SOLARIS)#include <sys/types.h> #include <sys/socket.h>
@@ -2629,6 +2629,8 @@ get_default_gateway (struct route_gateway_info *rgi)struct sockaddr *gate =NULL , *sa;struct rt_msghdr *rtm_aux; +#if defined(TARGET_FREEBSD )||defined(TARGET_DRAGONFLY ) +#define NEXTADDR (w, u) \ if (rtm_addrs & (w)) {\ l = ROUNDUP(u.sa_len); memmove(cp, &(u), l); cp += l;\
@@ -2636,6 +2638,18 @@ get_default_gateway (struct route_gateway_info *rgi)#define ADVANCE (x, n) (x += ROUNDUP((n)->sa_len)) +#else /* TARGET_SOLARIS */ + +#define NEXTADDR (w, u) \ + if (rtm_addrs & (w)) {\ + l = ROUNDUP(sizeof(struct sockaddr_in)); memmove(cp, &(u), l); cp += l;\ + } + +#define ADVANCE (x, n) (x += ROUNDUP(sizeof(struct sockaddr_in))) + +#endif + +#define rtm m_rtmsg.m_rtmCLEAR (*rgi);
@@ -2655,9 +2669,12 @@ get_default_gateway (struct route_gateway_info *rgi) rtm.rtm_addrs = rtm_addrs; so_dst.sa_family =AF_INET ; - so_dst.sa_len =sizeof (struct sockaddr_in ); so_mask.sa_family =AF_INET ; + +#if defined(TARGET_FREEBSD )||defined(TARGET_DRAGONFLY ) + so_dst.sa_len =sizeof (struct sockaddr_in ); so_mask.sa_len =sizeof (struct sockaddr_in ); +#endif NEXTADDR (RTA_DST , so_dst);NEXTADDR (RTA_NETMASK , so_mask);
Signature · 1 line
1.7.9.2
[Openvpn-devel] [PATCH applied] Re: Default gateway can't be determined on illumos/Solaris platforms
ACK. Tested on OpenSolaris 10 (5.11), works as advertised, has no impact on other platforms.
Just as a remark: the patch in master is more feature-complete as it benefits from the code cleanup/unification of all the BSDs and MacOS X in cab6305be749930eae - the 2.3 one can only show the gateway:
Wed Dec 31 10:22:22 2014 ROUTE_GATEWAY 194.97.140.30
while the one in "master" can show netmask and interface as well:
Wed Dec 31 10:24:12 2014 ROUTE_GATEWAY 194.97.140.30/255.255.255.224 IFACE=pcn0
.. but I'll leave it at that, to avoid more intrusive changes to 2.3.
Your patch has been applied to the release/2.3 branch.
commit b6dc199077079310d9f26fa8b366f4e71d32f6c9
Author: Alexander Pyhalov Date: Tue Oct 14 23:43:21 2014 +0400
Default gateway can't be determined on illumos/Solaris platforms
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9128
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH 1/1 Default gateway can't be determined on illumos/Solaris platforms
In reply to [email protected]...From: Alexander Pyhalov <[email protected]...>
The logic which is used on BSD is preserved. The only distinction is that illumos doesn't provide sa_len field in sockaddr structures.
--- src/openvpn/route.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
src/openvpn/route.c +19 -2
@@ -2626,7 +2626,7 @@ get_default_gateway (struct route_gateway_info *rgi) gc_free (&gc); } -#elif defined(TARGET_DARWIN) || \ +#elif defined(TARGET_DARWIN) || defined(TARGET_SOLARIS) || \ defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) || \ defined(TARGET_OPENBSD) || defined(TARGET_NETBSD)
@@ -2661,12 +2661,21 @@ struct rtmsg { ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))#endif +#if defined(TARGET_SOLARIS ) +#define NEXTADDR (w, u) \ + if (rtm_addrs & (w)) {\ + l = ROUNDUP(sizeof(struct sockaddr_in)); memmove(cp, &(u), l); cp += l;\ + } + +#define ADVANCE (x, n) (x += ROUNDUP(sizeof(struct sockaddr_in))) +#else #define NEXTADDR (w, u) \ if (rtm_addrs & (w)) {\ l = ROUNDUP(u.sa_len); memmove(cp, &(u), l); cp += l;\ }#define ADVANCE (x, n) (x += ROUNDUP((n)->sa_len)) +#endif #define max (a,b) ((a) > (b) ? (a) : (b))
@@ -2703,9 +2712,12 @@ get_default_gateway (struct route_gateway_info *rgi) rtm.rtm_addrs = rtm_addrs; so_dst.sa_family =AF_INET ; - so_dst.sa_len =sizeof (struct sockaddr_in ); so_mask.sa_family =AF_INET ; + +#ifndef TARGET_SOLARIS + so_dst.sa_len =sizeof (struct sockaddr_in ); so_mask.sa_len =sizeof (struct sockaddr_in ); +#endif NEXTADDR (RTA_DST , so_dst);NEXTADDR (RTA_NETMASK , so_mask);
@@ -2829,7 +2841,12 @@ get_default_gateway (struct route_gateway_info *rgi)for (cp = buffer; cp <= buffer + ifc.ifc_len -sizeof (struct ifreq ); ) { ifr = (struct ifreq *)cp; +#if defined(TARGET_SOLARIS ) +const size_t len =sizeof (ifr->ifr_name) +sizeof (ifr->ifr_addr); +#else const size_t len =sizeof (ifr->ifr_name) +max (sizeof (ifr->ifr_addr), ifr->ifr_addr.sa_len); +#endif +if (!ifr->ifr_addr.sa_family)break ;if (!strncmp (ifr->ifr_name, rgi->iface,IFNAMSIZ ))
Signature · 1 line
1.7.9.2
[Openvpn-devel] [PATCH applied] Re: Default gateway can't be determined on illumos/Solaris platforms
ACK. Tested on OpenSolaris 10 (5.11), works as advertised, has no impact on other platforms.
Your patch has been applied to the master branch.
commit 01bfdf3a38059cf907bec60d6fd36a5eeef59032
Author: Alexander Pyhalov Date: Tue Oct 14 23:43:22 2014 +0400
Default gateway can't be determined on illumos/Solaris platforms
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9129
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Hi,
Quoted 3 lines · On Tue, Oct 14, 2014 at 11:43:18PM +0400, [email protected]... wrote:
There are two patches here - against master and against 2.3 branch. It seems my first email didn't go to the list, because I used wrong From address...
Thanks. Patches look good on first glance - will look more closely ASAP and merge.
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]...Quoted 7 lines · Alexander Pyhalov
Hello.
In openvpn 2.3.4 on illumos/Solaris clients gateway for client can't be determined, because default stub is used instead ofget_default_gateway()function. This means that the following push route option in server config is not working:
push "routeremote_host255.255.255.255net_gateway"
Quoted 5 lines
OpenVPN client says that it doesn't know
net_gateway. The following patch mostly uses existing FreeBSD code to addget_default_gateway()implementation:
https://github.com/pyhalov/oi-userland/blob/openvpn/components/openvpn/patches/get_default_gateway.patch
.
Hello.
I've sent two patches (from [email protected]... address) against 2.3 and master branch), correcting to the list, implementing get_default_gateway() for Solaris / illumos platforms. Are there any issues with them?
Signature · 4 lines
С уважением, Александр Пыхалов, программист отдела телекоммуникационной инфраструктуры управления информационно-коммуникационной инфраструктуры ЮФУ
Hi,
Quoted 4 lines · Alexander Pyhalov
I've sent two patches (from [email protected]... address) against 2.3 and master branch), correcting to the list, implementing
get_default_gateway()for Solaris / illumos platforms. Are there any issues with them?
Sorry for never replying to your mail. The patches are sitting in my to-be-reviewed-and-tested queue, but I got distracted by work, security related stuff, etc.
Will handle.
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]...