aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2003-08-08 02:27:05 +0000
committerBill Nottingham <notting@redhat.com>2003-08-08 02:27:05 +0000
commit670fbad9378ec67d8331160908d96a6becbf5a78 (patch)
tree5a84fbd5fb4c4d696d46670fb39572dc5675e5e9 /sysconfig
parent21abf2cfb4445453d421266dce65db9aea1b2479 (diff)
downloadinitscripts-670fbad9378ec67d8331160908d96a6becbf5a78.tar
initscripts-670fbad9378ec67d8331160908d96a6becbf5a78.tar.gz
initscripts-670fbad9378ec67d8331160908d96a6becbf5a78.tar.bz2
initscripts-670fbad9378ec67d8331160908d96a6becbf5a78.tar.xz
initscripts-670fbad9378ec67d8331160908d96a6becbf5a78.zip
fix ethernet device renaming deadlock (yay recursion!) (#101566)
Diffstat (limited to 'sysconfig')
-rwxr-xr-xsysconfig/network-scripts/ifup3
-rw-r--r--sysconfig/network-scripts/network-functions30
2 files changed, 31 insertions, 2 deletions
diff --git a/sysconfig/network-scripts/ifup b/sysconfig/network-scripts/ifup
index 2a2e955c..9c6945ad 100755
--- a/sysconfig/network-scripts/ifup
+++ b/sysconfig/network-scripts/ifup
@@ -143,7 +143,8 @@ is_available ${REALDEVICE}
if [ -n "${HWADDR}" ]; then
FOUNDMACADDR=`get_hwaddr ${REALDEVICE}`
if [ "${FOUNDMACADDR}" != "${HWADDR}" ]; then
- /sbin/nameif "${REALDEVICE}" "${HWADDR}" || {
+ local curdev=`ip -o link | awk -F ':' -vIGNORECASE=1 '/$HWADDR/ { print $2 }'`
+ rename_device "${REALDEVICE}" "${HWADDR}" "${curdev}" || {
echo $"Device ${DEVICE} has different MAC address than expected, ignoring."
exit 1
}
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index 4bde6a63..ad106fb3 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -144,6 +144,31 @@ 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
+# (for general calls, use the current device you're trying to
+# change to $1)
+
+rename_device()
+{
+ /sbin/nameif "$1" "$2" || {
+ local hw2=`get_hwaddr ${1}`
+ local nconfig=`fgrep -il "HWADDR=$hw2" /etc/sysconfig/network-scripts/ifcfg-*`
+ local dev=
+ if [ -n "$nconfig" ]; then
+ dev=$(. $nconfig ; echo $DEVICE)
+ for device in $3 ; do
+ [ "$dev" = "$device" ] && unset dev
+ done
+ fi
+ [ -z "$dev" ] && dev=dev$RANDOM
+ rename_device $dev $hw2 "$3 $1"
+ /sbin/nameif "$1" "$2"
+ }
+}
+
is_available ()
{
LC_ALL= LANG= ip -o link | grep -q $1
@@ -154,7 +179,10 @@ is_available ()
return 2
fi
modprobe $1 > /dev/null 2>&1 || return 1
- [ -n "$HWADDR" ] && /sbin/nameif "$1" "$HWADDR"
+ if [ -n "$HWADDR" ]; then
+ local curdev=`ip -o link | awk -F ':' -vIGNORECASE=1 '/$HWADDR/ { print $2 }'`
+ rename_device "$1" "$HWADDR" "$curdev"
+ fi
LC_ALL= LANG= ip -o link | grep -q $1
return $?
}