From 2c930b8c9715e6f1b48ca6a0f27e916f247818e4 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 28 Feb 2006 20:27:10 +0000 Subject: Fix potentials for endless loops when you have multiple devices that claim to have the same hardware address. (#177792, #182466) This happens most with hostap_cs and similar wireless drivers that have ethX/wlanX *and* wifiX. Do this by ignoring ieee802.11 links. Also, use /sbin/ip, not nameif - it gets confused in these cases as well. --- sysconfig/network-scripts/ifup-eth | 2 +- sysconfig/network-scripts/network-functions | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'sysconfig') diff --git a/sysconfig/network-scripts/ifup-eth b/sysconfig/network-scripts/ifup-eth index 2e7ca951..45efb881 100755 --- a/sysconfig/network-scripts/ifup-eth +++ b/sysconfig/network-scripts/ifup-eth @@ -40,7 +40,7 @@ is_available ${REALDEVICE} if [ -n "${HWADDR}" ]; then FOUNDMACADDR=`get_hwaddr ${REALDEVICE}` if [ "${FOUNDMACADDR}" != "${HWADDR}" ]; then - curdev=`ip -o link | awk -F ':' -vIGNORECASE=1 "/$HWADDR/ { print \\$2 }"` + curdev=`ip -o link | grep -v link/ieee802.11 | awk -F ': ' -vIGNORECASE=1 "/$HWADDR/ { print \\$2 }"` if [ -n "$curdev" ]; then rename_device "${REALDEVICE}" "${HWADDR}" "${curdev}" || { echo $"Device ${DEVICE} has different MAC address than expected, ignoring." diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 1ed37e01..accff4bd 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -158,25 +158,29 @@ do_netreport () # rename_device() - Rename a network device to something else # $1 - desired name # $2 - hardware address to name -# $3 - list of devices that are already in use +# $3 - Array variable - list of devices that are already in use # (for general calls, use the current device you're trying to # change to $1) rename_device() { - /sbin/nameif "$1" "$2" 2>/dev/null || { + local devs=$3 + + /sbin/ip link set "${devs[0]}" name "$1" 2>/dev/null || { local hw2=`get_hwaddr ${1}` local nconfig=`get_config_by_hwaddr ${hw2}` local dev= if [ -n "$nconfig" ]; then dev=$(. $nconfig ; echo $DEVICE) - for device in $3 ; do + for device in "${devs[@]}" ; do [ "$dev" = "$device" ] && unset dev done fi [ -z "$dev" ] && dev=dev$RANDOM - rename_device $dev $hw2 "$3 $1" - /sbin/nameif "$1" "$2" 2>/dev/null + + devs[${#devs[@]}]=$1 + rename_device $dev $hw2 $devs + /sbin/ip link set "${devs[0]}" name $1 2>/dev/null } } @@ -196,7 +200,7 @@ is_available () # trying to rename it: configure_ccwgroup_device if [ -n "$HWADDR" ]; then - local curdev=`ip -o link | awk -F ':' -vIGNORECASE=1 "/$HWADDR/ { print \\$2 }"` + local curdev=`ip -o link | grep -v link/ieee802.11 | awk -F ': ' -vIGNORECASE=1 "/$HWADDR/ { print \\$2 }"` if [ -z "$curdev" ]; then return 1 fi -- cgit v1.2.1