nft_data_init(9)
π nft_data_init β the kernel API manual, but make it make sense β¨
okay so bestie, welcome to the nft_data_init(9) page, straight out of the Kernel API Manual π. This is the little kernel function that takes your raw netlink attributes and turns them into actual, usable nf_tables data. It's giving "backend bestie doing the heavy lifting" energy fr fr. Let's get into it π«Ά
β¨ SYNOPSIS β¨
int nft_data_init (const struct nft_ctx *ctx , struct nft_data *data ,
struct nft_data_desc *desc , const struct nlattr *nla );
yeah that's the whole squad right there π four args, one int return, no drama. Slay.
πΈ ARGUMENTS πΈ
ctxβ the context of the expression that's using the data π like, whose data is this anywaydataβ the destinationstruct nft_dataπ this is where the parsed goodies landdescβ the data description, aka the receipts πnlaβ the netlink attribute that's carrying the data π¦
π DESCRIPTION π
So what does it actually do? It parses the netlink data attributes and initializes a struct nft_data for you β¨. The type and length of the data get returned in the data description β so desc is literally telling you what you just got, iykyk π
.
And here's the cute part π: the caller can say "bestie, I only want data of type NFT_DATA_VALUE" by passing NULL for the ctx argument. That's it. That's the whole flex. No ctx, no other types, just pure NFT_DATA_VALUE energy β.
ngl, passing NULL isn't a bug, it's a choice β you're lowkey gatekeeping which data types get through π
π SEE ALSO π
the whole friend group π go check these out:
- Kernel file
./net/netfilter/nf_tables_api.cβ the source file, main character of the directory fr nft_register_expr(9)nft_unregister_expr(9)nft_data_hold(9)nft_register_obj(9)nft_unregister_obj(9)nft_parse_u32_check(9)nft_dump_register(9)nft_data_release(9)
like, that's a lot of siblings but they all ate π₯
okay that's the whole page bestie, you're officially fluent in nft_data_init π
β¨. shoutout to ./net/netfilter for hosting this absolute icon, and to October 2026 for the timestamp π β no cap, we love a documented kernel API. bye bestie, go parse some attributes π¦π
π¦ 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