ethnl_parse_bitset(9)
๐
ethnl_parse_bitset โ Kernel API Manual, bestie edition
okay so this is ethnl_parse_bitset from the kernel API manual and it is literally the function that does the math homework for you ๐งฎโจ It computes the effective value and mask from a bitset nest. Iconic. No cap.
โจ SYNOPSIS โจ
int ethnl_parse_bitset (unsigned long *val , unsigned long *mask ,
unsigned int nbits , const struct nlattr *attr , ethnl_string_array_t
names , struct netlink_ext_ack *extack );
that's the whole vibe right there ๐ซถ five args, one int return, zero drama.
๐ ARGUMENTS ๐
valโ anunsigned longbased bitmap, and it's where the value goes. like, the output value slot ๐maskโ also anunsigned longbased bitmap, and it's where the mask goes. twin ofval, bestie behavior fr fr.nbitsโ the size of thevalandmaskbitmaps. so like, how many bits each one holds ๐ฆattrโ the nest attribute you're parsing and applying. this is the actual data being decoded โจnamesโ array of bit names. may be null for compact format โ yes,NULLis allowed, she's flexible ๐extackโ extack, used for error reporting. the "what went wrong" messenger ๐ข
๐ธ DESCRIPTION ๐ธ
so here's the tea โ: you hand over nbits-size-long bitmaps for val and mask, and the whole point is this โ
x = (val & mask) | (x & ~mask)
the way that this formula would modify any nbits sized bitmap x the exact same way ethnl_update_bitset with the same bitset attribute would. like, identical outcome, no divergence, periodt. ๐
basically: precompute the effective value + mask once, then you can slam that update formula onto any x and it's giving correctly-updated bitmap every time ๐ฅ
โญ RETURN โญ
- negative error code on failure ๐ญ
0on success ๐
yes it's that simple, and yes you should still check it. literally always check your returns, bestie, i'm begging ๐
ngl this is a "check the return value or perish" situation.0= slay.< 0= something went sideways.
๐ฆ SEE ALSO ๐ฆ
- the kernel file
./net/ethtool/bitset.cโ the mothership ๐ ethnl_bitmap32_clear(9)ethnl_bitmap32_not_zero(9)ethnl_bitmap32_update(9)ethnl_bitset32_size(9)ethnl_put_bitset32(9)ethnl_bitset_is_compact(9)ethnl_name_to_idx(9)ethnl_bitmap32_equal(9)ethnl_update_bitset32(9)
that's the whole friend group, go say hi ๐๐
okay that's the whole page!! tysm for reading, mwah ๐ซถ from ./net/ethtool, October 2026 โ the Kernel API Manual era, and honestly? we ate. ๐โจ๐
๐ฆ 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