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>
# 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
" 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
#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);
}
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
#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