howto determine network device unit number? device.hints?
Yony Yossef
yonyossef.lists at gmail.com
Thu Jan 15 01:43:38 PST 2009
> Yony Yossef wrote:
> > Thanks for the explanation.
> >
> > So there's no way to determine this in advance..
> >
> What do you mean by 'in advance'? Assuming a fixed hardware
> configuration, when the kernel is loaded, you know all the
> interface names and can rename them, i.e., in rc.local.
>From the beginning:
I have a FreeBSD7 machine with two network cards, both carry the same device
name "mtnic".
My driver is a kernel module loaded manualy using kldload.
Upon load, the driver registers the net device by the name "mtnic<unit
number>", that is what you see in ifconfig.
Problem is, this unit number is not constant and changing arbitrarily every
time I reload the driver (card A unit number=0 & card B un=1 or the other
way around).
Therefore, IP assignment to mtnic0 by /etc/rc.conf may assign an interface
with an IP belongs to another subnet, since rc.conf is not changing.
Of course I can keep my own MAC-to-interface mapping and rename the
interfaces after I load the driver.
It doesn't sound like a reasonable solution though.
Plus, I still don't understand why the unit number should change at all,
instead of being determined according to the card PCI location or some other
constant.
Yony
>
> > I must build a script that contains my own mapping between MAC
> > addresses and the wanted interface names and run it after
> each driver
> > load, rename the interfaces if necessary.
> >
> I do not quite understand your requirement. Can you please explain?
> Do you need a script that works on multiple machines with
> different hardwares?
>
> > It seems quite wrong, don't you agree?
> >
> > And how come the unit number is given an arbitrary value?
> Is there a
> > good reason for that?
> >
> > Yony
More information about the freebsd-net
mailing list