From f2cbd4cbd639df9b0f3d9320df491bf23c109edb Mon Sep 17 00:00:00 2001
From: WANG Chao <chaowang@redhat.com>
Date: Wed, 4 Sep 2013 01:29:58 +0800
Subject: [PATCH] net-lib: ibft_to_cmdline() fixes
Fix 3 issues in ibft_to_cmdline():
- unset local variables at the beginning of each loop
- only write vlan.conf when we write out ip=xxx
- when vlan id is 0, don't write out vlan.conf. Because 0 means untagged
and we don't actually need vlan interface.
---
modules.d/40network/net-lib.sh | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
index ca4b393..82c4f72 100644
--- a/modules.d/40network/net-lib.sh
+++ b/modules.d/40network/net-lib.sh
@@ -203,11 +203,13 @@ fix_bootif() {
}
ibft_to_cmdline() {
- local iface="" mac="" dev=""
- local dhcp="" ip="" gw="" mask="" hostname=""
+ local iface=""
modprobe -q iscsi_ibft
(
for iface in /sys/firmware/ibft/ethernet*; do
+ local mac="" dev=""
+ local dhcp="" ip="" gw="" mask="" hostname=""
+
[ -e ${iface}/mac ] || continue
mac=$(read a < ${iface}/mac; echo $a)
[ -z "$mac" ] && continue
@@ -216,10 +218,6 @@ ibft_to_cmdline() {
[ -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)
- echo "vlan=$vlan:$dev"
- fi
if [ -n "$dhcp" ]; then
echo "ip=$dev:dhcp"
@@ -244,6 +242,11 @@ ibft_to_cmdline() {
ls -l ${iface} | vinfo
fi
+ if [ -e ${iface}/vlan ]; then
+ vlan=$(read a < ${iface}/vlan; echo $a)
+ [ "$vlan" -ne "0" ] && echo "vlan=$vlan:$dev"
+ fi
+
echo $mac > /tmp/net.${dev}.has_ibft_config
done
) >> /etc/cmdline.d/40-ibft.conf