From 38ba0d7a623356c9ba89a4cb994d2e711f20ff5d Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Mon, 7 Mar 2011 13:19:44 +0100 Subject: [PATCH] network: add iBFT interface configuration [forward port of 0828d4c3574693ae80c217229e1bba6948dc9509] --- dracut.kernel.7.xml | 3 ++- modules.d/40network/ifup | 4 +++- modules.d/40network/module-setup.sh | 6 +++--- modules.d/40network/parse-ip-opts.sh | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/dracut.kernel.7.xml b/dracut.kernel.7.xml index aad27e2..32e73cf 100644 --- a/dracut.kernel.7.xml +++ b/dracut.kernel.7.xml @@ -386,7 +386,7 @@ This parameter can be specified multiple times. - ip={dhcp|on|any|dhcp6|auto6} + ip={dhcp|on|any|dhcp6|auto6|ibft} dhcp|on|any: get ip from dhcp server from all interfaces. If root=dhcp, @@ -394,6 +394,7 @@ loop sequentially through all interfaces (eth0, eth1, ...) and use the first with a valid DHCP root-path. auto6: IPv6 autoconfiguration dhcp6: IPv6 DHCP + ibft: iBFT autoconfiguration diff --git a/modules.d/40network/ifup b/modules.d/40network/ifup index c548ece..dc71109 100755 --- a/modules.d/40network/ifup +++ b/modules.d/40network/ifup @@ -207,7 +207,9 @@ fi # looking for ip= lines for p in $(getargs ip=); do ip_to_var $p - + # skip ibft + [ "$autoconf" = "ibft" ] && continue + # If this option isn't directed at our interface, skip it [ -n "$dev" ] && [ "$dev" != "$netif" ] && continue diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh index cb8c5df..6dd5fab 100755 --- a/modules.d/40network/module-setup.sh +++ b/modules.d/40network/module-setup.sh @@ -55,9 +55,9 @@ install() { inst_hook pre-udev 50 "$moddir/ifname-genrules.sh" inst_hook pre-udev 60 "$moddir/net-genrules.sh" inst_hook cmdline 91 "$moddir/dhcp-root.sh" - inst_hook cmdline 99 "$moddir/parse-ip-opts.sh" - inst_hook cmdline 97 "$moddir/parse-bond.sh" - inst_hook cmdline 98 "$moddir/parse-bridge.sh" + inst_hook cmdline 96 "$moddir/parse-bond.sh" + inst_hook cmdline 97 "$moddir/parse-bridge.sh" + inst_hook cmdline 98 "$moddir/parse-ip-opts.sh" inst_hook cmdline 99 "$moddir/parse-ifname.sh" inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh" diff --git a/modules.d/40network/parse-ip-opts.sh b/modules.d/40network/parse-ip-opts.sh index b4954a2..d4e5018 100755 --- a/modules.d/40network/parse-ip-opts.sh +++ b/modules.d/40network/parse-ip-opts.sh @@ -51,11 +51,43 @@ if [ -n "$NEEDBOOTDEV" ] ; then [ -z "$BOOTDEV" ] && die "Bootdev argument is empty" fi +if [ "ibft" = "$(getarg ip=)" ]; then + modprobe 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 +fi + # Check ip= lines # XXX Would be nice if we could errorcheck ip addresses here as well for p in $(getargs ip=); do ip_to_var $p + # skip ibft + [ "$autoconf" = "ibft" ] && continue + # We need to have an ip= line for the specified bootdev [ -n "$NEEDBOOTDEV" ] && [ "$dev" = "$BOOTDEV" ] && BOOTDEVOK=1 -- 2.7.4