diff options
author | Bob Gilligan <gilligan@vyatta.com> | 2010-02-05 16:41:30 -0800 |
---|---|---|
committer | Bob Gilligan <gilligan@vyatta.com> | 2010-02-05 16:41:30 -0800 |
commit | 743b1d4931d9794add3b3f1f55448e31caae2bde (patch) | |
tree | 01004dfedc7396f3da4da6453bd49ea7b2f329f6 /scripts/vyatta_net_name | |
parent | 91452c86d9a5183d4d99e79365b71cf633033427 (diff) | |
download | vyatta-cfg-system-743b1d4931d9794add3b3f1f55448e31caae2bde.tar.gz vyatta-cfg-system-743b1d4931d9794add3b3f1f55448e31caae2bde.zip |
Bugfix 5120: Use biosdevname to generate the canonical name for an interface.
Network interfaces are discovered at boot time in non-deterministic
order, so their names are non-deterministic. The vyatta_net_name
script is responsible for ensuring that network interface names are
changed to match their Vyatta config file entry when a match based on
MAC address is found. With this change, when a match is not found, we
use the biosdevname tool to to find the canonical name for an
interface, then change the interface's name to that name. This
ensures that NICs are named in a deterministic and systemmatic fashion.
Diffstat (limited to 'scripts/vyatta_net_name')
-rwxr-xr-x | scripts/vyatta_net_name | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/scripts/vyatta_net_name b/scripts/vyatta_net_name index 7a4420ad..de1fbcbf 100755 --- a/scripts/vyatta_net_name +++ b/scripts/vyatta_net_name @@ -49,7 +49,7 @@ for arg ; do attr_address=$arg ;; * ) - kname=$arg + orig_kname=$arg ;; esac done @@ -62,7 +62,9 @@ done shopt -s extglob nullglob -# load cfg_eth_hwid array from config file as follows +# load cfg_eth_hwid array from the Vyatta config file by looking +# for entries formatted as follows: +# # interface { # ... # ethernet eth# { @@ -72,7 +74,11 @@ shopt -s extglob nullglob # } # } # -# cfg_eth_hwid=( "eth#=xx:xx:xx:xx:xx:xx" ... ) +# The result is an array named "cfg_net_hwid". Each element of the +# array is formatted like this: +# +# eth#=xx:xx:xx:xx:xx:xx +# declare -a cfg_net_hwid=( $( sed -ne ' /^interfaces {/,/^}/ { @@ -220,12 +226,31 @@ get_free_ethn() echo "`date`: get_free_ethn found $ethn_to_use" >> $log_file } +# +# Main Section +# # Run with lock held to protect atomicity of access to assigned ethn file ( flock 200 touch $log_file -echo "`date`: vyatta_net_name $kname $attr_address" >> $log_file +echo "`date`: vyatta_net_name $orig_kname $attr_address" >> $log_file + +# The biosdevname program determines the "recommended" name for the NIC +# based on information such its place in the bus topology, and whether it +# resides on the motherboard or not. The ensures deterministic NIC naming. +# +if [ ! -z "$orig_kname" ]; then + if [ -e /sbin/biosdevname ]; then + kname=`/sbin/biosdevname -i $orig_kname` + echo "`date`: /sbin/biosdevname maps $orig_kname to $kname" >> $log_file + else + echo "`date`: /sbin/biosdevname is not present on this system" >> $log_file + kname=$orig_kname + fi +else + kname="" +fi if [ ! -f $BOOTFILE ] ; then cp $DEFAULT_BOOTFILE $BOOTFILE @@ -258,6 +283,7 @@ for name_hwid in ${cfg_net_hwid[@]} ; do done if [ -z "$kname" ]; then + echo "`date`: Error: interface name not specified by caller" >> $log_file exit 1 fi @@ -308,7 +334,7 @@ elif [ -z "${match#*=}" ] ; then finish mod $kname $attr_address else - # The config file has this interface name, but the mac address + # The config file has this interface name, but the mac address is not # that of this NIC. This indicates that the device is either a # replacement or new NIC that is being detected earlier than the device # configured with this name. Since we don't know which case it is, |