]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Linux: Assume we have a kernel that was release in the last 15 years
authorFrank Lichtenheld <frank@lichtenheld.com>
Thu, 27 Nov 2025 10:51:20 +0000 (11:51 +0100)
committerGert Doering <gert@greenie.muc.de>
Thu, 27 Nov 2025 11:10:54 +0000 (12:10 +0100)
Just assume that we have all the linux headers that
were part of linux since 2.6 (or 2.4 in some cases).

Simplifies configuration.

Change-Id: Ie460eec488a8781e3b1ee4f8b2ae2090729ed175
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1408
Message-Id: <20251127105125.30457-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34738.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
CMakeLists.txt
config.h.cmake.in
configure.ac
src/openvpn/mtu.c
src/openvpn/mtu.h
src/openvpn/options.c
src/openvpn/socket.c
src/openvpn/syshead.h
src/openvpn/tun.c
src/openvpn/tun.h

index e812145a050430ba7dc2aee5281077596a5cca64..c4d50e48299bfb745cec71467198c22ce85ccc06 100644 (file)
@@ -145,7 +145,6 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Android" OR ${FAKE_ANDROID})
     set(TARGET_ANDROID YES)
     set(ENABLE_ASYNC_PUSH YES)
     set(ENABLE_SITNL YES)
-    set(HAVE_LINUX_TYPES_H 1)
     # Wacky workaround as OpenSSL package detection is otherwise broken (https://stackoverflow.com/questions/45958214/android-cmake-could-not-find-openssl)
     list(APPEND CMAKE_FIND_ROOT_PATH ${OPENSSL_ROOT_DIR})
 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
@@ -153,9 +152,6 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
     set(ENABLE_ASYNC_PUSH YES)
     set(ENABLE_LINUXDCO YES)
     set(ENABLE_SITNL YES)
-    set(HAVE_DECL_SO_MARK YES)
-    set(ENABLE_FEATURE_TUN_PERSIST 1)
-    set(HAVE_LINUX_TYPES_H 1)
     set(ENABLE_DCO YES)
 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
     set(TARGET_FREEBSD YES)
@@ -258,8 +254,6 @@ check_include_files(dlfcn.h HAVE_DLFCN_H)
 check_include_files(dmalloc.h HAVE_DMALLOC_H)
 check_include_files(fcntl.h HAVE_FCNTL_H)
 check_include_files(err.h HAVE_ERR_H)
-check_include_files(linux/if_tun.h HAVE_LINUX_IF_TUN_H)
-check_include_files(linux/sockios.h HAVE_LINUX_SOCKIOS_H)
 check_include_files(netdb.h HAVE_NETDB_H)
 check_include_files("${NETEXTRA};netinet/in6.h" HAVE_NETINET_IN_H)
 check_include_files(net/if.h HAVE_NET_IF_H)
index 1c443ab7293fdbd1c57725289eff7f163ae56dbb..bf1899cdfac88c7cb947f30a792be8b2feaaf4db 100644 (file)
@@ -20,9 +20,6 @@
 /* Enable debugging support (needed for verb>=4) */
 #define ENABLE_DEBUG 1
 
-/* We have persist tun capability */
-#cmakedefine ENABLE_FEATURE_TUN_PERSIST
-
 /* Enable internal fragmentation support */
 #define ENABLE_FRAGMENT 1
 
 /* Define to 1 if you have the `daemon' function. */
 #cmakedefine HAVE_DAEMON
 
-/* Define to 1 if you have the declaration of `SO_MARK', and to 0 if you
-don't. */
-#cmakedefine01 HAVE_DECL_SO_MARK
-
 /* Define to 1 if you have the <direct.h> header file. */
 #cmakedefine HAVE_DIRECT_H
 
@@ -166,15 +159,6 @@ don't. */
 /* Define to 1 if you have the <limits.h> header file. */
 #define HAVE_LIMITS_H 1
 
-/* Define to 1 if you have the <linux/if_tun.h> header file. */
-#cmakedefine HAVE_LINUX_IF_TUN_H
-
-/* Define to 1 if you have the <linux/sockios.h> header file. */
-#cmakedefine HAVE_LINUX_SOCKIOS_H
-
-/* Define to 1 if you have the <linux/types.h> header file. */
-#cmakedefine HAVE_LINUX_TYPES_H
-
 /* Define to 1 if you have the <lzo1x.h> header file. */
 #define HAVE_LZO1X_H 1
 
index 44c7b653c5643ec142fda8267ac6583006f4787b..030f8ded970b769d166f142b65a48b12f3065dfc 100644 (file)
@@ -494,8 +494,8 @@ AC_CHECK_HEADERS([ \
        sys/mman.h sys/file.h sys/wait.h \
        unistd.h libgen.h stropts.h \
        syslog.h pwd.h grp.h termios.h \
-       sys/sockio.h sys/uio.h linux/sockios.h \
-       linux/types.h linux/errqueue.h poll.h sys/epoll.h err.h \
+       sys/sockio.h sys/uio.h \
+       poll.h sys/epoll.h err.h \
 ])
 
 SOCKET_INCLUDES="
@@ -587,12 +587,6 @@ AC_CHECK_TYPE(
        [AC_MSG_ERROR([struct sockaddr_in6 not found, needed for ipv6 transport support.])],
        [[${SOCKET_INCLUDES}]]
 )
-AC_CHECK_DECLS(
-       [SO_MARK],
-       ,
-       ,
-       [[${SOCKET_INCLUDES}]]
-)
 
 saved_LDFLAGS="$LDFLAGS"
 LDFLAGS="$LDFLAGS -Wl,--wrap=exit"
@@ -717,16 +711,6 @@ AC_CHECK_HEADERS(
        ],
        [have_tap_header="yes"]
 )
-AC_CHECK_DECLS(
-       [TUNSETPERSIST],
-       [AC_DEFINE([ENABLE_FEATURE_TUN_PERSIST], [1], [We have persist tun capability])],
-       ,
-       [[
-               #ifdef HAVE_LINUX_IF_TUN_H
-               #include <linux/if_tun.h>
-               #endif
-       ]]
-)
 CFLAGS="${old_CFLAGS}"
 test "${have_tap_header}" = "yes" || AC_MSG_ERROR([no tap header could be found])
 
index 9e152df8e3dc2f5750a2d38ba38851ae6828c509..e080ea9eb091552bd77cd514aea8aea68edc2086 100644 (file)
@@ -274,6 +274,8 @@ translate_mtu_discover_type_name(const char *name)
 
 #if EXTENDED_SOCKET_ERROR_CAPABILITY
 
+#include <linux/errqueue.h>
+
 struct probehdr
 {
     uint32_t ttl;
index 3bbff6f6514b8fd6a2620f5c1dfcaa090e091a42..b6901491e141c60791fe1a8ebcb9fd3a0db083c0 100644 (file)
@@ -262,8 +262,7 @@ void alloc_buf_sock_tun(struct buffer *buf, const struct frame *frame);
 
 /*
  * EXTENDED_SOCKET_ERROR_CAPABILITY functions -- print extra error info
- * on socket errors, such as PMTU size.  As of 2003.05.11, only works
- * on Linux 2.4+.
+ * on socket errors, such as PMTU size.
  */
 
 #if EXTENDED_SOCKET_ERROR_CAPABILITY
index 62f84ddfabc57dda430bdb0556538c9d2c5f5816..5e731968533d16bb01c27b6211e53fb212e3ccbd 100644 (file)
@@ -315,7 +315,7 @@ static const char usage_message[] =
     "                  or --fragment max value, whichever is lower.\n"
     "--sndbuf size   : Set the TCP/UDP send buffer size.\n"
     "--rcvbuf size   : Set the TCP/UDP receive buffer size.\n"
-#if defined(TARGET_LINUX) && HAVE_DECL_SO_MARK
+#if defined(TARGET_LINUX)
     "--mark value    : Mark encrypted packets being sent with value. The mark value\n"
     "                  can be matched in policy routing and packetfilter rules.\n"
     "--bind-dev dev  : Bind to the given device when making connection to a peer or\n"
@@ -768,7 +768,7 @@ static const char usage_message[] =
     "                         (for use with --tls-auth or --tls-crypt)."
 #ifdef ENABLE_FEATURE_TUN_PERSIST
     "\n"
-    "Tun/tap config mode (available with linux 2.4+):\n"
+    "Tun/tap config mode:\n"
     "--mktun         : Create a persistent tunnel.\n"
     "--rmtun         : Remove a persistent tunnel.\n"
     "--dev tunX|tapX : tun/tap device\n"
@@ -1792,7 +1792,7 @@ show_settings(const struct options *o)
     SHOW_BOOL(occ);
     SHOW_INT(rcvbuf);
     SHOW_INT(sndbuf);
-#if defined(TARGET_LINUX) && HAVE_DECL_SO_MARK
+#if defined(TARGET_LINUX)
     SHOW_INT(mark);
 #endif
     SHOW_INT(sockflags);
@@ -6518,7 +6518,7 @@ add_option(struct options *options, char *p[], bool is_inline, const char *file,
     }
     else if (streq(p[0], "mark") && p[1] && !p[2])
     {
-#if defined(TARGET_LINUX) && HAVE_DECL_SO_MARK
+#if defined(TARGET_LINUX)
         VERIFY_PERMISSION(OPT_P_GENERAL);
         options->mark = atoi_warn(p[1], msglevel);
 #endif
index 747c7a7ad3b372c3acf1ca04ec5b6b8b9ed38c60..46bedf4fa88d5cae1d655298f0b8e13e278883f9 100644 (file)
@@ -524,7 +524,7 @@ socket_set_tcp_nodelay(socket_descriptor_t sd, int state)
 static inline void
 socket_set_mark(socket_descriptor_t sd, int mark)
 {
-#if defined(TARGET_LINUX) && HAVE_DECL_SO_MARK
+#if defined(TARGET_LINUX)
     if (mark && setsockopt(sd, SOL_SOCKET, SO_MARK, (void *)&mark, sizeof(mark)) != 0)
     {
         msg(M_WARN, "NOTE: setsockopt SO_MARK=%d failed", mark);
index 90045a9368b941d0ff62bdc9cb1cdcc47ccf11ae..c6f2608625734a539b278842a6ee0aa2d4bcc191 100644 (file)
 
 #if defined(TARGET_LINUX) || defined(TARGET_ANDROID)
 
-#ifdef HAVE_LINUX_IF_TUN_H
-#include <linux/if_tun.h>
-#endif
+#define EXTENDED_SOCKET_ERROR_CAPABILITY 1
 
-#ifdef HAVE_NETINET_IP_H
-#include <netinet/ip.h>
+#ifdef TARGET_LINUX
+#define ENABLE_FEATURE_TUN_PERSIST
 #endif
 
-#ifdef HAVE_LINUX_SOCKIOS_H
+#include <linux/if_tun.h>
 #include <linux/sockios.h>
-#endif
-
-#ifdef HAVE_LINUX_TYPES_H
-#include <linux/types.h>
-#endif
 
-#ifdef HAVE_LINUX_ERRQUEUE_H
-#include <linux/errqueue.h>
+#ifdef HAVE_NETINET_IP_H
+#include <netinet/ip.h>
 #endif
 
 #ifdef HAVE_NETINET_TCP_H
@@ -360,15 +353,6 @@ typedef int MIB_TCP_STATE;
 #define PASSTOS_CAPABILITY 0
 #endif
 
-/*
- * Do we have the capability to report extended socket errors?
- */
-#if defined(HAVE_LINUX_TYPES_H) && defined(HAVE_LINUX_ERRQUEUE_H)
-#define EXTENDED_SOCKET_ERROR_CAPABILITY 1
-#else
-#define EXTENDED_SOCKET_ERROR_CAPABILITY 0
-#endif
-
 /*
  * Does this platform support linux-style IP_PKTINFO
  * or bsd-style IP_RECVDSTADDR ?
@@ -396,14 +380,6 @@ typedef int MIB_TCP_STATE;
 typedef unsigned short sa_family_t;
 #endif
 
-/*
- * Disable ESEC
- */
-#if 0
-#undef EXTENDED_SOCKET_ERROR_CAPABILITY
-#define EXTENDED_SOCKET_ERROR_CAPABILITY 0
-#endif
-
 /*
  * Do we have a syslog capability?
  */
index 06b7ae5c696b3fcd8fb76ee1b7a2a888a7700dc5..7c61dcf38369f2728b87dc1996291b6491e87a3f 100644 (file)
@@ -2055,10 +2055,6 @@ read_tun(struct tuntap *tt, uint8_t *buf, int len)
 
 #elif defined(TARGET_LINUX)
 
-#ifndef HAVE_LINUX_SOCKIOS_H
-#error header file linux/sockios.h required
-#endif
-
 #if !PEDANTIC
 
 void
@@ -2186,11 +2182,6 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
 
 #ifdef ENABLE_FEATURE_TUN_PERSIST
 
-/* TUNSETGROUP appeared in 2.6.23 */
-#ifndef TUNSETGROUP
-#define TUNSETGROUP _IOW('T', 206, int)
-#endif
-
 void
 tuncfg(const char *dev, const char *dev_type, const char *dev_node, int persist_mode,
        const char *username, const char *groupname, const struct tuntap_options *options,
index e13f99f144cbc84971a855d5f282bcb025dc80b0..876f1475beaa5f9ba708531b8d4c9efccc2add9e 100644 (file)
@@ -278,9 +278,11 @@ int write_tun(struct tuntap *tt, uint8_t *buf, int len);
 
 int read_tun(struct tuntap *tt, uint8_t *buf, int len);
 
+#ifdef ENABLE_FEATURE_TUN_PERSIST
 void tuncfg(const char *dev, const char *dev_type, const char *dev_node, int persist_mode,
             const char *username, const char *groupname, const struct tuntap_options *options,
             openvpn_net_ctx_t *ctx);
+#endif
 
 const char *guess_tuntap_dev(const char *dev, const char *dev_type, const char *dev_node,
                              struct gc_arena *gc);