Skip to contentSkip to conversation

Remove --disable-multihome option

PATCH Superseded Arne Schwabe 3 participants 20 messages Apr 21, 2021 – Apr 22, 2021

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/7 Remove --disable-multihome option

With this change we always build multihome support if the operating system supports it.

---
 configure.ac          | 7 -------
 src/openvpn/syshead.h | 2 +-
 2 files changed, 1 insertion(+), 8 deletions(-)
configure.ac +0 -7
index 747325164..aaac65c3d 100644
@@ -121,13 +121,6 @@ AC_ARG_ENABLE(
 	[enable_fragment="yes"]
 )
 
-AC_ARG_ENABLE(
-	[multihome],
-	[AS_HELP_STRING([--disable-multihome], [disable multi-homed UDP server support (--multihome) @<:@default=yes@:>@])],
-	,
-	[enable_multihome="yes"]
-)
-
 AC_ARG_ENABLE(
 	[port-share],
 	[AS_HELP_STRING([--disable-port-share], [disable TCP server port-share support (--port-share) @<:@default=yes@:>@])],
src/openvpn/syshead.h +1 -1
index bac07d102..0b029c648 100644
@@ -391,7 +391,7 @@ typedef int MIB_TCP_STATE;
  * Does this platform support linux-style IP_PKTINFO
  * or bsd-style IP_RECVDSTADDR ?
  */
-#if defined(ENABLE_MULTIHOME) && ((defined(HAVE_IN_PKTINFO) && defined(IP_PKTINFO)) || defined(IP_RECVDSTADDR)) && defined(HAVE_MSGHDR) && defined(HAVE_CMSGHDR) && defined(HAVE_IOVEC) && defined(CMSG_FIRSTHDR) && defined(CMSG_NXTHDR) && defined(HAVE_RECVMSG) && defined(HAVE_SENDMSG)
+#if ((defined(HAVE_IN_PKTINFO) && defined(IP_PKTINFO)) || defined(IP_RECVDSTADDR)) && defined(HAVE_MSGHDR) && defined(HAVE_CMSGHDR) && defined(HAVE_IOVEC) && defined(CMSG_FIRSTHDR) && defined(CMSG_NXTHDR) && defined(HAVE_RECVMSG) && defined(HAVE_SENDMSG)
 #define ENABLE_IP_PKTINFO 1
 #else
 #define ENABLE_IP_PKTINFO 0
Signature · 1 line
2.31.1
#1 lore raw

PATCH 2/7 Move direct.h header where it is used

The direct.h header provides only a handful of functions [1] of which we only use _wchdir. Directly included the direct.h file where it is used and remove autoconf magic around it.

[1] https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/as5kw0ze(v=vs.110)?redirectedfrom=MSDN

---
 configure.ac           | 2 +-
 src/openvpn/platform.c | 4 ++++
 src/openvpn/syshead.h  | 4 ----
 3 files changed, 5 insertions(+), 5 deletions(-)
configure.ac +1 -1
index aaac65c3d..a67bf2595 100644
@@ -407,7 +407,7 @@ AX_TYPE_SOCKLEN_T
 AC_CHECK_SIZEOF([unsigned int])
 AC_CHECK_SIZEOF([unsigned long])
 AC_CHECK_HEADERS([ \
-	fcntl.h io.h direct.h \
+	fcntl.h io.h \
 	sys/types.h sys/socket.h \
 	unistd.h dlfcn.h \
 	netinet/in.h netinet/in_systm.h \
src/openvpn/platform.c +4 -0
index 45ee54541..c63c1d994 100644
@@ -39,6 +39,10 @@
 
 #include "platform.h"
 
+#if _WIN32
+#include <direct.h>
+#endif
+
 /* Redefine the top level directory of the filesystem
  * to restrict access to files for security */
 void
src/openvpn/syshead.h +0 -4
index 0b029c648..cb9bf7dc7 100644
@@ -100,10 +100,6 @@
 #include <fcntl.h>
 #endif
 
-#ifdef HAVE_DIRECT_H
-#include <direct.h>
-#endif
-
 #ifdef HAVE_IO_H
 #include <io.h>
 #endif
Signature · 1 line
2.31.1
#3 lore raw

PATCH 3/7 Remove always enabled USE_64_BIT_COUNTERS define

In reply to Arne Schwabe

Also change the types to use C99 uint64_t and its printf u64 define.

---
 src/openvpn/common.h  | 15 +++------------
 src/openvpn/syshead.h |  5 -----
 2 files changed, 3 insertions(+), 17 deletions(-)
src/openvpn/common.h +3 -12
index 623b3e0d7..544fa238e 100644
@@ -25,19 +25,10 @@
 #define COMMON_H
 
 /*
- * Statistics counters and associated printf formats.
+ * Statistics counters and associated printf format.
  */
-#ifdef USE_64_BIT_COUNTERS
-typedef unsigned long long int counter_type;
-#ifdef _WIN32
-#define counter_format  "%I64u"
-#else
-#define counter_format  "%llu"
-#endif
-#else  /* ifdef USE_64_BIT_COUNTERS */
-typedef unsigned int counter_type;
-#define counter_format   "%u"
-#endif
+typedef uint64_t counter_type;
+#define counter_format  "%" PRIu64
 
 /*
  * Time intervals
src/openvpn/syshead.h +0 -5
index cb9bf7dc7..f29c63c73 100644
@@ -458,11 +458,6 @@ socket_defined(const socket_descriptor_t sd)
     return sd != SOCKET_UNDEFINED;
 }
 
-/*
- * Should statistics counters be 64 bits?
- */
-#define USE_64_BIT_COUNTERS
-
 /*
  * Should we enable the use of execve() for calling subprocesses,
  * instead of system()?
Signature · 1 line
2.31.1
#8 lore raw

PATCH 4/7 Fix a number of mingw warnings

In reply to Arne Schwabe

Move to definition inside the ifdef where they are used to avoid unused warnings.

Fix a few printf related warnings when DWORD is used as paramter and the printf format should be %lu (long unsigned int)

---
 src/openvpn/route.c  | 4 ++--
 src/openvpn/socket.c | 3 ++-
 src/openvpn/tun.c    | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
src/openvpn/route.c +2 -2
index c6b3dc584..c83bd9e2b 100644
@@ -2360,7 +2360,6 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt,
 #else
     int metric;
 #endif
-    const char *device = tt->actual_name;
     bool gateway_needed = false;
 
     if ((r6->flags & (RT_DEFINED|RT_ADDED)) != (RT_DEFINED|RT_ADDED))
@@ -2369,6 +2368,7 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt,
     }
 
 #ifndef _WIN32
+    const char *device = tt->actual_name;
     if (r6->iface != NULL)              /* vpn server special route */
     {
         device = r6->iface;
@@ -2713,7 +2713,7 @@ get_default_gateway_row(const MIB_IPFORWARDTABLE *routes)
             const DWORD index = row->dwForwardIfIndex;
             const DWORD metric = row->dwForwardMetric1;
 
-            dmsg(D_ROUTE_DEBUG, "GDGR: route[%d] %s/%s i=%d m=%d",
+            dmsg(D_ROUTE_DEBUG, "GDGR: route[%lu] %s/%s i=%d m=%d",
                  i,
                  print_in_addr_t((in_addr_t) net, 0, &gc),
                  print_in_addr_t((in_addr_t) mask, 0, &gc),
src/openvpn/socket.c +2 -1
index b13d2e0f1..8a6e42cc6 100644
@@ -2837,10 +2837,11 @@ print_link_socket_actual_ex(const struct link_socket_actual *act,
 {
     if (act)
     {
-        char ifname[IF_NAMESIZE] = "[undef]";
         struct buffer out = alloc_buf_gc(128, gc);
         buf_printf(&out, "%s", print_sockaddr_ex(&act->dest.addr.sa, separator, flags, gc));
 #if ENABLE_IP_PKTINFO
+        char ifname[IF_NAMESIZE] = "[undef]";
+
         if ((flags & PS_SHOW_PKTINFO) && addr_defined_ipi(act))
         {
             switch (act->dest.addr.sa.sa_family)
src/openvpn/tun.c +1 -1
index 2c1b270dd..4ef34e4eb 100644
@@ -5606,7 +5606,7 @@ windows_set_mtu(const int iface_index, const short family,
 
     if (err != NO_ERROR)
     {
-        msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%u if_index=%d]",
+        msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%lu if_index=%d]",
             family_name, strerror_win32(err, &gc), err, iface_index);
     }
     else
Signature · 1 line
2.31.1
#13 lore raw

PATCH 5/7 Remove support for blocking connect()

In reply to Arne Schwabe

It is hard to imagine that we still have any supported OS that does not support non-blocking connect while still supporting non-blocking sockets in general.

---
 src/openvpn/socket.c  |  8 --------
 src/openvpn/syshead.h | 11 -----------
 2 files changed, 19 deletions(-)
src/openvpn/socket.c +0 -8
index 8a6e42cc6..4e13c65e8 100644
@@ -1459,7 +1459,6 @@ openvpn_connect(socket_descriptor_t sd,
     protect_fd_nonlocal(sd, remote);
 #endif
 
-#ifdef CONNECT_NONBLOCK
     set_nonblock(sd);
     status = connect(sd, remote, af_addr_size(remote->sa_family));
     if (status)
@@ -1540,13 +1539,6 @@ openvpn_connect(socket_descriptor_t sd,
             }
         }
     }
-#else  /* ifdef CONNECT_NONBLOCK */
-    status = connect(sd, remote, af_addr_size(remote->sa_family));
-    if (status)
-    {
-        status = openvpn_errno();
-    }
-#endif /* ifdef CONNECT_NONBLOCK */
 
     return status;
 }
src/openvpn/syshead.h +0 -11
index f29c63c73..a964ffd35 100644
@@ -155,10 +155,6 @@
 #include <poll.h>
 #endif
 
-#ifdef HAVE_SYS_EPOLL_H
-#include <sys/epoll.h>
-#endif
-
 #ifdef ENABLE_SELINUX
 #include <selinux/selinux.h>
 #endif
@@ -545,13 +541,6 @@ socket_defined(const socket_descriptor_t sd)
 #define EPOLL 0
 #endif
 
-/*
- * Is non-blocking connect() supported?
- */
-#if defined(SOL_SOCKET) && defined(SO_ERROR) && defined(EINPROGRESS) && defined(ETIMEDOUT)
-#define CONNECT_NONBLOCK
-#endif
-
 /*
  * Compression support
  */
Signature · 1 line
2.31.1
#16 lore raw

PATCH 6/7 Replace OS_SPECIFIC_DIRSEP with PATH_SEPARATOR

In reply to Arne Schwabe

We have two define that do exactly the same. Also move the check from configure.ac to syshead.h since it is really only checking for Windows.

---
 configure.ac             | 8 --------
 src/openvpn/platform.c   | 2 +-
 src/openvpn/ssl_verify.c | 2 +-
 src/openvpn/syshead.h    | 6 ++++--
 4 files changed, 6 insertions(+), 12 deletions(-)
configure.ac +0 -8
index a67bf2595..3b4d3cbc7 100644
@@ -1133,14 +1133,6 @@ if test -n "${GIT}" -a -d "${srcdir}/.git"; then
 fi
 AC_MSG_RESULT([${GIT_CHECKOUT}])
 
-if test -n "${SP_PLATFORM_WINDOWS}"; then
-	AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #"
-	AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
-else
-	AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['/'], [Path separator])
-	AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["/"], [Path separator])
-fi
-
 dnl enable --x509-username-field feature if requested
 if test "${enable_x509_alt_username}" = "yes"; then
 	if test "${with_crypto_library}" = "mbedtls" ; then
src/openvpn/platform.c +1 -1
index c63c1d994..bf7b1aa0a 100644
@@ -486,7 +486,7 @@ platform_gen_path(const char *directory, const char *filename,
         struct buffer out = alloc_buf_gc(outsize, gc);
         char dirsep[2];
 
-        dirsep[0] = OS_SPECIFIC_DIRSEP;
+        dirsep[0] = PATH_SEPARATOR;
         dirsep[1] = '\0';
 
         if (directory)
src/openvpn/ssl_verify.c +1 -1
index 7608155cd..14aaf2bf7 100644
@@ -616,7 +616,7 @@ verify_check_crl_dir(const char *crl_dir, openvpn_x509_cert_t *cert,
         goto cleanup;
     }
 
-    if (!openvpn_snprintf(fn, sizeof(fn), "%s%c%s", crl_dir, OS_SPECIFIC_DIRSEP, serial))
+    if (!openvpn_snprintf(fn, sizeof(fn), "%s%c%s", crl_dir, PATH_SEPARATOR, serial))
     {
         msg(D_HANDSHAKE, "VERIFY CRL: filename overflow");
         goto cleanup;
src/openvpn/syshead.h +4 -2
index a964ffd35..28ccca087 100644
@@ -432,9 +432,11 @@ typedef unsigned short sa_family_t;
  * Directory separation char
  */
 #ifdef _WIN32
-#define OS_SPECIFIC_DIRSEP '\\'
+#define PATH_SEPARATOR '\\'
+#define PATH_SEPARATOR_STR "\\"
 #else
-#define OS_SPECIFIC_DIRSEP '/'
+#define PATH_SEPARATOR '/'
+#define PATH_SEPARATOR_STR "/"
 #endif
 
 /*
Signature · 1 line
2.31.1
#18 lore raw

PATCH 7/7 Remove a number of platform specific checks in configure.ac

In reply to Arne Schwabe

- Remove windows XP/old mingw compat code in socket.c
- Use _WIN32 instead checking for existence of windows.h, winsock2.h and ws2tcpip.h in autconf
- Remove check for unlink. The last remaining use is a check inside a Unix socket.
- Even Windows has umask, so remove the check for it

---
 configure.ac          | 11 +++++------
 src/compat/compat.h   |  5 +----
 src/openvpn/event.c   |  4 ++++
 src/openvpn/socket.c  | 16 ----------------
 src/openvpn/syshead.h |  6 ++----
 5 files changed, 12 insertions(+), 30 deletions(-)
configure.ac +5 -6
index 3b4d3cbc7..94897c863 100644
@@ -412,7 +412,6 @@ AC_CHECK_HEADERS([ \
 	unistd.h dlfcn.h \
 	netinet/in.h netinet/in_systm.h \
 	netinet/tcp.h arpa/inet.h netdb.h \
-	windows.h winsock2.h ws2tcpip.h \
 	versionhelpers.h \
 ])
 AC_CHECK_HEADERS([ \
@@ -438,13 +437,13 @@ SOCKET_INCLUDES="
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
-#ifdef HAVE_WINDOWS_H
+#ifdef _WIN32
 #include <windows.h>
 #endif
-#ifdef HAVE_WINSOCK2_H
+#ifdef _WIN32
 #include <winsock2.h>
 #endif
-#ifdef HAVE_WS2TCPIP_H
+#ifdef _WIN32
 #include <ws2tcpip.h>
 #endif
 #ifdef HAVE_NETINET_IN_SYSTM_H
@@ -623,8 +622,8 @@ AC_CHECK_FUNCS([ \
 	daemon chroot getpwnam setuid nice system getpid dup dup2 \
 	syslog openlog mlockall getrlimit getgrnam setgid \
 	setgroups flock readv writev time gettimeofday \
-	setsid chdir getpeername unlink \
-	chsize ftruncate execve getpeereid umask basename dirname access \
+	setsid chdir getpeername \
+	chsize ftruncate execve getpeereid basename dirname access \
 	epoll_create strsep \
 ])
 
src/compat/compat.h +1 -4
index 2bf48a5eb..026974a81 100644
@@ -24,11 +24,8 @@
 #ifndef COMPAT_H
 #define COMPAT_H
 
-#ifdef HAVE_WINSOCK2_H
+#ifdef _WIN32
 #include <winsock2.h>
-#endif
-
-#ifdef HAVE_WS2TCPIP_H
 #include <ws2tcpip.h>
 #endif
 
src/openvpn/event.c +4 -0
index 14a25155c..d766f8be8 100644
@@ -35,6 +35,10 @@
 #include "event.h"
 #include "fdmisc.h"
 
+#if EPOLL
+#include <sys/epoll.h>
+#endif
+
 #include "memdbg.h"
 
 /*
src/openvpn/socket.c +0 -16
index 4e13c65e8..01c65b3e0 100644
@@ -1385,14 +1385,6 @@ socket_listen_accept(socket_descriptor_t sd,
     return new_sd;
 }
 
-/* older mingw versions and WinXP do not have this define,
- * but Vista and up support the functionality - just define it here
- */
-#ifdef _WIN32
-#ifndef IPV6_V6ONLY
-#define IPV6_V6ONLY 27
-#endif
-#endif
 void
 socket_bind(socket_descriptor_t sd,
             struct addrinfo *local,
@@ -3905,10 +3897,7 @@ socket_bind_unix(socket_descriptor_t sd,
                  const char *prefix)
 {
     struct gc_arena gc = gc_new();
-
-#ifdef HAVE_UMASK
     const mode_t orig_umask = umask(0);
-#endif
 
     if (bind(sd, (struct sockaddr *) local, sizeof(struct sockaddr_un)))
     {
@@ -3919,10 +3908,7 @@ socket_bind_unix(socket_descriptor_t sd,
             sockaddr_unix_name(local, "NULL"));
     }
 
-#ifdef HAVE_UMASK
     umask(orig_umask);
-#endif
-
     gc_free(&gc);
 }
 
@@ -3967,12 +3953,10 @@ void
 socket_delete_unix(const struct sockaddr_un *local)
 {
     const char *name = sockaddr_unix_name(local, NULL);
-#ifdef HAVE_UNLINK
     if (name && strlen(name))
     {
         unlink(name);
     }
-#endif
 }
 
 bool
src/openvpn/syshead.h +2 -4
index 28ccca087..15de0b46d 100644
@@ -100,10 +100,6 @@
 #include <fcntl.h>
 #endif
 
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-
 #ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
 #endif
@@ -338,6 +334,8 @@ typedef int MIB_TCP_STATE;
 #include <iphlpapi.h>
 #include <wininet.h>
 #include <shellapi.h>
+#include <io.h>
+
 /* The following two headers are needed of PF_INET6 */
 #include <winsock2.h>
 #include <ws2tcpip.h>
Signature · 1 line
2.31.1
#14 lore raw

Re: [Openvpn-devel] [PATCH 5/7] Remove support for blocking connect()

In reply to Arne Schwabe

Hi,

Quoted 3 lines · Arne Schwabe

It is hard to imagine that we still have any supported OS that does not support non-blocking connect while still supporting non-blocking sockets in general.

[..]

src/openvpn/syshead.h line 161

Quoted 12 lines
src/openvpn/syshead.h +0 -4
index f29c63c73..a964ffd35 100644
@@ -155,10 +155,6 @@
 #include <poll.h>
 #endif
 
-#ifdef HAVE_SYS_EPOLL_H
-#include <sys/epoll.h>
-#endif
-

Is that intentional?

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#15 lore raw

Re: [Openvpn-devel] [PATCH 5/7] Remove support for blocking connect()

Am 21.04.21 um 22:32 schrieb Gert Doering:

Quoted 15 lines

Hi,

Quoted 3 lines · Arne Schwabe

It is hard to imagine that we still have any supported OS that does not support non-blocking connect while still supporting non-blocking sockets in general.

[..]

Quoted 8 lines
src/openvpn/syshead.h +0 -0
index f29c63c73..a964ffd35 100644
@@ -155,10 +155,6 @@
 #include <poll.h>
 #endif
 
Quoted 6 lines

src/openvpn/syshead.h line 161

Quoted 4 lines
src/openvpn/syshead.h +0 -4
-#ifdef HAVE_SYS_EPOLL_H
-#include <sys/epoll.h>
-#endif
-

Is that intentional?

Managed to slip into wrong patch. I accidentally commited it with 5/7 instead of 7/7.

Arne

#19 lore raw
In reply to Arne Schwabe

Hi,

Quoted 4 lines · Arne Schwabe

With this change we always build multihome support if the operating system supports it.

Shouldn't these go too?

$ grep -rn MULTIHOME
config-msvc.h:13:#define ENABLE_MULTIHOME 1
configure.ac:1155:test "${enable_multihome}" = "yes" &&
AC_DEFINE([ENABLE_MULTIHOME], [1], [Enable multi-homed UDP server
capability])

Otherwise it looks good.

Regards,

Signature · 1 line
Antonio Quartulli
#2 lore raw

Re: [Openvpn-devel] [PATCH 2/7] Move direct.h header where it is used

In reply to Arne Schwabe

Hi,

Quoted 7 lines · Arne Schwabe

The direct.h header provides only a handful of functions [1] of which we only use _wchdir. Directly included the direct.h file where it is used and remove autoconf magic around it.

[1] https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/as5kw0ze(v=vs.110)?redirectedfrom=MSDN

Should this be removed too?

config-msvc.h:33:#define HAVE_DIRECT_H 1

Regards,

Signature · 1 line
Antonio Quartulli
Acked-by on v1 3/7
#4 lore raw

Re: [Openvpn-devel] [PATCH 3/7] Remove always enabled USE_64_BIT_COUNTERS define

In reply to Arne Schwabe

Hi,

Quoted 3 lines · Arne Schwabe

Also change the types to use C99 uint64_t and its printf u64 define.

This patch looks good and compiles on my test rig.

As expected, it is basically removing a bunch of ifdefs always forced on the "true-branch".

Since we recently confirmed that all our suppotred platforms also support C99, I don't expect breakages on any *BSD either.

Signature · 1 line
Antonio Quartulli
#9 lore raw

Re: [Openvpn-devel] [PATCH 4/7] Fix a number of mingw warnings

In reply to Arne Schwabe

Hi,

Quoted 26 lines · Arne Schwabe

Move to definition inside the ifdef where they are used to avoid unused warnings.

Fix a few printf related warnings when DWORD is used as paramter and the printf format should be %lu (long unsigned int)

---
 src/openvpn/route.c  | 4 ++--
 src/openvpn/socket.c | 3 ++-
 src/openvpn/tun.c    | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
src/openvpn/route.c +0 -1
index c6b3dc584..c83bd9e2b 100644
@@ -2360,7 +2360,6 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt,
 #else
     int metric;
 #endif
-    const char *device = tt->actual_name;
     bool gateway_needed = false;
 
     if ((r6->flags & (RT_DEFINED|RT_ADDED)) != (RT_DEFINED|RT_ADDED))

src/openvpn/route.c delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt, · line 2371

Quoted 4 lines
src/openvpn/route.c +1 -0
@@ -2369,6 +2368,7 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt,
     }
 
 #ifndef _WIN32
+    const char *device = tt->actual_name;

This variable is not used in all cases embraced by "ifndef _WIN32". I.e. I think it is not used when any of the following is defined:
TARGET_OPENBSD
TARGET_NETBSD
TARGET_AIX

Therefore this change would fix *only* the warning on Windows. Do we want to go this way? or should we rather rearrange the ifdefs a bit so that we have a cleaner change/function?

src/openvpn/route.c get_default_gateway_row(const MIB_IPFORWARDTABLE *routes) · line 2716

Quoted 9 lines
src/openvpn/route.c +1 -1
     if (r6->iface != NULL)              /* vpn server special route */
     {
         device = r6->iface;
@@ -2713,7 +2713,7 @@ get_default_gateway_row(const MIB_IPFORWARDTABLE *routes)
             const DWORD index = row->dwForwardIfIndex;
             const DWORD metric = row->dwForwardMetric1;
 
-            dmsg(D_ROUTE_DEBUG, "GDGR: route[%d] %s/%s i=%d m=%d",
+            dmsg(D_ROUTE_DEBUG, "GDGR: route[%lu] %s/%s i=%d m=%d",

shouldn't be enough to convert to %u ? (/me is not a DOWRD expert though)

Quoted 8 lines
src/openvpn/route.c +0 -0
                  i,
                  print_in_addr_t((in_addr_t) net, 0, &gc),
                  print_in_addr_t((in_addr_t) mask, 0, &gc),
src/openvpn/socket.c +0 -0
index b13d2e0f1..8a6e42cc6 100644

src/openvpn/socket.c print_link_socket_actual_ex(const struct link_socket_actual *act, · line 2843

Quoted 8 lines
src/openvpn/socket.c +1 -1
@@ -2837,10 +2837,11 @@ print_link_socket_actual_ex(const struct link_socket_actual *act,
 {
     if (act)
     {
-        char ifname[IF_NAMESIZE] = "[undef]";
         struct buffer out = alloc_buf_gc(128, gc);
         buf_printf(&out, "%s", print_sockaddr_ex(&act->dest.addr.sa, separator, flags, gc));
 #if ENABLE_IP_PKTINFO
+        char ifname[IF_NAMESIZE] = "[undef]";

This makes sense.

Quoted 9 lines
src/openvpn/socket.c +1 -0
+
         if ((flags & PS_SHOW_PKTINFO) && addr_defined_ipi(act))
         {
             switch (act->dest.addr.sa.sa_family)
src/openvpn/tun.c +0 -0
index 2c1b270dd..4ef34e4eb 100644

src/openvpn/tun.c windows_set_mtu(const int iface_index, const short family, · line 5609

Quoted 5 lines
src/openvpn/tun.c +1 -1
@@ -5606,7 +5606,7 @@ windows_set_mtu(const int iface_index, const short family,
 
     if (err != NO_ERROR)
     {
-        msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%u if_index=%d]",
+        msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%lu if_index=%d]",

same question as above.

src/openvpn/tun.c windows_set_mtu(const int iface_index, const short family, · line 5612

Quoted 4 lines
src/openvpn/tun.c +0 -0
             family_name, strerror_win32(err, &gc), err, iface_index);
     }
     else

Regards,

Signature · 1 line
Antonio Quartulli
#17 lore raw

Re: [Openvpn-devel] [PATCH 6/7] Replace OS_SPECIFIC_DIRSEP with PATH_SEPARATOR

In reply to Arne Schwabe

Hi,

Quoted 66 lines · Arne Schwabe

We have two define that do exactly the same. Also move the check from configure.ac to syshead.h since it is really only checking for Windows.

---
 configure.ac             | 8 --------
 src/openvpn/platform.c   | 2 +-
 src/openvpn/ssl_verify.c | 2 +-
 src/openvpn/syshead.h    | 6 ++++--
 4 files changed, 6 insertions(+), 12 deletions(-)
configure.ac +0 -8
index a67bf2595..3b4d3cbc7 100644
@@ -1133,14 +1133,6 @@ if test -n "${GIT}" -a -d "${srcdir}/.git"; then
 fi
 AC_MSG_RESULT([${GIT_CHECKOUT}])
 
-if test -n "${SP_PLATFORM_WINDOWS}"; then
-	AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #"
-	AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
-else
-	AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['/'], [Path separator])
-	AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["/"], [Path separator])
-fi
-
 dnl enable --x509-username-field feature if requested
 if test "${enable_x509_alt_username}" = "yes"; then
 	if test "${with_crypto_library}" = "mbedtls" ; then
src/openvpn/platform.c +1 -1
index c63c1d994..bf7b1aa0a 100644
@@ -486,7 +486,7 @@ platform_gen_path(const char *directory, const char *filename,
         struct buffer out = alloc_buf_gc(outsize, gc);
         char dirsep[2];
 
-        dirsep[0] = OS_SPECIFIC_DIRSEP;
+        dirsep[0] = PATH_SEPARATOR;
         dirsep[1] = '\0';
 
         if (directory)
src/openvpn/ssl_verify.c +1 -1
index 7608155cd..14aaf2bf7 100644
@@ -616,7 +616,7 @@ verify_check_crl_dir(const char *crl_dir, openvpn_x509_cert_t *cert,
         goto cleanup;
     }
 
-    if (!openvpn_snprintf(fn, sizeof(fn), "%s%c%s", crl_dir, OS_SPECIFIC_DIRSEP, serial))
+    if (!openvpn_snprintf(fn, sizeof(fn), "%s%c%s", crl_dir, PATH_SEPARATOR, serial))
     {
         msg(D_HANDSHAKE, "VERIFY CRL: filename overflow");
         goto cleanup;
src/openvpn/syshead.h +0 -0
index a964ffd35..28ccca087 100644

src/openvpn/syshead.h typedef unsigned short sa_family_t; · line 436

Quoted 6 lines
src/openvpn/syshead.h +2 -1
@@ -432,9 +432,11 @@ typedef unsigned short sa_family_t;
  * Directory separation char
  */
 #ifdef _WIN32
-#define OS_SPECIFIC_DIRSEP '\\'
+#define PATH_SEPARATOR '\\'
+#define PATH_SEPARATOR_STR "\\"

Do we still need the define in config-msvc.h now that we have it here?

config-msvc.h:85:#define PATH_SEPARATOR '\\'
config-msvc.h:86:#define PATH_SEPARATOR_STR "\\"

Regards,

Quoted 8 lines
src/openvpn/syshead.h +2 -1
 #else
-#define OS_SPECIFIC_DIRSEP '/'
+#define PATH_SEPARATOR '/'
+#define PATH_SEPARATOR_STR "/"
 #endif
 
 /*
Signature · 1 line
Antonio Quartulli
#5 lore raw

[Openvpn-devel] [PATCH applied] Re: Remove always enabled USE_64_BIT_COUNTERS define

In reply to Arne Schwabe

Your patch has been applied to the release/2.4 branch.

commit 1bdd09e7e019ac6d8fdc1b009bdec818b9183e76

Author: Arne Schwabe
Date:   Wed Apr 21 15:43:44 2021 +0200
     Remove always enabled USE_64_BIT_COUNTERS define

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Antonio Quartulli <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg22171.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#6 lore raw

Re: [Openvpn-devel] [PATCH applied] Re: Remove always enabled USE_64_BIT_COUNTERS define

Hi,

Quoted 1 line · Gert Doering

Your patch has been applied to the release/2.4 branch.

Uh, that was not what I intended to do. But that's what you get for "try to get things done early in the morning" before coffee works. *sigh*

I have force-pushed 2.4 without that commit (no tags set, so no harm done) and applied it to master, where it was intended to go

commit 3a16a8678ded8df8e41c495bccc4e24ef0ce82f4 (master)

Author: Arne Schwabe <[email protected]...>
Date:   Wed Apr 21 15:43:44 2021 +0200

Remove always enabled USE_64_BIT_COUNTERS define

sorry

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#7 lore raw

Re: [Openvpn-devel] [PATCH applied] Re: Remove always enabled USE_64_BIT_COUNTERS define

Hi,

Quoted 2 lines · Gert Doering

I have force-pushed 2.4 without that commit (no tags set, so no harm done) and applied it to master, where it was intended to go

Well. I tried that (though I should have known better) and neither sf nor gitlab actually let me, and I think that's actually good :-)

So, release/2.4 has a erroneous commit + a revert commit now.

It hasn't been actually broken at any time (because the commit is okay), it was just against our approach to "which commits go where".

$ git log release/2.4
commit 5e272a0196f3a9ac9423397079779ac8bbdf6159 (HEAD)
Author: Gert Doering <[email protected]...>
Date:   Thu Apr 22 10:26:12 2021 +0200

Revert "Remove always enabled USE_64_BIT_COUNTERS define"

commit 1bdd09e7e019ac6d8fdc1b009bdec818b9183e76

Author: Arne Schwabe <[email protected]...>
Date:   Wed Apr 21 15:43:44 2021 +0200

Remove always enabled USE_64_BIT_COUNTERS define

commit 092734634796e9637920e029fea716afc146cd82 (tag: v2.4.11, vweb1/release/2.4)

Author: Gert Doering <[email protected]...>
Date:   Tue Apr 20 15:31:32 2021 +0200

Preparing release v2.4.11 (ChangeLog, version.m4, Changes.rst)

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#10 lore raw

Re: [Openvpn-devel] [PATCH 4/7] Fix a number of mingw warnings

In reply to Antonio Quartulli
Quoted 10 lines
Quoted 3 lines

#ifndef _WIN32
+ const char *device = tt->actual_name;

This variable is not used in all cases embraced by "ifndef _WIN32". I.e. I think it is not used when any of the following is defined:
TARGET_OPENBSD
TARGET_NETBSD
TARGET_AIX

Quoted 3 lines

Therefore this change would fix *only* the warning on Windows. Do we want to go this way? or should we rather rearrange the ifdefs a bit so that we have a cleaner change/function?

No all other platforms. The variable is used just 2 lines below it definition to set gateway_needed which is used by all platforms apart from _WIN32. So only WIN32 had this warning.

Quoted 10 lines
Quoted 10 lines


     if (r6->iface != NULL)              /* vpn server special route */
     {
         device = r6->iface;
src/openvpn/route.c +0 -0
@@ -2713,7 +2713,7 @@ get_default_gateway_row(const MIB_IPFORWARDTABLE *routes)
             const DWORD index = row->dwForwardIfIndex;
             const DWORD metric = row->dwForwardMetric1;
 
Quoted 4 lines

src/openvpn/route.c get_default_gateway_row(const MIB_IPFORWARDTABLE *routes) · line 2716

Quoted 2 lines
src/openvpn/route.c +1 -1
-            dmsg(D_ROUTE_DEBUG, "GDGR: route[%d] %s/%s i=%d m=%d",
+            dmsg(D_ROUTE_DEBUG, "GDGR: route[%lu] %s/%s i=%d m=%d",

shouldn't be enough to convert to %u ? (/me is not a DOWRD expert though)

No. DWORD is a long unsigned int as mentioned in the commit message. It is 32 bit int since Windows always has long as 32 bit. It is a bit confusing when you are used to the long=64 bit :)

Quoted 5 lines
Quoted 5 lines

index 2c1b270dd..4ef34e4eb 100644

src/openvpn/tun.c +0 -0
@@ -5606,7 +5606,7 @@ windows_set_mtu(const int iface_index, const short family,
 
Quoted 7 lines

src/openvpn/tun.c windows_set_mtu(const int iface_index, const short family, · line 5609

Quoted 4 lines
src/openvpn/tun.c +1 -1
     if (err != NO_ERROR)
     {
-        msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%u if_index=%d]",
+        msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%lu if_index=%d]",

same question as above.

Same answer :)

Arne

#11 lore raw

Re: [Openvpn-devel] [PATCH 4/7] Fix a number of mingw warnings

Hi,

Quoted 10 lines · Arne Schwabe
Quoted 10 lines
Quoted 3 lines

#ifndef _WIN32
+ const char *device = tt->actual_name;

This variable is not used in all cases embraced by "ifndef _WIN32". I.e. I think it is not used when any of the following is defined:
TARGET_OPENBSD
TARGET_NETBSD
TARGET_AIX

Quoted 8 lines
Quoted 3 lines

Therefore this change would fix *only* the warning on Windows. Do we want to go this way? or should we rather rearrange the ifdefs a bit so that we have a cleaner change/function?

No all other platforms. The variable is used just 2 lines below it definition to set gateway_needed which is used by all platforms apart from _WIN32. So only WIN32 had this warning.

Well, it's assigned but not used on the platforms I mentioned. I guess the compiler isn't able to throw a warning at the moment though.

Anyway, I am fine with keeping this change as it is. This code may require some bigger restructuring at some point.
So fixing the usage of one variable only doesn't give us anything.

But at least this changes gets rid of a warning :)

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines



     if (r6->iface != NULL)              /* vpn server special route */
     {
         device = r6->iface;
src/openvpn/route.c +0 -0
@@ -2713,7 +2713,7 @@ get_default_gateway_row(const MIB_IPFORWARDTABLE *routes)
             const DWORD index = row->dwForwardIfIndex;
             const DWORD metric = row->dwForwardMetric1;
 
Quoted 21 lines
Quoted 4 lines

src/openvpn/route.c get_default_gateway_row(const MIB_IPFORWARDTABLE *routes) · line 2716

Quoted 2 lines
src/openvpn/route.c +1 -1
-            dmsg(D_ROUTE_DEBUG, "GDGR: route[%d] %s/%s i=%d m=%d",
+            dmsg(D_ROUTE_DEBUG, "GDGR: route[%lu] %s/%s i=%d m=%d",

shouldn't be enough to convert to %u ? (/me is not a DOWRD expert though)

No. DWORD is a long unsigned int as mentioned in the commit message. It is 32 bit int since Windows always has long as 32 bit. It is a bit confusing when you are used to the long=64 bit :)

Quoted 12 lines

src/openvpn/tun.c windows_set_mtu(const int iface_index, const short family, · line 5609

Quoted 9 lines

index 2c1b270dd..4ef34e4eb 100644

src/openvpn/tun.c +1 -1
@@ -5606,7 +5606,7 @@ windows_set_mtu(const int iface_index, const short family,
 
     if (err != NO_ERROR)
     {
-        msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%u if_index=%d]",
+        msg(M_WARN, "TUN: Setting %s mtu failed: %s [status=%lu if_index=%d]",

same question as above.

Thanks for the explanation on DWORD.

Compiled on my rig and no problem showed up.

Signature · 1 line
Antonio Quartulli
#12 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix a number of mingw warnings

In reply to Arne Schwabe

Your patch has been applied to the master branch.

commit 7890e51aab91b304045a0163462f334b8e5ae8e8

Author: Arne Schwabe
Date:   Wed Apr 21 15:43:45 2021 +0200
     Fix a number of mingw warnings

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Antonio Quartulli <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg22176.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering