of_get_mac_address(9)
π¦ 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 β
- the kernel file
./net/core/of_net.c of_get_phy_mode(9)of_get_ethdev_address(9)
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
- 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