Re: How does "alias ethX drivername" in modules.conf work?

Riley Williams
2001-08-08T06:41:05Z

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2891 bytes --]

Hi Mark.

>> I've certainly never stood in the position you call "Kernel" in
>> that description. Here's the situation as I see it, put in those
>> sort of terms, characters being InitScripts and Kernel
>> respectively:
>>
>> 1. InitScripts points at Kernel saying "there is no good and no
>> well documented mapping method".
>>
>> 2. Kernel replies "There is a good mapping method, which is to
>> always map the ports starting with the lowest numbered one."

> Well, there is that present mapping method, but I hesitate to
> call it "good".
>
> Plus, we are unable to satisfactorily define "lowest numbered
> one".

Why? When is eth0 higher numbered than eth1 for example?

> If I build a system with several identical (other than MAC)
> FooCorp PCI ethernics, they will number up in order of ascending
> MAC address.
>
> I take the same system, replace the FooCorp cards with BarInc
> NICs, they will number up in reverse MAC address.
>
> Replace them instead with Baz Systems NICs, and I get them in
> bus scan order (at which point I'm dependent on the firmware
> version of my PCI bridge too!).
>
> And if I elect to use Frob Networking NICs, I instead get them
> in the *random* order that their oncard processors won the race
> to power up.
>
> Gods and demons help me if I try putting several of all four
> brands in one box, or the firmware on my NICs or in my PCI
> bridges changes!

I dealt with this problem in a previous email, but will repeat it for
your benefit. The ONLY provisos I will use are the following two:

1. All ethernet interfaces in your machine have distinct MAC's.

2. If the firmware in your NIC's changes, the MAC's do not.

Providing both of these are met, the enclosed BASH SHELL SCRIPT
implements the `ifconfig` command with the port name replaced by its
MAC address.

With this change, it doesn't actually matter what port name a
particular interface is given, because ALL of the other network config
tools refer to the interface by its assigned IP address, not its port
name. As a result, if its port name changes between boots, the routing
automatically changes with it.

>> 3. InitScripts then tells Kernel "But I don't want to map the
>> ports in ascending numerical order!"

> The phrase "ascending numerical order" becomes, depending on if
> you have a complex (lots of different kinds of interfaces) or
> dynamic (ferex, with PCMCIA, CompactPCI, USB, and Firewire
> ethernet interfaces), either useless or undefined.

I disagree: The phrase "ascending numerical order" has a FIXED
meaning, namely that eth0 comes before eth1 which comes before eth2.

You appear to have assumed that I was referring to ascending MAC
address, and such an assumption makes nonsense of most of what I said,
but if you use the meaning I used, you'll see it makes perfect sense
throughout.

Best wishes from Riley.

[-- Attachment #2: /usr/local/sbin/ifmap --]
[-- Type: TEXT/PLAIN, Size: 1504 bytes --]

#!/bin/bash

###############################################################################
#
# This script provides a version of the `ifconfig` command that expects to
# see the ethernet address associated with a particular port, and performs
# the stated actions on whichever ethernet interface has the specified
# ethernet address. All actions associated with the `ifconfig` command are
# supported, and the only change in syntax is that the port name of "eth?"
# is replaced by the associated ethernet address.
#
# If no ethernet interface is found with the specified ethernet address,
# this script uses a return value of 1, otherwise it uses a return value
# of 0.
#
###############################################################################

function assign() {
local HW="$1" OK=Y
declare -i N=0

shift 1
while [ $OK = Y ]; do
if ! port eth$N ; then
if ifconfig eth$N up 2> /dev/null ; then
if [ "`hwaddr eth$N`" != "${HW}" ]; then
ifconfig eth$N down
else
ifconfig eth$N "$@"
OK=$?
fi
else
OK=0
fi
fi
N=$N+1
done
return $OK
}

function hwaddr() {
ifconfig "$1" | grep "^$1" | tr ' ' '\n' | grep '[0-9A-F]:[0-9A-F]'
}

function port() {
ifconfig | grep ^eth | fgrep "$1" > /dev/null
}

if [ $# -gt 0 ]; then
if assign "$@" ; then
echo No ethernet interface with address "$1" found. >&2
exit 1
else
exit 0
fi
else
ifconfig
exit 0
fi