ACCF_DATA(9)

✨ ACCF_DATA ✨

okay bestie, gather round, because today we're talking about accf_data β€” the accept filter that literally just makes your server wait for the vibe to arrive before it lets anybody in. πŸ’…

she lives in section 9 of the kernel developer's manual, and honestly? she's giving patient queen. πŸ‘‘


🌸 NAME 🌸

accf_data β€” buffer incoming connections until data arrives πŸ’–

like... that's it. that's the whole job. she holds the door but doesn't open it until someone actually shows up with something to say.


πŸŽ€ SYNOPSIS πŸŽ€

options INET
options ACCEPT_FILTER_DATA
kldload accf_data

three little lines, three ways to get her into your life. no cap. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• β€” this is a filter, and you place it on a socket. specifically, a socket that's gonna be using accept() to receive incoming connections. that's her whole scene.

what she does: she prevents the application from receiving the connected descriptor via accept() until data actually arrives on the connection. 🫢 like, no data, no descriptor. she's not handing over the goods to a ghost. periodt.

so instead of your app waking up to a connection that's just... sitting there. silently. doing nothing. (πŸ’€ the worst kind of guest), she makes it wait until there's actually something to read.

also!! the ACCEPT_FILTER_DATA kernel option is also a module, which means you can enable it at runtime via kldload(8) β€” but only if the INET option has been compiled into the kernel. so check that first, bestie, otherwise she's not coming to the party. πŸ™ˆ


🌈 EXAMPLES 🌈

okay so assuming ACCEPT_FILTER_DATA has been included in the kernel config file, or the accf_data module has been loaded, this is how you enable the data accept filter on the socket sok. look at her go:

struct accept_filter_arg afa;

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

see that "dataready" string? that's her name at the setsockopt party. πŸŽ€ zero the struct, copy the name, call the setsockopt, done. iconic behaviour, honestly. no notes. πŸ‘‘


πŸ’œ SEE ALSO πŸ’œ

the whole friend group fr fr 🫢 go say hi.


⭐ HISTORY ⭐

the accept filter mechanism and the accf_data filter were introduced in FreeBSD 4.0. so she's been around. she's a veteran. she's got lore. 🌸


πŸ‘‘ AUTHORS πŸ‘‘

this manual page and the filter were written by Alfred Perlstein. thank you for your service king 🫑✨


lowkey important reminder: she only shows up if INET is compiled into your kernel. don't forget that part, bestie, or you'll be sitting there wondering why nothing works. 😭

and that's the whole page!! written on November 15, 2000, coming at you from Debian β€” yeah, this documentation is older than most of us and she's still serving. πŸ’–βœ¨ bye bestie, go buffer some connections πŸ¦‹

πŸ“¦ where this page comes from