bpf_ksock_send(9)
π bpf_ksock_send(9) β the kernel API manual, bestie edition π
okay so real talk, this one's from the Kernel API Manual and it's literally about yeeting data out of a BPF kernel socket. let's get into it β¨
πΈ NAME πΈ
bpf_ksock_send β send data through a BPF kernel socket. that's it, that's the vibe π
β¨ SYNOPSIS β¨
__bpf_kfunc int bpf_ksock_send (struct bpf_ksock *ks , const void *data
, u32 data__sz );
no cap, that's the whole signature. copy it exactly, don't be cute with it π«Ά
π¦ ARGUMENTS π¦
ksβ the BPF kernel socket context. it must be an acquired reference, okay? like, an actually-acquired one. don't come at this function with a non-acquired socket, it's not the move πdataβ pointer to the data you wanna send. the actual bytes, the payload, the whole point πdata__szβ size of the data you're sending. it's au32. yes, the double underscore is on purpose, that's just how kfunc args are named, iykyk β
π₯ DESCRIPTION π₯
so here's the tea: this sends data on a connected socket. connected, bestie β like please make sure it's connected first, that's the whole prerequisite π§
and it's best-effort and nonblocking, meaning it does what it can and does not sit around waiting for you. main character energy, but in a "i have other sockets to service" way.
β οΈ but ALSO: this may sleep (it goes through kernel_sendmsg under the hood), which means you can only call it from sleepable BPF programs. not me warning you about this β okay, actually yes, me warning you about this. a non-sleepable program calling this is gonna have a bad time π
π RETURN π
- number of bytes sent on success π (could be fewer than you asked for, it's best-effort, remember?)
- negative
errnoon error π
π SEE ALSO π
the kernel file ./net/core/bpf_ksock.c β plus the whole friend group:
struct bpf_ksock(9)bpf_ksock_create(9)bpf_ksock_connect(9)bpf_ksock_acquire(9)bpf_ksock_release(9)
like, acquire before you send, release after you're done. the circle of life π¦
okay that's the page!! mwah π this little beauty lives in ./net/core and the version/date stamp on it is October 2026 β so yeah, mark your calendar, bestie, and go send some bytes responsibly πβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms