ia64/xen-unstable

changeset 8646:40bb46f599d9

Poll for peth0 coming up before trying to attach it to the bridge. This fixes
a problem seen with tg3's needing some time for auto-negotiation, and so the
script would fail.

Patch courtesy of someone who's name has been lost to history.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Tue Jan 10 15:21:00 2006 +0000 (2006-01-10)
parents 991ccc24bf2e
children a38c292e8390
files tools/examples/network-bridge
line diff
     1.1 --- a/tools/examples/network-bridge	Tue Jan 10 15:05:05 2006 +0000
     1.2 +++ b/tools/examples/network-bridge	Tue Jan 10 15:21:00 2006 +0000
     1.3 @@ -242,10 +242,10 @@ using loopback.nloopbacks=<N> on the dom
     1.4  	ip addr flush ${pdev}
     1.5  	ip link set ${netdev} addr ${mac} arp on
     1.6  	add_to_bridge ${bridge} ${vif0}
     1.7 -	add_to_bridge ${bridge} ${pdev}
     1.8  	ip link set ${bridge} up
     1.9  	ip link set ${vif0} up
    1.10  	ip link set ${pdev} up
    1.11 +	add_to_bridge2 ${bridge} ${pdev}
    1.12  	do_ifup ${netdev}
    1.13      else
    1.14  	# old style without ${vdev}
    1.15 @@ -293,6 +293,27 @@ op_stop () {
    1.16      brctl delbr ${bridge}
    1.17  }
    1.18  
    1.19 +# adds $dev to $bridge but waits for $dev to be in running state first
    1.20 +add_to_bridge2() {
    1.21 +    local bridge=$1
    1.22 +    local dev=$2
    1.23 +    local maxtries=10
    1.24 +
    1.25 +    echo -n "Waiting for ${dev} to negotiate link."
    1.26 +    for i in `seq ${maxtries}` ; do
    1.27 +	if ifconfig ${dev} | grep -q RUNNING ; then
    1.28 +	    break
    1.29 +	else
    1.30 +	    echo -n '.'
    1.31 +	    sleep 1
    1.32 +	fi
    1.33 +    done
    1.34 +
    1.35 +    if [ ${i} -eq ${maxtries} ] ; then echo '(link isnt in running state)' ; fi
    1.36 +
    1.37 +    add_to_bridge ${bridge} ${dev}
    1.38 +}
    1.39 +
    1.40  case "$command" in
    1.41      start)
    1.42  	op_start