Fix accept_filter for GNU/Linux

Federico Schwindt fgsch at lodoss.net
Fri Sep 4 01:15:12 CEST 2015


Hi,

Actually the problem is somewhere else.

The attached diff should fix it.

Cheers.

On Wed, Sep 2, 2015 at 10:23 PM, Rafael Zalamena <rafaelfz at taghos.com.br>
wrote:

> Hello,
>
> Varnish cache daemon is not doing 'accept_filter' for the GNU/Linux
> version because of HAVE_ACCEPT_FILTER not being defined. Something along
> the way broke it, so in order to fix it I have added TCP_DEFER_ACCEPT
> detection code to configure.ac to define HAVE_ACCEPT_FILTER and
> HAVE_TCP_DEFER_ACCEPT so we can have a fallback of accept_filter on Linux.
>
> Since I didn't see any different use of ACCEPT_FILTER and historicaly no
> one used it diferently I kept TCP_DEFER_ACCEPT being a ACCEPT_FILTER
> replacement to create a small diff.
>
> diff --git configure.ac configure.ac
> index 6c4d5f2..4a50fd8 100644
> --- configure.ac
> +++ configure.ac
> @@ -366,6 +366,19 @@ AC_CHECK_DECL([SO_ACCEPTFILTER],
>      ]
>  )
>
> +AC_CHECK_DECL([TCP_DEFER_ACCEPT],
> +    [
> +    AC_DEFINE(HAVE_ACCEPT_FILTERS,1,[Define to 1 if you have accept
> filters]),
> +    AC_DEFINE(HAVE_TCP_DEFER_ACCEPT,1,[Define to 1 if you have TCP defer
> accept])
> +    ],
> +    ,
> +    [
> +#include <sys/socket.h>
> +#include <netinet/in.h>
> +#include <netinet/tcp.h>
> +    ]
> +)
> +
>  # Older Solaris versions define SO_{RCV,SND}TIMEO, but do not
>  # implement them.
>  #
> diff --git lib/libvarnish/vtcp.c lib/libvarnish/vtcp.c
> index 3992555..732c2ea 100644
> --- lib/libvarnish/vtcp.c
> +++ lib/libvarnish/vtcp.c
> @@ -146,6 +146,7 @@ VTCP_hisname(int sock, char *abuf, unsigned alen, char
> *pbuf, unsigned plen)
>  /*--------------------------------------------------------------------*/
>
>  #ifdef HAVE_ACCEPT_FILTERS
> +#ifndef HAVE_TCP_DEFER_ACCEPT
>
>  int
>  VTCP_filter_http(int sock)
> @@ -160,7 +161,7 @@ VTCP_filter_http(int sock)
>         return (retval);
>  }
>
> -#elif defined(__linux)
> +#else /* HAVE_TCP_DEFER_ACCEPT */
>
>  int
>  VTCP_filter_http(int sock)
> @@ -173,6 +174,7 @@ VTCP_filter_http(int sock)
>         return (retval);
>  }
>
> +#endif
>  #else
>
>  int
>
> _______________________________________________
> varnish-dev mailing list
> varnish-dev at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20150904/2939ae2b/attachment.html>
-------------- next part --------------
diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index 9736ca9..a17351d 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -489,7 +489,6 @@ vca_acct(void *arg)
 		assert (ls->sock > 0);		// We know where stdin is
 		AZ(listen(ls->sock, cache_param->listen_depth));
 		vca_tcp_opt_set(ls->sock, 1);
-#ifdef HAVE_ACCEPT_FILTERS
 		if (cache_param->accept_filter) {
 			int i;
 			i = VTCP_filter_http(ls->sock);
@@ -498,7 +497,6 @@ vca_acct(void *arg)
 				    "Kernel filtering: sock=%d, ret=%d %s",
 				    ls->sock, i, strerror(errno));
 		}
-#endif /* HAVE_ACCEPT_FILTERS */
 	}
 
 	need_test = 1;
diff --git a/include/tbl/params.h b/include/tbl/params.h
index d3a2982..339fbaa 100644
--- a/include/tbl/params.h
+++ b/include/tbl/params.h
@@ -30,7 +30,6 @@
 
 /*lint -save -e525 -e539 */
 
-#ifdef HAVE_ACCEPT_FILTERS
 PARAM(
 	/* name */	accept_filter,
 	/* typ */	bool,
@@ -44,7 +43,6 @@ PARAM(
 	/* l-text */	NULL,
 	/* func */	NULL
 )
-#endif /* HAVE_ACCEPT_FILTERS */
 
 PARAM(
 	/* name */	acceptor_sleep_decay,


More information about the varnish-dev mailing list