skb_kill_datagram(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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:


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