skb_copy_expand(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… skb_copy_expand β€” copy and expand sk_buff

okay bestie, welcome to skb_copy_expand(9) from the Kernel API Manual ✨ this is a kernel-networking girly and she is very good at her job, so let's get into it 🫢


πŸŽ€ SYNOPSIS πŸŽ€

struct sk_buff * skb_copy_expand (const struct sk_buff *skb , int
newheadroom , int newtailroom , gfp_t gfp_mask );

like, that's the whole signature, no notes πŸ’…


🌸 ARGUMENTS 🌸

  • skb β€” the buffer you wanna copy, bestie. your source material πŸ‘‘
  • newheadroom β€” how many new free bytes you want at the head πŸŽ€
  • newtailroom β€” how many new free bytes you want at the tail πŸ¦‹
  • gfp_mask β€” the allocation priority. yes it matters, keep reading 😭

✨ DESCRIPTION ✨

So what this does is: it makes a copy of an sk_buff and its data, and while it's doing that it also allocates extra space for you πŸ’– literally copying and expanding at the same time, main character energy fr fr.

This is the one you reach for when the caller wants to modify the data and needs a private copy of that data to alter, plus more room for new fields. It returns NULL on failure, or a pointer to the buffer on success. And heads up β€” the returned buffer has a reference count of 1. ⭐

🚨 ngl this part is important: you must pass GFP_ATOMIC as the allocation priority if this function is called from an interrupt. no cap, don't skip that.

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./net/core/skbuff.c β€” and like, the whole extended friend group πŸ’€ mwah, enjoy the roster:


okay that's the whole thing, you're so welcome πŸ§šπŸ’œ this page lives over in ./net/core and it's dated October 2026 β€” go forth and copy those skbs responsibly, bestie. slay πŸ’…βœ¨

πŸ“¦ where this page comes from