[CentOS] Nic order detection

Thu Jan 10 14:52:09 UTC 2008
Michael D. Kralka <michael.kralka at kvs.com>

Les Mikesell wrote:
> I do have the ifcfg-ethX files for the 2 interfaces that are currently
> active, but since the machines were built by image copies of a master
> disk, they do not have HWADDR address entries.  A person on-site with
> access to the console adjusted them if they didn't come up right the
> first time, but they seem to shift around on each reboot.  Will adding
> the HWADDR entry nail them down even if it doesn't match the nic type
> specified in modprobe.conf?  Can someone point me to the code where this
> happens?  Until recently the machines were running centos 3.x and this
> seems to be a difference in behavior.

As already pointed out, yes adding HWADDR will "nail them down" and the
entries in modprobe.conf don't mean much. If you (or a script) execute
"modprobe eth0" it will load the appropriate module. Unfortunately, this
is not how CentOS 5 loads drivers.

With CentOS 5, udev is used to load the drivers by looking at the
"modalias" file found for each device under the /sys directory (search
for them, there are many). For PCI devices, the modalias includes the 4
16-bit PCI ID values, the PCI device type, and some other information.

Unfortunately, udev tries to be clever and loads drivers in parallel. As
a result, if there are NICs that use different drivers, the order that
the NICs are assigned ethX interfaces is left to the whim of the Linux
scheduler (i.e. is non-deterministic). Devices using the same driver
will always be assigned interface names in the same relative ordering.
If they all use the same driver, they will always be assigned the same
names, without having to fuss with the HWADDR option (this is due to how
drivers enumerate PCI devices).

In reality, HWADDR doesn't force the kernel to assign the desired
interface to each device. It simply "cleans up" after udev by renaming
the interfaces from what the kernel assigned to each NIC to the
interfaces you expect. Search for "rename_device" in ifup-eth and
network-functions, both found in the /etc/sysconfig/network-scripts
directory.

Cheers,
Michael