From: David Sommerseth Date: Mon, 21 Nov 2011 15:17:44 +0000 (+0100) Subject: Fix compilation errors on Linux platforms without SO_MARK X-Git-Tag: v2.3-alpha1~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=032f0045246846f566f7433e95376916beb980b0;p=thirdparty%2Fopenvpn.git Fix compilation errors on Linux platforms without SO_MARK 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 --- diff --git a/configure.ac b/configure.ac index f904db492..19173e96d 100644 --- a/configure.ac +++ b/configure.ac @@ -443,6 +443,9 @@ if test "${WIN32}" != "yes"; then # include #endif ]) + + dnl Check if SO_MARK is available + AC_TRY_COMPILE([#include ], [if( SO_MARK > 0) return 1;], [AC_DEFINE(HAVE_SO_MARK,[],[Is SO_MARK available?])]) fi AC_CACHE_SAVE diff --git a/options.c b/options.c index 19792e97f..562c6f64b 100644 --- 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 diff --git a/socket.c b/socket.c index c8a86ea6f..1a772afc9 100644 --- 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