nla_reserve(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… nla_reserve(9) β€” the Kernel API Manual, bestie edition πŸ’…

okay so this is a page straight outta the Kernel API Manual (yes, the nla_reserve(9) one, we're fancy now), and it's genuinely so useful. it's giving "make room for your netlink attribute and let someone else do the copying" energy and honestly? iconic. let's get into it 🫢


✨ NAME ✨

nla_reserve β€” reserve room for attribute on the skb

like literally, that's the whole job. reserving room. on the skb. slay.


πŸ¦‹ SYNOPSIS πŸ¦‹

struct nlattr * nla_reserve (struct sk_buff *skb , int attrtype , int
attrlen );

that's the signature, don't come for me about the line break, it's exactly how it showed up πŸ’€


πŸŽ€ ARGUMENTS πŸŽ€

  • skb β€” the socket buffer you're reserving room on. that's the main character right there.
  • attrtype β€” the attribute type. which flavour of attribute are we doing.
  • attrlen β€” length of the attribute payload. how much room the payload needs, no cap.

🌸 DESCRIPTION 🌸

okay so the way this works: nla_reserve adds a netlink attribute header to a socket buffer and reserves room for the payload β€” but it does not copy it. nope. not its job. it's just holding the spot, like a friend saving you a seat. the actual copying is somebody else's problem 😌

and here's the important bit: it returns NULL if the tailroom of the skb is insufficient to store the attribute header and payload.

⚠️ real talk β€” that NULL return is not a vibe check you can ignore. if the tailroom can't fit the attribute header and the payload, you get NULL back, periodt. check it. πŸ’€

⭐ SEE ALSO ⭐

so many siblings, it's a whole family reunion 🧚 β€” and they're all chillin' in the kernel file ./lib/nlattr.c:

like, go read them too. iykyk πŸ’œ


and that's the whole page, bestie β€” no notes, ate and left no crumbs πŸ‘‘

signing off from ./lib, dated October 2026 (yes, the future, we're ahead of schedule 🌈), with all the love in the kernel πŸ“πŸ’–βœ¨

πŸ“¦ where this page comes from