of_get_mac_address(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ of_get_mac_address πŸ¦‹

okay so welcome to the Kernel API Manual bestie, section 9 ofc, and today's main character is of_get_mac_address πŸ’–


✨ NAME ✨

of_get_mac_address β€” and ngl the NAME line in the original is literally blank?? not a single word after the dash 😭 so we're just gonna sit here with the function name and vibe, iykyk 🫢


πŸŽ€ SYNOPSIS πŸŽ€

int of_get_mac_address (struct device_node *np , u8 *addr );

like yes that's the whole signature, copy it exactly pls, spaces and all, don't @ me πŸ’…


🌸 ARGUMENTS 🌸

  • np β€” the caller's Device Node, aka where you're looking, bestie 🌳
  • addr β€” a pointer to a six-byte array where the result goes. six bytes. that's your MAC-sized lil slot, so make sure it's actually that big πŸ‘‘

πŸ’œ DESCRIPTION πŸ’œ

okay so the whole plot: this thing searches the device tree for the best MAC address to use πŸ”₯

the order matters, so pay attention:

  • 'mac-address' gets checked first, because that one is supposed to contain the "most recent" MAC address πŸ‘‘
  • if that isn't set, then 'local-mac-address' is checked next, because that's the default address ✨
  • if that isn't set either… then the obsolete of the above isn't set, then try to get MAC address from nvmem cell named
and yeah, that sentence genuinely just trails off right there in the source 😭 "nvmem cell named" β€” named what, bestie?? the manpage said cliffhanger and left. not me inventing the rest, fr fr, that's literally all it says πŸ™ˆ

okay now the 'address' property lore 🧚 note that the 'address' property is supposed to contain a virtual address of the register set, but some DTS files have redefined that property to be the MAC address. so like, chaos, but documented chaos πŸ’€


and now the dramatic part 🚨 all-zero MAC addresses are rejected, because those could be properties that exist in the device tree but were not set by U-Boot. example time:

  • the DTS could define 'mac-address' and 'local-mac-address', both with zero MAC addresses 🫠
  • some older U-Boots only initialized 'local-mac-address'
  • in this case, the real MAC is in 'local-mac-address', and 'mac-address' exists but is all zeros

so like, the zero one is a decoy, don't fall for it, the rejection is the whole point πŸ’…


🌈 RETURN 🌈

0 on success, and errno in case of error. that's it, that's the tea β˜•


⭐ SEE ALSO ⭐

go read those too, i'm obsessed, slay πŸ¦‹


lowkey reminder: keep every flag, path and number exactly as written above β€” the vibe is mine, the facts are not, periodt πŸ’–

and that's a wrap bestie!! this page came from ./net/core and it's dated October 2026 β€” go forth and get those MAC addresses, you're gonna eat πŸŽ€βœ¨

πŸ“¦ where this page comes from