186d7f5d3SJohn Marino.\" 286d7f5d3SJohn Marino.\" Copyright (c) 2000 Alfred Perlstein 386d7f5d3SJohn Marino.\" 486d7f5d3SJohn Marino.\" All rights reserved. 586d7f5d3SJohn Marino.\" 686d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without 786d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions 886d7f5d3SJohn Marino.\" are met: 986d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright 1086d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer. 1186d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright 1286d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer in the 1386d7f5d3SJohn Marino.\" documentation and/or other materials provided with the distribution. 1486d7f5d3SJohn Marino.\" 1586d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 1686d7f5d3SJohn Marino.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1786d7f5d3SJohn Marino.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1886d7f5d3SJohn Marino.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 1986d7f5d3SJohn Marino.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2086d7f5d3SJohn Marino.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2186d7f5d3SJohn Marino.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2286d7f5d3SJohn Marino.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2386d7f5d3SJohn Marino.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2486d7f5d3SJohn Marino.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2586d7f5d3SJohn Marino.\" 2686d7f5d3SJohn Marino.\" $FreeBSD: src/share/man/man9/accf_http.9,v 1.1.2.6 2002/07/02 01:03:59 brian Exp $ 2786d7f5d3SJohn Marino.\" 2886d7f5d3SJohn Marino.Dd November 15, 2000 2986d7f5d3SJohn Marino.Dt ACCF_HTTP 9 3086d7f5d3SJohn Marino.Os 3186d7f5d3SJohn Marino.Sh NAME 3286d7f5d3SJohn Marino.Nm accf_http 3386d7f5d3SJohn Marino.Nd "buffer incoming connections until a certain complete HTTP requests arrive" 3486d7f5d3SJohn Marino.Sh SYNOPSIS 3586d7f5d3SJohn Marino.Cd options INET 3686d7f5d3SJohn Marino.Cd options ACCEPT_FILTER_HTTP 3786d7f5d3SJohn Marino.Li kldload accf_http 3886d7f5d3SJohn Marino.Sh DESCRIPTION 3986d7f5d3SJohn MarinoThis is a filter to be placed on a socket that will be using 4086d7f5d3SJohn Marino.Fn accept 4186d7f5d3SJohn Marinoto receive incoming HTTP connections. 4286d7f5d3SJohn Marino.Pp 4386d7f5d3SJohn MarinoIt prevents the application from receiving the connected descriptor via 4486d7f5d3SJohn Marino.Fn accept 4586d7f5d3SJohn Marinountil either a full HTTP/1.0 or HTTP/1.1 HEAD or GET request has 4686d7f5d3SJohn Marinobeen buffered by the kernel. 4786d7f5d3SJohn Marino.Pp 4886d7f5d3SJohn MarinoIf something other than a HTTP/1.0 or 4986d7f5d3SJohn MarinoHTTP/1.1 HEAD or GET request is received the kernel will 5086d7f5d3SJohn Marinoallow the application to receive the connection descriptor 5186d7f5d3SJohn Marinovia 5286d7f5d3SJohn Marino.Fn accept . 5386d7f5d3SJohn Marino.Pp 5486d7f5d3SJohn MarinoThe utility of 5586d7f5d3SJohn Marino.Nm 5686d7f5d3SJohn Marinois such that a server will not have to context switch several times 5786d7f5d3SJohn Marinobefore performing the initial parsing of the request. 5886d7f5d3SJohn MarinoThis effectively reduces the amount of required CPU utilization 5986d7f5d3SJohn Marinoto handle incoming requests by keeping active 6086d7f5d3SJohn Marinoprocesses in preforking servers such as Apache low 6186d7f5d3SJohn Marinoand reducing the size of the filedescriptor set that needs 6286d7f5d3SJohn Marinoto be managed by interfaces such as 6386d7f5d3SJohn Marino.Fn select , 6486d7f5d3SJohn Marino.Fn poll 6586d7f5d3SJohn Marinoor 6686d7f5d3SJohn Marino.Fn kevent 6786d7f5d3SJohn Marinobased servers. 6886d7f5d3SJohn Marino.Pp 6986d7f5d3SJohn MarinoThe 7086d7f5d3SJohn Marino.Nm 7186d7f5d3SJohn Marinokernel option is also a module that can be enabled at runtime via 7286d7f5d3SJohn Marino.Xr kldload 8 7386d7f5d3SJohn Marinoif the INET option has been compiled into the kernel. 7486d7f5d3SJohn Marino.Sh EXAMPLES 7586d7f5d3SJohn MarinoAssuming ACCEPT_FILTER_HTTP has been included in the kernel config 7686d7f5d3SJohn Marinofile or the 7786d7f5d3SJohn Marino.Nm 7886d7f5d3SJohn Marinomodule has been loaded, this will enable the http accept filter 7986d7f5d3SJohn Marinoon the socket 8086d7f5d3SJohn Marino.Fa sok . 8186d7f5d3SJohn Marino.Bd -literal -offset 0i 8286d7f5d3SJohn Marino struct accept_filter_arg afa; 8386d7f5d3SJohn Marino 8486d7f5d3SJohn Marino bzero(&afa, sizeof(afa)); 8586d7f5d3SJohn Marino strcpy(afa.af_name, "httpready"); 8686d7f5d3SJohn Marino setsockopt(sok, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa)); 8786d7f5d3SJohn Marino.Ed 8886d7f5d3SJohn Marino.Sh SEE ALSO 8986d7f5d3SJohn Marino.Xr setsockopt 2 , 9086d7f5d3SJohn Marino.Xr accept_filter 9 9186d7f5d3SJohn Marino.Sh HISTORY 9286d7f5d3SJohn MarinoThe accept filter mechanism and the 9386d7f5d3SJohn Marino.Nm 9486d7f5d3SJohn Marinofilter were introduced in 9586d7f5d3SJohn Marino.Fx 4.0 . 9686d7f5d3SJohn Marino.Sh AUTHORS 9786d7f5d3SJohn MarinoThis manual page and the filter were written by 9886d7f5d3SJohn Marino.An Alfred Perlstein . 99