From: Arne Schwabe Date: Wed, 18 Dec 2013 19:34:16 +0100 Message-Id: <1387391656-28820-2-git-send-email-arne@...1227...> In-Reply-To: <1387391656-28820-1-git-send-email-arne@...1227...> References: <1387391656-28820-1-git-send-email-arne@...1227...> Subject: [Openvpn-devel] [PATCH 2/2] Fix for server selecting address family List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: openvpn-devel@lists.sourceforge.net --- src/openvpn/socket.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 0459280..6da8f29 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -1507,21 +1507,10 @@ create_new_socket (struct link_socket* sock) /* clear destination set by set_actual_address */ CLEAR(sock->info.lsa->actual.dest); } - - /* - * Create the socket early if socket should be bound - */ - if (sock->bind_local) - { - create_socket (sock); - - if (sock->bind_local) - bind_local(sock); - } - } + /* bind socket if necessary */ void link_socket_init_phase1 (struct link_socket *sock, @@ -1943,6 +1932,17 @@ link_socket_init_phase2 (struct link_socket *sock, /* If socket has not already been created create it now */ if (sock->sd == SOCKET_UNDEFINED) { + /* If we have no --remote and have still not figured out the + * protocol family to use we will use the first of the bind */ + if (sock->bind_local && sock->info.lsa->bind_local + && !sock->info.lsa->actual.ai_family && !sock->remote_host) + { + msg (M_WARN, "Could not determine IPv4/IPv6 protocol. Using %s", + addr_family_name(sock->info.lsa->bind_local->ai_family)); + set_actual_address(&sock->info.lsa->actual, sock->info.lsa->bind_local); + + } + if (sock->info.lsa->actual.ai_family) { create_socket (sock); -- 1.8.3.4 (Apple Git-47)