bpf_ksock_send(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’Œ 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 a u32. 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 errno on error 😭

πŸ‘‘ SEE ALSO πŸ‘‘

the kernel file ./net/core/bpf_ksock.c β€” plus the whole friend group:

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