From 0b11ea71996a7b804afbc38d1d5461fb0f4ef882 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Wed, 7 Aug 2013 16:05:03 +0200 Subject: [PATCH] network/net-lib.sh: fix ibft interface configuration also skip ibft$num names, which have been already given https://bugzilla.redhat.com/show_bug.cgi?id=989944 --- modules.d/40network/net-lib.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh index 494960c..ca4b393 100644 --- a/modules.d/40network/net-lib.sh +++ b/modules.d/40network/net-lib.sh @@ -172,13 +172,20 @@ save_netinfo() { } set_ifname() { - local name="$1" mac="$2" num=0 n="" + local name="$1" mac="$2" num=-1 n="" # if it's already set, return the existing name for n in $(getargs ifname=); do strstr "$n" "$mac" && echo ${n%%:*} && return done # otherwise, pick a new name and use that - while [ -e /sys/class/net/$name$num ]; do num=$(($num+1)); done + while :; do + num=$(($num+1)); + [ -e /sys/class/net/$name$num ] && continue + for n in $(getargs ifname=); do + [ "$name$num" = "${n%%:*}" ] && continue 2 + done + break + done echo "ifname=$name$num:$mac" >> /etc/cmdline.d/45-ifname.conf echo "$name$num" } @@ -205,6 +212,9 @@ ibft_to_cmdline() { mac=$(read a < ${iface}/mac; echo $a) [ -z "$mac" ] && continue dev=$(set_ifname ibft $mac) + + [ -e /tmp/net.${dev}.has_ibft_config ] && continue + [ -e ${iface}/dhcp ] && dhcp=$(read a < ${iface}/dhcp; echo $a) if [ -e ${iface}/vlan ]; then vlan=$(read a < ${iface}/vlan; echo $a) @@ -215,6 +225,8 @@ ibft_to_cmdline() { echo "ip=$dev:dhcp" elif [ -e ${iface}/ip-addr ]; then [ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a) + # skip not assigned ip adresses + [ "$ip" = "0.0.0.0" ] && continue [ -e ${iface}/gateway ] && gw=$(read a < ${iface}/gateway; echo $a) [ -e ${iface}/subnet-mask ] && mask=$(read a < ${iface}/subnet-mask; echo $a) [ -e ${iface}/hostname ] && hostname=$(read a < ${iface}/hostname; echo $a)