nla_reserve(9)
π 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 β thatNULLreturn is not a vibe check you can ignore. if the tailroom can't fit the attribute header and the payload, you getNULLback, 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:
__nla_validate(9)nla_policy_len(9)__nla_parse(9)nla_find(9)nla_strscpy(9)nla_strdup(9)nla_memcpy(9)nla_memcmp(9)nla_strcmp(9)__nla_reserve(9)__nla_reserve_64bit(9)__nla_reserve_nohdr(9)nla_reserve_64bit(9)nla_reserve_nohdr(9)__nla_put(9)__nla_put_64bit(9)__nla_put_nohdr(9)nla_put(9)nla_put_64bit(9)nla_put_nohdr(9)nla_append(9)
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
- 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