__nla_parse(9)
๐ธ __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 needsmaxtype+1elements. 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:
__nla_validate(9)nla_policy_len(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(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 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
- 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