ETHER_GEN_ADDR(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’– ETHER_GEN_ADDR(9) πŸ’–

okay so bestie, welcome to the ether_gen_addr era of the Kernel Developer's Manual ✨ this one's all about handing out a MAC address when nobody assigned one, and honestly? it's giving "fairy godmother but for network interfaces" 🧚


✨ NAME ✨

ether_gen_addr β€” generate an arbitrary MAC address for use πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

like, include these first, obviously:

#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/ethernet.h>

void
ether_gen_addr(struct ifnet *ifp, struct ether_addr *hwaddr);

🌸 DESCRIPTION 🌸

The ether_gen_addr() function generates an arbitrary MAC address for use by an ethernet interface that does not have an assigned address 🫢 like, it's literally the fallback bestie.

By default, ether_gen_addr attempts to generate a stable MAC address using the hostid of the jail that the ifp is being added to πŸ’… During early boot though, the hostid may not be set on machines that haven't yet populated /etc/hostid, or on machines that do not use loader(8) 😭 (yes, that's a whole thing).

ether_gen_addr can fail to derive a MAC address due to memory allocation failure, or because the hostid has not been populated πŸ’€ In these cases, a locally-administered unicast MAC address will be randomly generated and returned via the hwaddr parameter β€” no cap, the fallback is still a valid vibe ✨

If ether_gen_addr succeeds, then it will return a MAC address in the FreeBSD Foundation OUI, 58:9c:fc, via the hwaddr parameter πŸ‘‘

ngl the two paths are: stable-ish and hostid-based, or random-but-still-locally-administered-unicast. both land in hwaddr. that's the whole deal πŸ“

πŸ‘‘ AUTHORS πŸ‘‘

This manual page was written by Kyle Evans <kevans@FreeBSD.org> πŸ’– iconic of him, fr fr.


and that's the whole page bestie, you ate 🌈✨ this little slice of lore comes to you from Debian, dated June 1, 2021, and it's ETHER_GEN_ADDR(9) all the way down πŸŽ€ bye bestie, go generate some addresses responsibly πŸ’œ

πŸ“¦ where this page comes from