Fix compilation errors on Linux platforms without SO_MARK
PATCH 1/1 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 <[email protected]...>
--- configure.ac | 3 +++ options.c | 6 +++--- socket.c | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-)
configure.ac +3 -0
@@ -437,6 +437,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
options.c +3 -3
@@ -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
@@ -1501,7 +1501,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);
@@ -4572,7 +4572,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
socket.c +2 -2
@@ -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
Signature · 1 line
1.7.4.4