skb_unshare(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… skb_unshare(9) β€” Kernel API Manual, but make it make sense

okay so bestie, welcome to the <pink>Kernel API Manual</pink> ✨ and today's main character is skb_unshare, the function that says "no, you cannot share that, I'm making you your own copy" 🫢


πŸŽ€ NAME πŸŽ€

skb_unshare β€” make a copy of a shared buffer

like, un-share it. de-clone it. give it its own vibe. you get it πŸ’…


✨ SYNOPSIS ✨

struct sk_buff * skb_unshare (struct sk_buff *skb , gfp_t pri );

yes the spacing is exactly like that, don't come for me, I'm just the messenger 😭


🌸 ARGUMENTS 🌸

  • skb β€” buffer to check πŸ‘€ this is the one we're vibe-checking to see if it's a clone or not
  • pri β€” priority for memory allocation, aka the gfp flags you're passing in so kmalloc knows how much of a hurry you're in πŸƒβ€β™€οΈ

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜•οΈ β€” if the socket buffer is a clone, this function creates a new copy of the data, drops a reference count on the old copy, and returns the new copy with the reference count at 1. slay! fresh buffer, fresh start, count reset, iconic behavior πŸ‘‘

if the buffer is not a clone, the original buffer is just returned to you. no copy, no drama, we're just sending it right back πŸ’–

bestie please read this part carefully πŸ™ˆ when called with a spinlock held or from interrupt state, pri must be GFP_ATOMIC. no cap. don't be out here sleeping in interrupt context, that's giving main character villain energy πŸ’€

and if the memory allocation fails? NULL is returned. that's it. that's the whole thing. so like... check for it, okay? 😭


πŸ‘‘ SEE ALSO πŸ‘‘

it's giving the whole friend group β€” the kernel file is ./include/linux/skbuff.h and honestly here's everyone:

iykyk πŸ”₯ that's a lot of friends and honestly? obsessed with the community 🌈


that's the whole page bestie, go forth and un-share those buffers responsibly 🧚

sign-off time πŸŽ€ this one lives in ./include/linux, dated October 2026, and it's filed under skb_unshare(9) β€” periodt πŸ’œ

πŸ“¦ where this page comes from