dev_alloc_name(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… dev_alloc_name(9) β€” like, the naming era ✨

Okay bestie, welcome to the Kernel API Manual πŸŽ€ and specifically to dev_alloc_name(9) β€” the little function that hands your shiny new network device its very own name. Think of it as the kernel's baby-name book, except the names are like eth0 and eth1 and the baby is a struct. Iconic. πŸ’–


🌸 NAME 🌸

dev_alloc_name β€” allocate a name for a device πŸ‘‘


✨ SYNOPSIS ✨

int dev_alloc_name (struct net_device *dev , const char *name );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • dev β€” the device, obvs. This is the one getting named. 🫢
  • name β€” the name format string, like the template you fill in.

πŸ”₯ DESCRIPTION πŸ”₯

So here's the vibe: you hand it a format string β€” for example "ltd" β€” and it goes off and tries to find a suitable id for it. Detective mode. πŸ”

It scans the list of devices to build up a free map, then picks the first empty slot. First come, first served, no cap. πŸ’…

⚠️ Real talk, bestie: the caller must hold the dev_base or rtnl lock while allocating the name and adding the device, otherwise you get duplicates. And duplicates are not the move. 😭

It's limited to bits_per_byte * page size devices β€” that's 32K on most platforms, iykyk.

Returns the number of the unit assigned, or a negative errno code if things go sideways. πŸ™ˆ


🌈 SEE ALSO 🌈

Kernel file ./net/core/dev.c β€” and honestly the whole friend group showed up, so let's give them all their moment: πŸ‘‘


Okay that's the whole thing, mwah πŸ’‹ ngl this one's a certified classic from the ./net/core era, dated October 2026, and it lives at dev_alloc_name(9) β€” go name some devices, bestie, you got this πŸŒŸπŸ’œ

πŸ“¦ where this page comes from