summaryrefslogtreecommitdiff
path: root/src/openvpn/socket.c
diff options
context:
space:
mode:
authorBernhard Schmidt <berni@debian.org>2018-03-04 22:22:32 +0100
committerBernhard Schmidt <berni@debian.org>2018-03-04 22:22:32 +0100
commitcf55ab99392458e723c7ebcc32c19bbd225b1f4b (patch)
treeb895b41b7629c9a31de5cc15e7aa7805ddac87ce /src/openvpn/socket.c
parent9683f890944ffb114f5f8214f694e0b339cf5a5a (diff)
New upstream version 2.4.5
Diffstat (limited to 'src/openvpn/socket.c')
-rw-r--r--src/openvpn/socket.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 4e7e3f9..211e744 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2017 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2018 OpenVPN Inc <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -496,7 +496,7 @@ openvpn_getaddrinfo(unsigned int flags,
goto done;
}
- openvpn_sleep(fail_wait_interval);
+ management_sleep(fail_wait_interval);
}
ASSERT(res);
@@ -1122,7 +1122,7 @@ socket_do_accept(socket_descriptor_t sd,
if (!socket_defined(new_sd))
{
- msg(D_LINK_ERRORS | M_ERRNO, "TCP: accept(%d) failed", sd);
+ msg(D_LINK_ERRORS | M_ERRNO, "TCP: accept(%d) failed", (int)sd);
}
/* only valid if we have remote_len_af!=0 */
else if (remote_len_af && remote_len != remote_len_af)
@@ -1193,7 +1193,7 @@ socket_listen_accept(socket_descriptor_t sd,
if (status <= 0)
{
- openvpn_sleep(1);
+ management_sleep(1);
continue;
}
@@ -1228,7 +1228,7 @@ socket_listen_accept(socket_descriptor_t sd,
break;
}
}
- openvpn_sleep(1);
+ management_sleep(1);
}
if (!nowait && openvpn_close_socket(sd))
@@ -1297,11 +1297,9 @@ socket_bind(socket_descriptor_t sd,
}
if (bind(sd, cur->ai_addr, cur->ai_addrlen))
{
- const int errnum = openvpn_errno();
- msg(M_FATAL, "%s: Socket bind failed on local address %s: %s",
+ msg(M_FATAL | M_ERRNO, "%s: Socket bind failed on local address %s",
prefix,
- print_sockaddr_ex(local->ai_addr, ":", PS_SHOW_PORT, &gc),
- strerror_ts(errnum, &gc));
+ print_sockaddr_ex(local->ai_addr, ":", PS_SHOW_PORT, &gc));
}
gc_free(&gc);
}
@@ -1376,7 +1374,7 @@ openvpn_connect(socket_descriptor_t sd,
#endif
break;
}
- openvpn_sleep(1);
+ management_sleep(1);
continue;
}
@@ -1433,7 +1431,7 @@ set_actual_address(struct link_socket_actual *actual, struct addrinfo *ai)
}
-void
+static void
socket_connect(socket_descriptor_t *sd,
const struct sockaddr *dest,
const int connect_timeout,
@@ -1475,10 +1473,8 @@ socket_connect(socket_descriptor_t *sd,
if (status)
{
- msg(D_LINK_ERRORS,
- "TCP: connect to %s failed: %s",
- print_sockaddr(dest, &gc),
- strerror_ts(status, &gc));
+ msg(D_LINK_ERRORS, "TCP: connect to %s failed: %s",
+ print_sockaddr(dest, &gc), strerror(status));
openvpn_close_socket(*sd);
*sd = SOCKET_UNDEFINED;
@@ -1790,6 +1786,8 @@ link_socket_init_phase1(struct link_socket *sock,
ASSERT(sock->info.proto == PROTO_TCP_SERVER);
ASSERT(!sock->inetd);
sock->sd = accept_from->sd;
+ /* inherit (possibly guessed) info AF from parent context */
+ sock->info.af = accept_from->info.af;
}
/* are we running in HTTP proxy mode? */
@@ -1877,12 +1875,12 @@ phase2_inetd(struct link_socket *sock, const struct frame *frame,
sock->info.lsa->actual.dest.addr.sa.sa_family = local_addr.addr.sa.sa_family;
dmsg(D_SOCKET_DEBUG, "inetd(%s): using sa_family=%d from getsockname(%d)",
proto2ascii(sock->info.proto, sock->info.af, false),
- local_addr.addr.sa.sa_family, sock->sd);
+ local_addr.addr.sa.sa_family, (int)sock->sd);
}
else
{
msg(M_WARN, "inetd(%s): getsockname(%d) failed, using AF_INET",
- proto2ascii(sock->info.proto, sock->info.af, false), sock->sd);
+ proto2ascii(sock->info.proto, sock->info.af, false), (int)sock->sd);
}
}
#else /* ifdef HAVE_GETSOCKNAME */
@@ -3888,12 +3886,11 @@ socket_bind_unix(socket_descriptor_t sd,
if (bind(sd, (struct sockaddr *) local, sizeof(struct sockaddr_un)))
{
- const int errnum = openvpn_errno();
- msg(M_FATAL, "%s: Socket bind[%d] failed on unix domain socket %s: %s",
+ msg(M_FATAL | M_ERRNO,
+ "%s: Socket bind[%d] failed on unix domain socket %s",
prefix,
(int)sd,
- sockaddr_unix_name(local, "NULL"),
- strerror_ts(errnum, &gc));
+ sockaddr_unix_name(local, "NULL"));
}
#ifdef HAVE_UMASK