ethnl_parse_bitset(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’… 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 โ€” an unsigned long based bitmap, and it's where the value goes. like, the output value slot ๐Ÿ’–
  • mask โ€” also an unsigned long based bitmap, and it's where the mask goes. twin of val, bestie behavior fr fr.
  • nbits โ€” the size of the val and mask bitmaps. 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, NULL is 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 ๐Ÿ˜ญ
  • 0 on 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 ๐Ÿฆ‹

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