NetBSD + nginx-0.8.53 + accept filters - not working

Hello,

Giving nginx a spin on NetBSD, I noticed:
accept filters “accept_filter=httpready” are not supported on this
platform, ignored in /usr/pkg/etc/nginx/nginx.conf:40

But NetBSD does support them:
accf_http (9) - buffer incoming connections until a certain complete
HTTP requests arrive

grep -i accf /usr/src/sys/arch/amd64/conf/NETBSD_WEBSERVER

pseudo-device accf_data # “dataready” accept filter
pseudo-device accf_http # “httpready” accept filter

Since I’m using packages (pkgin), I could not test nginx 1.x (which is
in pkgsrc); Maybe this has been fixed in the mean time ?

Regards,

Hugo

Posted at Nginx Forum:

Hello!

On Tue, Aug 09, 2011 at 05:48:06AM -0400, hugo wrote:

Giving nginx a spin on NetBSD, I noticed:
accept filters “accept_filter=httpready” are not supported on this
platform, ignored in /usr/pkg/etc/nginx/nginx.conf:40

But NetBSD does support them:
accf_http (9) - buffer incoming connections until a certain complete
HTTP requests arrive

Ah, ok, it looks like accept filters are available in NetBSD 5.0+.

[…]

Since I’m using packages (pkgin), I could not test nginx 1.x (which is
in pkgsrc); Maybe this has been fixed in the mean time ?

You may try

./configure --with-cc-opt="-D NGX_HAVE_DEFERRED_ACCEPT"

to see if it works.

If it is, we probably want to fix configure to detect it
automatically.

Maxim D.

Hello!

On Tue, Aug 09, 2011 at 03:07:14PM +0400, Maxim D. wrote:

[…]

Since I’m using packages (pkgin), I could not test nginx 1.x (which is
in pkgsrc); Maybe this has been fixed in the mean time ?

You may try

./configure --with-cc-opt="-D NGX_HAVE_DEFERRED_ACCEPT"

Oops, should be

./configure --with-cc-opt="-D NGX_HAVE_DEFERRED_ACCEPT=1"

(note “=1”)

to see if it works.

If it is, we probably want to fix configure to detect it
automatically.

Maxim D.

Had a brief chat with the maintainer; He’s of the opinion that this
should be dealt with upstream, using the same logic in use for FreeBSD:
“if SO_ACCEPTFILTER exists, use it by default.”

Regards,

Hugo

Posted at Nginx Forum:

Hello!

On Tue, Aug 09, 2011 at 09:44:53AM -0400, hugo wrote:

Had a brief chat with the maintainer; He’s of the opinion that this
should be dealt with upstream, using the same logic in use for FreeBSD:
“if SO_ACCEPTFILTER exists, use it by default.”

As I already stated earlier:

to see if it works.

If it is, we probably want to fix configure to detect it
automatically.

Do you see it works? I.e. not only doesn’t produce errors while
parsing configuration, but actually works ok and uses accept
filters?

Maxim D.

nginx-1.0.4 Lightweight HTTP server and mail proxy server

I fixed the Makefile in /usr/pkgsrc/www/nginx and added CONFIGURE_ARGS+=
–with-cc-opt=“-D NGX_HAVE_DEFERRED_ACCEPT=1”

Restarting nginx produced no errors with the accept_filter=httpready
line after recompilation.

I’ve notified the nginx pkgsrc maintainer too.

Thanks for the line!

Hugo

Posted at Nginx Forum:

Hello!

On Tue, Aug 09, 2011 at 10:22:34AM -0400, hugo wrote:

From the manpage:

RETURN VALUES
A 0 is returned if the call succeeds, -1 if it fails.

Do you actually see accept filter works, i.e. holding connection in
incomplete queue till http request comes?

Not sure, but likely NetBSD’s netstat should show this as well as
FreeBSD’s one with “netstat -Lan”:

$ netstat -Lan
Current listen queue sizes (qlen/incqlen/maxqlen)
Proto Listen Local Address

tcp4 0/1/128 *.8080

Note “1” in incqlen: this is telnet connection opened without http
request sent.

Maxim D.

Maxim,

According to
fxr.watson.org: identifier "SO_ACCEPTFILTER",
SO_ACCEPTFILTER is defined as 0x1000, and I see this:

23235 1 nginx CALL
setsockopt(7,0xffff,0x1000,0x7f7fffffd410,0x100)
23235 1 nginx RET setsockopt 0

From the manpage:

RETURN VALUES
A 0 is returned if the call succeeds, -1 if it fails.

Regards,

Hugo

Posted at Nginx Forum: