]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(network): don't use same ifname multiple times
authorMartin Wilck <mwilck@suse.com>
Sat, 17 Sep 2022 21:05:39 +0000 (23:05 +0200)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Fri, 30 Sep 2022 06:02:18 +0000 (06:02 +0000)
If multiple ibft interfaces exist, set_ifname() may reuse the same
name (usually "ibft0"), because it's usually called cmdline time,
when no interfaces exist in sysfs yet. Remember the number used
set and don't use it again.

modules.d/40network/net-lib.sh

index a294a3902192e35145b2667fb010d3abcb1d78d6..8b876926d75db1b2924c8915bb137c885a232755 100755 (executable)
@@ -222,6 +222,7 @@ set_ifname() {
     for n in $(getargs ifname=); do
         strstr "$n" "$mac" && echo "${n%%:*}" && return
     done
+    [ ! -f "/tmp/set_ifname_$name" ] || read -r num < "/tmp/set_ifname_$name"
     # otherwise, pick a new name and use that
     while :; do
         num=$((num + 1))
@@ -232,6 +233,7 @@ set_ifname() {
         break
     done
     echo "ifname=$name$num:$mac" >> /etc/cmdline.d/45-ifname.conf
+    echo "$num" > "/tmp/set_ifname_$name"
     echo "$name$num"
 }