From 208f5edf15809e85af2bd11fff1d9e43ede6fe0b Mon Sep 17 00:00:00 2001 From: Steven Shiau Date: Wed, 18 Aug 2010 14:30:06 +0200 Subject: [PATCH] Making multiple connected NICs work. --- scripts/live | 79 ++++++++++++++++++--------------- scripts/live-premount/select_eth_device | 15 ++++--- 2 files changed, 54 insertions(+), 40 deletions(-) diff --git a/scripts/live b/scripts/live index 2976dae..07226fa 100755 --- a/scripts/live +++ b/scripts/live @@ -581,6 +581,9 @@ do_netsetup () 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 @@ -651,9 +654,6 @@ do_netsetup () 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 @@ -677,45 +677,54 @@ do_netsetup () 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" + 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 "${DNSDOMAIN}" ] + if [ -n "${interface}" ] then - echo "domain ${DNSDOMAIN}" > /etc/resolv.conf - echo "search ${DNSDOMAIN}" > /etc/resolv.conf + HWADDR="$(cat /sys/class/net/${interface}/address)" fi - for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1} - do - echo "nameserver $i" >> /etc/resolv.conf - done - fi + if [ ! -e "/etc/resolv.conf" ] + then + echo "Creating /etc/resolv.conf" - # 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 + 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 + panic "No supported network device found, maybe a non-mainline driver is required." + fi + done } do_netmount() diff --git a/scripts/live-premount/select_eth_device b/scripts/live-premount/select_eth_device index dfeac3d..fe86313 100755 --- a/scripts/live-premount/select_eth_device +++ b/scripts/live-premount/select_eth_device @@ -68,6 +68,7 @@ for ARGUMENT in $(cat /proc/cmdline); do esac done +found_eth_dev="" while true; do echo -n "Looking for a connected Ethernet interface ..." @@ -85,13 +86,17 @@ while true; do 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 -- 2.1.4