ACCF_HTTP(9)

πŸ’– ACCF_HTTP πŸ’–

okay bestie, this is the ACCF_HTTP page from section 9 of the Kernel Developer's Manual β€” yes, the kernel dev one, we're going deep today 🫢


✨ NAME ✨

accf_http β€” buffer incoming connections until a certain complete HTTP requests arrive

like, it just holds the vibe at the door until the whole request shows up. no half-sent requests walking in here πŸšͺπŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

options INET
options ACCEPT_FILTER_HTTP
kldload accf_http

that's it, that's the whole entrance fee ✨


🌸 DESCRIPTION 🌸

So. This is a filter you place on a socket that's gonna be using accept() to receive incoming HTTP connections. It's giving bouncer-at-the-club energy 🧚

It prevents the application from receiving the connected descriptor via accept() until either a full HTTP/1.0 or HTTP/1.1 HEAD or GET request has been buffered by the kernel. Like, the app literally cannot get that file descriptor until the request is complete. Periodt. πŸ‘‘

But if something other than an HTTP/1.0 or HTTP/1.1 HEAD or GET request shows up? The kernel's like "aight, not my problem," and lets the application receive the connection descriptor via accept() anyway. Not it gatekeeping things it doesn't understand πŸ’€

The whole point of accf_http β€” the utility, the reason it ate and left no crumbs β€” is that a server won't have to context switch several times before doing the initial parsing of the request. Which effectively reduces the amount of required CPU utilization to handle incoming requests by:

  • keeping active processes in preforking servers such as Apache low, and
  • reducing the size of the file descriptor set that needs to be managed by interfaces such as select(), poll() or kevent() based servers.

iconic behaviour, fr fr 🌈

Also!! The accf_http kernel option is also a module that can be enabled at runtime via kldload(8) β€” but only if the INET option has been compiled into the kernel. so like, INET is the prerequisite bestie, no skipping steps πŸ™ˆ


πŸŽ€ EXAMPLES πŸŽ€

Assuming ACCEPT_FILTER_HTTP has been included in the kernel config file, or the accf_http module has been loaded β€” either way works β€” this will enable the http accept filter on the socket sok:

struct accept_filter_arg afa;

bzero(&afa, sizeof(afa));
strcpy(afa.af_name, "httpready");
setsockopt(sok, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa));

look at that. "httpready" β€” the name literally tells you the vibe. slay ✨


πŸ”₯ SEE ALSO πŸ”₯

go read those too, iykyk πŸ’œ


🌈 HISTORY 🌈

The accept filter mechanism and the accf_http filter were introduced in FreeBSD 4.0. so they've been serving looks since forever πŸ‘‘


πŸ‘‘ AUTHORS πŸ‘‘

This manual page and the filter were written by Alfred Perlstein. thank you king 🫢


Debian Β· November 15, 2000 β€” that's the version and the date bestie, mwah, catch u on the next page πŸ’–πŸ’…βœ¨

πŸ“¦ where this page comes from