Fix accept_filter for GNU/Linux

Federico Schwindt fgsch at lodoss.net
Fri Sep 4 14:35:55 CEST 2015


Did you see my second diff? :)
On 4 Sep 2015 1:31 pm, "Rafael Zalamena" <rafaelfz at taghos.com.br> wrote:

> Em Fri, 4 Sep 2015 00:48:50 +0100
> Federico Schwindt <fgsch at lodoss.net> escreveu:
>
> > And a version aligned with phk's comment (off by default).
> >
> > On Fri, Sep 4, 2015 at 12:15 AM, Federico Schwindt <fgsch at lodoss.net>
> wrote:
> >
> > > Hi,
> > >
> > > Actually the problem is somewhere else.
> > >
> > > The attached diff should fix it.
> > >
> > > Cheers.
> > >
>
> With your diff varnish will spam log messages on systems without
> ACCEPT_FILTERS or TCP_DEFER_ACCEPT by default.
>
> I've modified my diff to kill some ifdefs and make accept_filter always
> avaliable, but this time disabled by default on system without
> ACCEPT_FILTERS or with TCP_DEFER_ACCEPT.
>
> With this:
> (1) anyone who wants to enable accept_filter on GNU/Linux should just
>     call varnish with 'varnishd ... -p accept_filter=on';
> (2) anyone who enables accept_filter on a system without it will have a
>     log spam about not having support for this feature;
> (3) we get to keep the old behavior for systems with ACCEPT_FILTERS;
>
>
> diff --git bin/varnishd/cache/cache_acceptor.c
> bin/varnishd/cache/cache_acceptor.c
> index 9736ca9..a17351d 100644
> --- bin/varnishd/cache/cache_acceptor.c
> +++ 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 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 include/tbl/params.h include/tbl/params.h
> index d3a2982..6cbe3ba 100644
> --- include/tbl/params.h
> +++ include/tbl/params.h
> @@ -30,13 +30,16 @@
>
>  /*lint -save -e525 -e539 */
>
> -#ifdef HAVE_ACCEPT_FILTERS
>  PARAM(
>         /* name */      accept_filter,
>         /* typ */       bool,
>         /* min */       NULL,
>         /* max */       NULL,
> +#if defined(HAVE_ACCEPT_FILTERS) && !defined(HAVE_TCP_DEFER_ACCEPT)
>         /* default */   "on",
> +#else
> +       /* default */   "off",
> +#endif /* HAVE_ACCEPT_FILTERS */
>         /* units */     "bool",
>         /* flags */     MUST_RESTART,
>         /* s-text */
> @@ -44,7 +47,6 @@ PARAM(
>         /* l-text */    NULL,
>         /* func */      NULL
>  )
> -#endif /* HAVE_ACCEPT_FILTERS */
>
>  PARAM(
>         /* name */      acceptor_sleep_decay,
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20150904/83224aeb/attachment.html>


More information about the varnish-dev mailing list