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

[Xen-changelog] [xen-unstable] hotplug: Avoid race condition when creating or destroying network bridges



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1268658995 0
# Node ID 9300248eaad2f82f997c06ae7305b50c85298751
# Parent  4152a3ce90a76c96b6c7540271595793ba510df2
hotplug: Avoid race condition when creating or destroying network bridges

I saw the following message when I created or destroyed two bridges by
using network-bridge script at same time.  Of course names of the
bridges are different.  But, a temporal name "tmpbridge" is used by
the script to create or destroy the bridges.  I think that the message
was shown by "tmpbridge".

  SIOCSIFNAME: File exists

This patch avoids race condition when creating or destroying the
bridges.

Signed-off-by: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
---
 tools/hotplug/Linux/network-bridge |   10 ++++++++++
 1 files changed, 10 insertions(+)

diff -r 4152a3ce90a7 -r 9300248eaad2 tools/hotplug/Linux/network-bridge
--- a/tools/hotplug/Linux/network-bridge        Thu Mar 11 17:40:35 2010 +0000
+++ b/tools/hotplug/Linux/network-bridge        Mon Mar 15 13:16:35 2010 +0000
@@ -50,8 +50,10 @@
 
 
 dir=$(dirname "$0")
+. "$dir/logging.sh"
 . "$dir/xen-script-common.sh"
 . "$dir/xen-network-common.sh"
+. "$dir/locking.sh"
 
 findCommand "$@"
 evalVariables "$@"
@@ -219,6 +221,8 @@ op_start () {
         return
     fi
 
+    claim_lock "network-bridge"
+
     create_bridge ${tdev}
 
     preiftransfer ${netdev}
@@ -249,6 +253,8 @@ op_start () {
     if [ ${antispoof} = 'yes' ] ; then
        antispoofing
     fi
+
+    release_lock "network-bridge"
 }
 
 op_stop () {
@@ -259,6 +265,8 @@ op_stop () {
        return
     fi
 
+    claim_lock "network-bridge"
+
     transfer_addrs ${bridge} ${pdev}
     if ! ifdown ${bridge}; then
        get_ip_info ${bridge}
@@ -274,6 +282,8 @@ op_stop () {
     do_ifup ${netdev}
 
     brctl delbr ${tdev}
+
+    release_lock "network-bridge"
 }
 
 # adds $dev to $bridge but waits for $dev to be in running state first

_______________________________________________
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®.