Using any network interface whatsoever

Mike Meyer mwm-keyword-freebsdhackers.102a7e at mired.org
Sun Apr 9 03:00:12 UTC 2006


In <20060409005712.GA856 at trit.org>, Dima Dorfman <dd at freebsd.org> typed:
> Mike Meyer <mwm-keyword-freebsdhackers.102a7e at mired.org> wrote:
> > What do I want for that? I identify ethernet boards by which slot on
> > the back of the system I plug the cable into. Currently, I have to map
> > that to board types to and which board is plugged into which slot to
> > know which name to use. I want a name that tells me which slot I plug
> > a cable in to plug it into that interface.
> Is information about the slot even available on a PC? For something like this:

The BIOS seems to get that information from somewhere. But I'm not a
hardware guru, so I can't say for sure.

> : em0 at pci6:7:0:   class=0x020000 card=0x016d1028 chip=0x10768086 rev=0x05 hdr=0x00
> :     vendor   = 'Intel Corporation'
> :     device   = '82547EI Gigabit Ethernet Controller'
> :     class    = network
> :     subclass = ethernet
> 
> would you consider eth-6-7-0 to be an improvement over em0?

Not really, because the magic numbers aren't tied to anything
real. You want the magic numbers to corrspond to the physical objects
you manipulate.

For disk devices, the numbers were originally tied to bus ids, which
were set on the device. ra's had swappable plugs with the drive number
on them and a light behind the plug, so /dev/ra3 referred to the drive
in the rack of 16 drives with the number "3" in the front panel
lights.

> It has the advantage of not changing if another card is added to the
> system, but it's not very informative. For a system that has only
nn> its two on-board NICs, "em0" and "em1" are very obvious--at least
> it's clear which one corresponds to the label "eth 0" on the
> chassis.

I'll have to take your word for that, as I haven't got a box handy
with two onboard NICs.

Is there anything that says we can't have multiple names for an
interface? If we do that, then we could (random brainstorming here):

Have a name like eth-pci-slot-3 (it's an ethernet device on a pci bus
at slot 3), eth-pci-onboard-0 (onboard ethernet port 0) or eth-usb-2
(for the usb-ethernet dongles). The class part - "eth" - is redundant,
as the rest of the name identifies the device exactly, but it helps
prevent errors, as you get "no such device" errors instead of trying
to do something completely inappropriate to a device. This is what
you'd use on systems with multiple identical devices.

All network devices also get a name of the form net0, net1, .... This
is for systems with just one network interface - no matter what kind
it is - which can just refer to "net0" and get the one and only
network interface.

All network devices also get a name corresponding to the media, so
you'd have eth0, eth1, or fw0, fw1 (firewire), meaning that if you
specifically want an ethernet - as opposed to an arbitrary network
interface - you'd use eth0 instead of net0. This allows you to use
eth0, fw0 and wifi0 for the ethernet, firewire and wifi network
interfaces on a modern laptop, without having to worry about which
net# device map to which of those devices.


	<mike
-- 
Mike Meyer <mwm at mired.org>		http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.


More information about the freebsd-hackers mailing list