From: Amos Jeffries Date: Wed, 6 Oct 2010 13:03:11 +0000 (-0600) Subject: Portability fixes for netfilter MARK support. X-Git-Tag: take1~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4f6c2e068d43ab2c677b2331bab2f0b5e07e5bd;p=thirdparty%2Fsquid.git Portability fixes for netfilter MARK support. --- diff --git a/configure.in b/configure.in index b30f1bf856..510c8f8f61 100644 --- a/configure.in +++ b/configure.in @@ -1316,29 +1316,35 @@ AC_ARG_WITH(netfilter-conntrack, [Do not use Netfilter conntrack libraries for packet marking. A path to alternative library location may be specified by using --with-netfilter-conntrack=PATH. Default: auto-detect.]), [ - case "$withval" in - yes|no) with_netfilter_conntrack=$withval ;; - *) squid_opt_netfilterconntrackpath=$withval - with_netfilter_conntrack=yes ;; - esac], [ +case "$with_netfilter_conntrack" in + yes|no) + : # Nothing special to do here + ;; + *) + if test ! -d "$withval" ; then + AC_MSG_ERROR([--without-netfilter-conntrack path does not point to a directory]) + fi + squid_opt_netfilterconntrackpath=$withval + LDFLAGS="-L$squid_opt_netfilterconntrackpath/lib $LDFLAGS" + CPPFLAGS="-I$squid_opt_netfilterconntrackpath/include $CPPFLAGS" with_netfilter_conntrack=yes + esac ]) -if test x"$with_netfilter_conntrack" = "xyes"; then - if test "x$squid_opt_netfilterconntrackpath" != "x"; then - if ! test -d "$squid_opt_netfilterconntrackpath"; then - AC_MSG_ERROR([--with-netfilter-conntrack path '$squid_opt_netfilterconntrackpath' does not exist]) +AC_MSG_NOTICE([Linux Netfilter Conntrack support requested: ${with_netfilter_conntrack:=auto}]) +if test "x$with_netfilter_conntrack" != "xno"; then + AC_SEARCH_LIBS([nfct_query], [netfilter_conntrack],,[ + if test x"$with_netfilter_conntrack" = "xyes"; then + AC_MSG_ERROR([--with-netfilter-conntrack specified but libnetfilter-conntrack library not found]) fi - LDFLAGS="-L$squid_opt_netfilterconntrackpath/lib $LDFLAGS" - CPPFLAGS="-I$squid_opt_netfilterconntrackpath/include $CPPFLAGS" - fi - AC_SEARCH_LIBS([nfct_query], [netfilter_conntrack],, - with_netfilter_conntrack=no - if test x"$withval" = "xyes"; then - AC_MSG_ERROR([--with-netfilter-conntrack specified but libnetfilter-conntrack libraries not found]) - fi ) + with_netfilter_conntrack=no]) AC_CHECK_HEADERS([libnetfilter_conntrack/libnetfilter_conntrack.h \ - libnetfilter_conntrack/libnetfilter_conntrack_tcp.h],,with_netfilter_conntrack=no) + libnetfilter_conntrack/libnetfilter_conntrack_tcp.h],,[ + if test x"$with_netfilter_conntrack" = "xyes"; then + AC_MSG_ERROR([--with-netfilter-conntrack specified but libnetfilter-conntrack headers not found]) + fi + with_netfilter_conntrack=no]) fi +AC_MSG_NOTICE([Linux Netfilter Conntrack support enabled: ${with_netfilter_conntrack} ${squid_opt_netfilterconntrackpath}]) dnl Enable Large file support diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 8aa5138d4b..0c8530f5f5 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1301,6 +1301,8 @@ free_acl_tos(acl_tos ** head) } } +#if defined(SO_MARK) + CBDATA_TYPE(acl_nfmark); static void @@ -1369,6 +1371,7 @@ free_acl_nfmark(acl_nfmark ** head) cbdataFree(l); } } +#endif /* SO_MARK */ CBDATA_TYPE(acl_size_t); diff --git a/src/cf_gen_defines b/src/cf_gen_defines index 50ce262939..37615ed510 100644 --- a/src/cf_gen_defines +++ b/src/cf_gen_defines @@ -32,6 +32,7 @@ BEGIN { define["USE_WCCPv2"]="--enable-wccpv2" define["USE_QOS_TOS"]="--enable-zph-qos" define["_SQUID_MSWIN_"]="MS Windows" + define["SO_MARK"]="Packet MARK (Linux)" } /^IFDEF:/ { if (define[$2] != "") diff --git a/src/fde.h b/src/fde.h index 2fc1d4076f..089ad24c17 100644 --- a/src/fde.h +++ b/src/fde.h @@ -130,7 +130,8 @@ private: type = 0; remote_port = 0; local_addr.SetEmpty(); - tos = '\0'; + tosToServer = '\0'; + nfmarkToServer = 0; sock_family = 0; memset(ipaddr, '\0', MAX_IPSTRLEN); memset(desc,'\0',FD_DESC_SZ); @@ -160,9 +161,8 @@ private: #ifdef _SQUID_MSWIN_ win32.handle = NULL; #endif -#if USE_ZPH_QOS - upstreamTOS = 0; -#endif + tosFromServer = '\0'; + nfmarkFromServer = 0; } }; diff --git a/src/ip/Makefile.am b/src/ip/Makefile.am index ce15112d04..989f29d291 100644 --- a/src/ip/Makefile.am +++ b/src/ip/Makefile.am @@ -9,8 +9,8 @@ libip_la_SOURCES = \ Address.cc \ Intercept.h \ Intercept.cc \ - Qos.h \ - Qos.cc \ + QosConfig.h \ + QosConfig.cc \ Qos.cci \ tools.cc \ tools.h diff --git a/src/ip/QosConfig.cc b/src/ip/QosConfig.cc index 948e23aa47..36ce6cadac 100644 --- a/src/ip/QosConfig.cc +++ b/src/ip/QosConfig.cc @@ -1,18 +1,20 @@ +#include "squid.h" + #include "acl/Gadgets.h" #include "ConfigParser.h" #include "fde.h" #include "hier_code.h" #include "ip/tools.h" -#include "Qos.h" +#include "ip/QosConfig.h" #include "Parsing.h" -#include "squid.h" /* Qos namespace */ void Ip::Qos::getTosFromServer(const int server_fd, fde *clientFde) { -#if USE_QOS_TOS +#if USE_QOS_TOS && _SQUID_LINUX_ + /* Bug 2537: This part of ZPH only applies to patched Linux kernels. */ tos_t tos = 1; int tos_len = sizeof(tos); clientFde->tosFromServer = 0; diff --git a/src/ip/QosConfig.h b/src/ip/QosConfig.h index 4011ffef3c..9ad9c48fc8 100644 --- a/src/ip/QosConfig.h +++ b/src/ip/QosConfig.h @@ -32,6 +32,7 @@ namespace Qos /** * Function to retrieve the TOS value of the inbound packet. * Called by FwdState::dispatch if QOS options are enabled. + * Bug 2537: This part of ZPH only applies to patched Linux kernels * @param server_fd Server side descriptor of connection to get TOS for * @param clientFde Pointer to client side fde instance to set tosFromServer in */