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

[Xen-changelog] Poll for peth0 coming up before trying to attach it to the bridge. This fixes



# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 40bb46f599d93a8605740bc5800d5e61d8cc1198
# Parent  991ccc24bf2e437fff0e45c490692f9ca239509e
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@xxxxxxxxxxxxx>

diff -r 991ccc24bf2e -r 40bb46f599d9 tools/examples/network-bridge
--- a/tools/examples/network-bridge     Tue Jan 10 15:05:05 2006
+++ b/tools/examples/network-bridge     Tue Jan 10 15:21:00 2006
@@ -242,10 +242,10 @@
        ip addr flush ${pdev}
        ip link set ${netdev} addr ${mac} arp on
        add_to_bridge ${bridge} ${vif0}
-       add_to_bridge ${bridge} ${pdev}
        ip link set ${bridge} up
        ip link set ${vif0} up
        ip link set ${pdev} up
+       add_to_bridge2 ${bridge} ${pdev}
        do_ifup ${netdev}
     else
        # old style without ${vdev}
@@ -293,6 +293,27 @@
     brctl delbr ${bridge}
 }
 
+# adds $dev to $bridge but waits for $dev to be in running state first
+add_to_bridge2() {
+    local bridge=$1
+    local dev=$2
+    local maxtries=10
+
+    echo -n "Waiting for ${dev} to negotiate link."
+    for i in `seq ${maxtries}` ; do
+       if ifconfig ${dev} | grep -q RUNNING ; then
+           break
+       else
+           echo -n '.'
+           sleep 1
+       fi
+    done
+
+    if [ ${i} -eq ${maxtries} ] ; then echo '(link isnt in running state)' ; fi
+
+    add_to_bridge ${bridge} ${dev}
+}
+
 case "$command" in
     start)
        op_start

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.