__nla_parse(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐ŸŒธ __nla_parse โ€” Kernel API Manual ๐Ÿ’–

okay so bestie, welcome to the little kernel function that turns a raw stream of netlink attributes into something you can actually use โœจ it's called __nla_parse, and the whole manual lives in the Kernel API Manual (the section 9 one, for all the kernel-internals girlies ๐ŸŽ€).


โœจ NAME โœจ

__nla_parse โ€” Parse a stream of attributes into a tb buffer ๐Ÿซถ

like, literally the whole job description. stream of attrs goes in, tb buffer comes out, slay ๐Ÿ’…


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

int __nla_parse (struct nlattr **tb , int maxtype , const struct nlattr
     *head , int len , const struct nla_policy *policy , unsigned int
     validate , struct netlink_ext_ack *extack );

seven arguments, no cap. it's giving "long signature but worth it" energy ๐Ÿ˜ญ


๐Ÿ’œ ARGUMENTS ๐Ÿ’œ

  • tb โ€” your destination array, and bestie it needs maxtype+1 elements. count them. do not skimp. the math is mathing ๐Ÿงฎ
  • maxtype โ€” the maximum attribute type you expect to see. the ceiling. the limit. the "no attrs above this line" sign ๐Ÿšง
  • head โ€” head of the attribute stream, aka where the little parade of attributes starts ๐ŸŒˆ
  • len โ€” length of the attribute stream. yes queen, tell us how far to read ๐Ÿ‘‘
  • policy โ€” the validation policy. the rulebook. the vibe check for your attributes ๐Ÿ“‹
  • validate โ€” validation strictness. how hard are we checking? you decide ๐Ÿ’…
  • extack โ€” extended ACK pointer. for when you need to send a whole message back about what went wrong ๐Ÿ“จ

๐ŸŒธ DESCRIPTION ๐ŸŒธ

so what it does: it parses a stream of attributes and stores a pointer to each attribute into the tb array, reachable via the attribute type. so like, type in โ†’ pointer out. iconic lookup behaviour โœจ

and the validation? that's controlled by the validate parameter โ€” you set the strictness, it validates accordingly. main character parameter tbh.

it returns 0 on success or a negative error code. so if you get 0, celebrate ๐ŸŽ‰ if you get negative, read it as "something went sideways, check your attrs" ๐Ÿ˜ญ


๐Ÿ“ SEE ALSO ๐Ÿ“

the whole friendship group lives in the kernel file ./lib/nlattr.c โ€” go say hi to all of them:

like a whole group chat of netlink attribute functions and honestly? obsessed ๐Ÿซถ


ngl if you're reading this at 3am with a kernel splat on your screen, hydrate, then re-read the maxtype+1 part ๐Ÿ’€๐Ÿงš

k bye bestie, this page came from ./lib and it's dated October 2026, filed under __nla_parse(9) โ€” go parse something cute โœจ๐Ÿ’–๐ŸŽ€

๐Ÿ“ฆ where this page comes from