Hi, On Sun, Apr 06, 2014 at 10:35:49AM +0200, Gert Doering wrote: > One possible approach would be to add this hack to the end of > openvpn_getaddrinfo():
A slightly simpler version of this could go to the beginning of create_socket() (--> no ai_next chain walking needed, etc.). Patch attached. With that patch in place, my OpenSolaris machine passes all my test cases. So functionally it's ok, just "philosophically" one might argue :-) gert -- USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany g...@greenie.muc.de fax: +49-89-35655025 g...@net.informatik.tu-muenchen.de
From 841ea45456e93f973be3f486a30549d35d9cade1 Mon Sep 17 00:00:00 2001 From: Gert Doering <g...@greenie.muc.de> List-Post: openvpn-devel@lists.sourceforge.net Date: Sun, 6 Apr 2014 10:44:38 +0200 Subject: [PATCH] Work around Solaris getaddrinfo() returing ai_protocol=0 Create_socket() and sub-functions assume that the ai_protocol value returned by getaddrinfo() is IPPROTO_UDP or IPPROTO_TCP. On Solaris, it is "0", because Solaris's socket() call will then "select the right protocol" - but it breaks our code. So if ai_protocol is 0, set the IPPROTO_* value according to ai_socktype (SOCK_DGRAM/SOCK_STREAM). Signed-off-by: Gert Doering <g...@greenie.muc.de> --- src/openvpn/socket.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 7deef0a..75dde7e 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -858,6 +858,19 @@ static void bind_local (struct link_socket *sock, const sa_family_t ai_family) static void create_socket (struct link_socket* sock, struct addrinfo* addr) { +#ifdef TARGET_SOLARIS + /* fixup Solaris' getaddrinfo() returning ai_protocol=0 + */ + if (addr->ai_protocol == 0 ) + { + msg( M_WARN, "invoking Solaris ai_protocol==0 fixup" ); + if( addr->ai_socktype == SOCK_DGRAM ) + addr->ai_protocol = IPPROTO_UDP; + else + addr->ai_protocol = IPPROTO_TCP; + } +#endif + if (addr->ai_protocol == IPPROTO_UDP) { sock->sd = create_socket_udp (addr, sock->sockflags); -- 1.5.6.5
pgpupPnztsIs8.pgp
Description: PGP signature