[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Fix for BOOTIF parameter



Hello,

Patch from Bug#593284 didn't work. Here is a little patch to fix
BOOTIF handling and remove unnecessary autodetection.


-- 
WBR realloc()
From 09c9818c93483e0e61620ffa57c6a7a6d5c3576d Mon Sep 17 00:00:00 2001
From: Stanislav Bogatyrev <realloc@realloc.spb.ru>
Date: Mon, 31 Jan 2011 04:04:33 +0300
Subject: [PATCH] Make BOOTIF really work.
 Skip auto-detection if $DEVICE or $BOOTIF present.
 Remove duplicated functionality in nic auto-detection.

---
 scripts/live                            |   56 ++++---------------------------
 scripts/live-premount/select_eth_device |   14 +++++++-
 2 files changed, 20 insertions(+), 50 deletions(-)

diff --git a/scripts/live b/scripts/live
index ef87d3c..c014c39 100755
--- a/scripts/live
+++ b/scripts/live
@@ -69,7 +69,8 @@ Arguments ()
 				;;
 
 			BOOTIF=*)
-				BOOTIF="${x#BOOTIF=}"
+				BOOTIF="${ARGUMENT#BOOTIF=}"
+				export BOOTIF
 				;;
 
 			debug)
@@ -608,11 +609,9 @@ do_netsetup ()
 	[ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
 	echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
 
-	if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
-	   [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
+	if [ -z "${DEVICE}" ]
 	then
 
-
 	# support for Syslinux IPAPPEND parameter
 	# it sets the BOOTIF variable on the kernel parameter
 
@@ -659,57 +658,16 @@ do_netsetup ()
 			fi
 		done
 	fi
+  fi
 
-	# if ethdevice was not specified on the kernel command line
-	# make sure we try to get a working network configuration
-	# for *every* present network device (except for loopback of course)
-	if [ -z "$ETHDEVICE" ] ; then
-		echo "If you want to boot from a specific device use bootoption ethdevice=..."
-		for device in /sys/class/net/*; do
-			dev=${device##*/} ;
-			if [ "$dev" != "lo" ] ; then
-				ETHDEVICE="$ETHDEVICE $dev"
-			fi
-		done
-	fi
-
-	# split args of ethdevice=eth0,eth1 into "eth0 eth1"
-	for device in $(echo $ETHDEVICE | sed 's/,/ /g') ; do
-		devlist="$devlist $device"
-	done
-
-	# this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
-	# an endless loop; iff execution fails give it two further tries, that's
-	# why we use '$devlist $devlist $devlist' for the other for loop
-	for dev in $devlist $devlist $devlist ; do
-		echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
-		ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
-		jobid=$!
-		sleep "$ETHDEV_TIMEOUT" ; sleep 1
-		if [ -r /proc/"$jobid"/status ] ; then
-			echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
-			kill -9 $jobid
-		fi
-
-		# if configuration of device worked we should have an assigned
-		# IP address, iff so let's use the according as $DEVICE for later usage
-		# simple and primitive approach which seems to work fine
-		if ifconfig $dev | grep -q 'inet.*addr:' ; then
-			export DEVICE="$dev"
-			break
-		fi
-	done
-
-	else
-		for interface in ${DEVICE}; do
+	for interface in ${DEVICE}; do
 			ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
 			[ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
 			if [ "$IPV4ADDR" != "0.0.0.0" ]
 			then
-				break
+				  break
 			fi
-		done
-	fi
+	done
 
 	for interface in ${DEVICE}; do
 		# source relevant ipconfig output
diff --git a/scripts/live-premount/select_eth_device b/scripts/live-premount/select_eth_device
index fe86313..2c2e1dc 100755
--- a/scripts/live-premount/select_eth_device
+++ b/scripts/live-premount/select_eth_device
@@ -56,13 +56,25 @@ if [ $(echo $l_interfaces | wc -w) -lt 2 ]; then
 	exit 0
 fi
 
+if [ -n $DEVICE ]
+then
+    echo "Force to use network device $DEVICE."
+    exit 0
+fi
+
+if [ -n $BOOTIF ]
+then
+    echo "BOOTIF parameter is set by pxelinux. Skipping autodetection."
+    exit 0
+fi
+
 # If user force to use specific device, write it
 for ARGUMENT in $(cat /proc/cmdline); do
     case "${ARGUMENT}" in
         live-netdev=*)
         NETDEV="${ARGUMENT#live-netdev=}"
         echo "DEVICE=$NETDEV" >> /conf/param.conf
-	echo "Found live-netdev parameter in /proc/cmdline. Force to use network device $NETDEV."
+        echo "Found live-netdev parameter in /proc/cmdline. Force to use network device $NETDEV."
         exit 0
         ;;
     esac
-- 
1.7.2.3


Reply to: