]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix compilation errors on Linux platforms without SO_MARK
authorDavid Sommerseth <davids@redhat.com>
Mon, 21 Nov 2011 15:17:44 +0000 (16:17 +0100)
committerDavid Sommerseth <davids@redhat.com>
Wed, 11 Jan 2012 15:02:47 +0000 (16:02 +0100)
When trying to compile OpenVPN on RHEL5/CentOS5, it would fail
due to missing declaration of SO_MARK.  SO_MARK is a feature which
first arrived in 2.6.26, and was never backported to RHEL5's 2.6.18
kernel base.

This patch adds a check at configure time, to see if SO_MARK is
available or not.

Signed-off-by: David Sommerseth <davids@redhat.com>
configure.ac
options.c
socket.c

index f904db4925d7129f1f459a9f7875b0b924a6e082..19173e96d7904bea31038bb2e6f93bcb3b54bdb0 100644 (file)
@@ -443,6 +443,9 @@ if test "${WIN32}" != "yes"; then
         # include <linux/types.h>
         #endif
        ])
+
+   dnl Check if SO_MARK is available
+   AC_TRY_COMPILE([#include <sys/socket.h>], [if( SO_MARK > 0) return 1;], [AC_DEFINE(HAVE_SO_MARK,[],[Is SO_MARK available?])])
 fi
 
 AC_CACHE_SAVE
index 19792e97f8266195b51a77e5294235b338eb502d..562c6f64b4b3ab55afb17a4466a3653c8f9ff90a 100644 (file)
--- a/options.c
+++ b/options.c
@@ -292,7 +292,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"
-#ifdef TARGET_LINUX
+#if defined(TARGET_LINUX) && defined(HAVE_SO_MARK)
   "--mark value    : Mark encrypted packets being sent with value. The mark value\n"
   "                  can be matched in policy routing and packetfilter rules.\n"
 #endif
@@ -1504,7 +1504,7 @@ show_settings (const struct options *o)
 #endif
   SHOW_INT (rcvbuf);
   SHOW_INT (sndbuf);
-#ifdef TARGET_LINUX
+#if defined(TARGET_LINUX) && defined(HAVE_SO_MARK)
   SHOW_INT (mark);
 #endif
   SHOW_INT (sockflags);
@@ -4745,7 +4745,7 @@ add_option (struct options *options,
     }
   else if (streq (p[0], "mark") && p[1])
     {
-#ifdef TARGET_LINUX
+#if defined(TARGET_LINUX) && defined(HAVE_SO_MARK)
       VERIFY_PERMISSION (OPT_P_GENERAL);
       options->mark = atoi(p[1]);
 #endif
index c8a86ea6fb1073e0e98738189c4d05ebac7b0f8c..1a772afc97787471e947ebac691d2deede691c34 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -779,10 +779,10 @@ socket_set_tcp_nodelay (int sd, int state)
 #endif
 }
 
-static void
+static inline void
 socket_set_mark (int sd, int mark)
 {
-#ifdef TARGET_LINUX
+#if defined(TARGET_LINUX) && defined(HAVE_SO_MARK)
   if (mark && setsockopt (sd, SOL_SOCKET, SO_MARK, &mark, sizeof (mark)) != 0)
     msg (M_WARN, "NOTE: setsockopt SO_MARK=%d failed", mark);
 #endif