Skip to content

Commit

Permalink
fix(network): don't use same ifname multiple times
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mwilck authored and johannbg committed Sep 30, 2022
1 parent a65fab6 commit f4e9ea8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules.d/40network/net-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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"
}

Expand Down

0 comments on commit f4e9ea8

Please sign in to comment.