skb_kill_datagram(9)
π skb_kill_datagram β the Kernel API Manual, bestie edition π
okay so you're in the kernel API manual (skb_kill_datagram(9)) and you found the page about forcibly freeing a datagram skbuff. yes, forcibly. it's giving "we're breaking up and i'm keeping the skb" energy π
β¨ NAME β¨
skb_kill_datagram β free a datagram skbuff forcibly π₯
π SYNOPSIS π
int skb_kill_datagram (struct sock *sk , struct sk_buff *skb , unsigned
int flags );
like, that's the whole signature. three args, one int back. slay.
π¦ ARGUMENTS π¦
skβ socket π«Άskbβ datagram skbuff (the little guy in question) πflagsβMSG_flags β
πΈ DESCRIPTION πΈ
so this function frees a datagram skbuff that was received by skb_recv_datagram. and bestie, listen β the flags argument must match the one used for skb_recv_datagram. no cap. they have to be the same flags, or things get weird.
if the MSG_PEEK flag is set, and the packet is still on the receive queue of the socket, it will be taken off the queue before it is freed. so peekers don't get to keep it forever, sorry π the queue lock is right there.
β οΈ okay this is the important one, highkey: this function currently only disables BH when acquiring the sk_receive_queue lock. therefore it must not be used in a context where that lock is acquired in an IRQ context. like, do not do that. fr fr. it's giving undefined-behaviour-adjacent and it's not cute π
it returns 0 if the packet was removed by us π (us!! we did that!!)
π SEE ALSO π
kernel file ./net/core/datagram.c β and the whole friend group:
__skb_try_recv_datagram(9)skb_copy_and_crc32c_datagram_iter(9)skb_copy_datagram_iter(9)skb_copy_datagram_from_iter(9)zerocopy_sg_from_iter(9)skb_copy_and_csum_datagram(9)skb_copy_and_csum_datagram_msg(9)datagram_poll_queue(9)datagram_poll(9)
and that's the page, bestie!! π§ mwah π this one lives in ./net/core, and the manual is dated October 2026 β so like, future vibes only β bye bestie, go free those skbs 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