]> git.ipfire.org Git - thirdparty/dracut.git/blobdiff - modules.d/40network/parse-ip-opts.sh
deprecate "ip=ibft" kernel command line parameter
[thirdparty/dracut.git] / modules.d / 40network / parse-ip-opts.sh
index d7b7f3753884211decee7edfd30432bd6b6a2a86..b029d0073987982c0199343a9121c01e100c0bae 100755 (executable)
@@ -5,79 +5,41 @@
 # Format:
 #       ip=[dhcp|on|any]
 #
-#       ip=<interface>:[dhcp|on|any]
+#       ip=<interface>:[dhcp|on|any][:[<mtu>][:<macaddr>]]
 #
-#       ip=<client-IP-number>:<server-id>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:[dhcp|on|any|none|off]
+#       ip=<client-IP-number>:<server-IP-number>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:{dhcp|on|any|none|off}[:[<mtu>][:<macaddr>]]
 #
 # When supplying more than only ip= line, <interface> is mandatory and
 # bootdev= must contain the name of the primary interface to use for
 # routing,dns,dhcp-options,etc.
 #
 
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+command -v getarg >/dev/null          || . /lib/dracut-lib.sh
 
-# Check if ip= lines should be used
-if getarg ip= >/dev/null ; then
-    if [ -z "$netroot" ] ; then
-        echo "Warning: No netboot configured, ignoring ip= lines"
-        return;
-    fi
-fi
-
-# Don't mix BOOTIF=macaddr from pxelinux and ip= lines
-getarg ip= >/dev/null && getarg BOOTIF= >/dev/null && \
-    die "Mixing BOOTIF and ip= lines is dangerous"
-
-# No more parsing stuff, BOOTIF says everything
-[ -n "$(getarg BOOTIF)" ] && return
-
-if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] ; then
+if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] && [ -z "$(getarg BOOTIF=)" ]; then
     # No ip= argument(s) for netroot provided, defaulting to DHCP
     return;
 fi
 
 # Count ip= lines to decide whether we need bootdev= or not
 if [ -z "$NEEDBOOTDEV" ] ; then
-    local count=0
+    count=0
     for p in $(getargs ip=); do
+        case "$p" in
+            ibft)
+                continue;;
+        esac
         count=$(( $count + 1 ))
     done
     [ $count -gt 1 ] && NEEDBOOTDEV=1
 fi
+unset count
 
 # If needed, check if bootdev= contains anything usable
-if [ -n "$NEEDBOOTDEV" ] ; then
-    BOOTDEV=$(getarg bootdev=) || die "Please supply bootdev argument for multiple ip= lines"
-    [ -z "$BOOTDEV" ] && die "Bootdev argument is empty"
-fi
+BOOTDEV=$(getarg bootdev=)
 
-if [ "ibft" = "$(getarg ip=)" ]; then
-    modprobe iscsi_ibft
-    num=0
-    (   
-       for iface in /sys/firmware/ibft/ethernet*; do
-           [ -e ${iface}/mac ] || continue
-            ifname_mac=$(read a < ${iface}/mac; echo $a)
-           [ -z "$ifname_mac" ] && continue
-            ifname_if=ibft$num
-           num=$(( $num + 1 ))
-           echo "ifname=$ifname_if:$ifname_mac"
-           dev=$ifname_if
-
-           dhcp=$(read a < ${iface}/dhcp; echo $a)
-           if [ -n "$dhcp" ]; then
-               echo "ip=$dev:dhcp"
-           else
-               ip=$(read a < ${iface}/ip-addr; echo $a)
-               gw=$(read a < ${iface}/gateway; echo $a)
-               mask=$(read a < ${iface}/subnet-mask; echo $a)
-               hostname=$(read a < ${iface}/hostname; echo $a)
-               echo "ip=$ip::$gw:$mask:$hostname:$dev:none"
-           fi
-       done
-    ) >> /etc/cmdline
-    # reread cmdline
-    unset CMDLINE
+if [ -n "$NEEDBOOTDEV" ] ; then
+    [ -z "$BOOTDEV" ] && warn "Please supply bootdev argument for multiple ip= lines"
 fi
 
 # Check ip= lines
@@ -85,7 +47,13 @@ fi
 for p in $(getargs ip=); do
     ip_to_var $p
 
-    # skip ibft
+    # make first device specified the BOOTDEV
+    if [ -z "$BOOTDEV" ] && [ -n "$dev" ]; then
+        BOOTDEV="$dev"
+        [ -n "$NEEDBOOTDEV" ] && warn "Setting bootdev to '$BOOTDEV'"
+    fi
+
+    # skip ibft since we did it above
     [ "$autoconf" = "ibft" ] && continue
 
     # We need to have an ip= line for the specified bootdev
@@ -101,7 +69,7 @@ for p in $(getargs ip=); do
     case $autoconf in
         error) die "Error parsing option 'ip=$p'";;
         bootp|rarp|both) die "Sorry, ip=$autoconf is currenty unsupported";;
-        none|off) \
+        none|off)
             [ -z "$ip" ] && \
             die "For argument 'ip=$p'\nValue '$autoconf' without static configuration does not make sense"
             [ -z "$mask" ] && \
@@ -128,9 +96,6 @@ for p in $(getargs ip=); do
         IFACES="$IFACES $dev"
     fi
 
-    # Small optimization for udev rules
-    [ -z "$NEEDBOOTDEV" ] && [ -n "$dev" ] && BOOTDEV=$dev
-
     # Do we need to check for specific options?
     if [ -n "$NEEDDHCP" ] || [ -n "$DHCPORSERVER" ] ; then
         # Correct device? (Empty is ok as well)
@@ -146,8 +111,14 @@ for p in $(getargs ip=); do
 
 done
 
+# put BOOTIF in IFACES to make sure it comes up
+if getargbool 1 "rd.bootif" && BOOTIF="$(getarg BOOTIF=)"; then
+    BOOTDEV=$(fix_bootif $BOOTIF)
+    IFACES="$BOOTDEV $IFACES"
+fi
+
 # This ensures that BOOTDEV is always first in IFACES
-if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ] ; then 
+if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ] ; then
     IFACES="${IFACES%$BOOTDEV*} ${IFACES#*$BOOTDEV}"
     IFACES="$BOOTDEV $IFACES"
 fi
@@ -155,6 +126,3 @@ fi
 # Store BOOTDEV and IFACES for later use
 [ -n "$BOOTDEV" ] && echo $BOOTDEV > /tmp/net.bootdev
 [ -n "$IFACES" ]  && echo $IFACES > /tmp/net.ifaces
-
-# We need a ip= line for the configured bootdev= 
-[ -n "$NEEDBOOTDEV" ] && [ -z "$BOOTDEVOK" ] && die "Bootdev Argument '$BOOTDEV' not found"