Skip to contentSkip to conversation

Avoid race condition when creating or destroying network bridges

PATCH New Masaki Kanno 1 participant 1 message Mar 12, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Avoid race condition when creating or destroying network bridges

Hi,

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.

Best regards,
Kan

tools/hotplug/Linux/network-bridge +10 -0
diff -r 132ac04cbdba tools/hotplug/Linux/network-bridge
@@ -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 @@
         return
     fi
 
+    claim_lock "network-bridge"
+
     create_bridge ${tdev}
 
     preiftransfer ${netdev}
@@ -249,6 +253,8 @@
     if [ ${antispoof} = 'yes' ] ; then
 	antispoofing
     fi
+
+    release_lock "network-bridge"
 }
 
 op_stop () {
@@ -259,6 +265,8 @@
 	return
     fi
 
+    claim_lock "network-bridge"
+
     transfer_addrs ${bridge} ${pdev}
     if ! ifdown ${bridge}; then
 	get_ip_info ${bridge}
@@ -274,6 +282,8 @@
     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-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel