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

[xen master] tools/hotplug/Linux: add remove_from_bridge()



commit bb13d936d2500f303c8fbf9420da9ed340818294
Author:     Paul Durrant <pdurrant@xxxxxxxxxx>
AuthorDate: Tue Aug 11 09:01:57 2020 +0100
Commit:     Wei Liu <wl@xxxxxxx>
CommitDate: Thu Aug 27 10:04:10 2020 +0000

    tools/hotplug/Linux: add remove_from_bridge()
    
    This patch adds a remove_from_bridge() function into xen-network-common.sh
    to partner with the existing add_to_bridge() function. The vif-bridge
    script is then modified to use it.
    
    Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx>
    Acked-by: Wei Liu <wl@xxxxxxx>
---
 tools/hotplug/Linux/vif-bridge            |  7 +------
 tools/hotplug/Linux/xen-network-common.sh | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/tools/hotplug/Linux/vif-bridge b/tools/hotplug/Linux/vif-bridge
index e722090ca8..c3e409926d 100644
--- a/tools/hotplug/Linux/vif-bridge
+++ b/tools/hotplug/Linux/vif-bridge
@@ -84,12 +84,7 @@ case "$command" in
         ;;
 
     offline)
-        if which brctl >&/dev/null; then
-            do_without_error brctl delif "$bridge" "$dev"
-        else
-            do_without_error ip link set "$dev" nomaster
-        fi
-        do_without_error ifconfig "$dev" down
+        remove_from_bridge "$bridge" "$dev"
         ;;
 
     add)
diff --git a/tools/hotplug/Linux/xen-network-common.sh 
b/tools/hotplug/Linux/xen-network-common.sh
index ec3bd4ec4a..6a0904361f 100644
--- a/tools/hotplug/Linux/xen-network-common.sh
+++ b/tools/hotplug/Linux/xen-network-common.sh
@@ -141,6 +141,25 @@ add_to_bridge () {
     ip link set dev ${dev} up
 }
 
+remove_from_bridge () {
+    local bridge=$1
+    local dev=$2
+
+    do_without_error ip link set dev ${dev} down
+
+    # Don't remove $dev from $bridge if it's not on the bridge.
+    if [ -e "/sys/class/net/${bridge}/brif/${dev}" ]; then
+        log debug "removing $dev from bridge $bridge"
+        if which brctl >&/dev/null; then
+            do_without_error brctl delif ${bridge} ${dev}
+        else
+            do_without_error ip link set ${dev} nomaster
+        fi
+    else
+        log debug "$dev not on bridge $bridge"
+    fi
+}
+
 # Usage: set_mtu bridge dev
 set_mtu () {
     local bridge=$1
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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