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

[PATCH] live-boot: make multiple connected NICs work



Hi,
Attached please find the patch for the live-boot 2.0.0-1. It makes live-boot to test all the connected NICs. Without patching, when multiple NICs are connected, currently live-boot only uses the first NIC to lease IP address from DHCP server. This is not always true, for example, if there are 2 NICs, both of them are connected, but the DHCP server is actually on 2nd NIC.
My 2 cents.

Regards,
Steven.

--
Steven Shiau<steven _at_ nchc org tw>  <steven _at_ stevenshiau org>
National Center for High-performance Computing, Taiwan. http://www.nchc.org.tw
Public Key Server PGP Key ID: 1024D/9762755A
Fingerprint: A2A1 08B7 C22C 3D06 34DB  F4BC 08B3 E3D7 9762 755A

--- a/scripts/live-premount/select_eth_device
+++ a/scripts/live-premount/select_eth_device
@@ -68,6 +68,7 @@
     esac
 done
 
+found_eth_dev=""
 while true; do
 	echo -n "Looking for a connected Ethernet interface ..."
 
@@ -85,13 +86,17 @@
 				2>/dev/null)
 			# link detected
 			if [ "$carrier" = 1 ]; then
-				echo " found $interface."
+				echo "Connected $interface found"
 				# inform initrd's init script :
-				echo "DEVICE=$interface" >> /conf/param.conf
-				exit 0
+				found_eth_dev="$found_eth_dev $interface"
 			fi
 		done
-		# wait a bit
-		sleep 1
+		if [ -n "$found_eth_dev" ]; then
+			echo "DEVICE='$found_eth_dev'" >> /conf/param.conf
+			exit 0
+		else
+			# wait a bit
+			sleep 1
+		fi
 	done
 done
--- a/scripts/live
+++ b/scripts/live
@@ -577,6 +577,9 @@
 	udevadm trigger
 	udevadm settle
 
+	[ -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}" ]
 	then
@@ -599,9 +602,6 @@
 		devlist="$devlist $device"
 	done
 
-	[ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
-	echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
-
 	# 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
@@ -625,45 +625,54 @@
 	done
 
 	else
-	ipconfig ${DEVICE} | tee /netboot.config
-	fi
-
-	# source relevant ipconfig output
-	OLDHOSTNAME=${HOSTNAME}
-	. /tmp/net-${DEVICE}.conf
-	[ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
-	export HOSTNAME
-
-	if [ -n "${DEVICE}" ]
-	then
-		HWADDR="$(cat /sys/class/net/${DEVICE}/address)"
+		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
+			fi
+		done
 	fi
 
-	if [ ! -e "/etc/resolv.conf" ]
-	then
-		echo "Creating /etc/resolv.conf"
-
-		if [ -n "${DNSDOMAIN}" ]
+	for interface in ${DEVICE}; do
+		# source relevant ipconfig output
+		OLDHOSTNAME=${HOSTNAME}
+		[ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
+		[ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
+		export HOSTNAME
+	
+		if [ -n "${interface}" ]
+		then
+			HWADDR="$(cat /sys/class/net/${interface}/address)"
+		fi
+	
+		if [ ! -e "/etc/resolv.conf" ]
+		then
+			echo "Creating /etc/resolv.conf"
+	
+			if [ -n "${DNSDOMAIN}" ]
+			then
+				echo "domain ${DNSDOMAIN}" > /etc/resolv.conf
+				echo "search ${DNSDOMAIN}" > /etc/resolv.conf
+			fi
+	
+			for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1}
+			do
+				echo "nameserver $i" >> /etc/resolv.conf
+			done
+		fi
+	
+		# Check if we have a network device at all
+		if ! ls /sys/class/net/"$interface" > /dev/null 2>&1 && \
+		   ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
+		   ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
+		   ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
+		   ! ls /sys/class/net/ra0 > /dev/null 2>&1
 		then
-			echo "domain ${DNSDOMAIN}" > /etc/resolv.conf
-			echo "search ${DNSDOMAIN}" > /etc/resolv.conf
+			panic "No supported network device found, maybe a non-mainline driver is required."
 		fi
-
-		for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1}
-		do
-			echo "nameserver $i" >> /etc/resolv.conf
-		done
-	fi
-
-	# Check if we have a network device at all
-	if ! ls /sys/class/net/"$DEVICE" > /dev/null 2>&1 && \
-	   ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
-	   ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
-	   ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
-	   ! ls /sys/class/net/ra0 > /dev/null 2>&1
-	then
-		panic "No supported network device found, maybe a non-mainline driver is required."
-	fi
+	done
 }
 
 do_netmount()

Reply to: