]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
net-lib: ibft_to_cmdline() fixes
authorWANG Chao <chaowang@redhat.com>
Tue, 3 Sep 2013 17:29:58 +0000 (01:29 +0800)
committerHarald Hoyer <harald@redhat.com>
Wed, 4 Sep 2013 06:04:20 +0000 (08:04 +0200)
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

index ca4b393395f2d97e5c3ec02985847582e1346d17..82c4f7234d3e31fbaef77d125695f98dfef8f557 100644 (file)
@@ -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