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

[xen master] tools/hotplug/Linux: re-factor add_to_bridge() in xen-network-common.sh



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

    tools/hotplug/Linux: re-factor add_to_bridge() in xen-network-common.sh
    
    Remove duplication of 'ip link set dev'. It is perfectly fine to call it
    even if the device has already been added to the bridge.
    
    NOTE: This patch also adds code to write a debug log entry if the device
          was already on the bridge.
    
    Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx>
    Acked-by: Wei Liu <wl@xxxxxxx>
---
 tools/hotplug/Linux/xen-network-common.sh | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/tools/hotplug/Linux/xen-network-common.sh 
b/tools/hotplug/Linux/xen-network-common.sh
index 8dd3a62068..ec3bd4ec4a 100644
--- a/tools/hotplug/Linux/xen-network-common.sh
+++ b/tools/hotplug/Linux/xen-network-common.sh
@@ -126,16 +126,18 @@ add_to_bridge () {
     local bridge=$1
     local dev=$2
 
-    # Don't add $dev to $bridge if it's already on a bridge.
-    if [ -e "/sys/class/net/${bridge}/brif/${dev}" ]; then
-       ip link set dev ${dev} up || true
-       return
-    fi
-    if which brctl >&/dev/null; then
-        brctl addif ${bridge} ${dev}
+    # Don't add $dev to $bridge if it's already on the bridge.
+    if [ ! -e "/sys/class/net/${bridge}/brif/${dev}" ]; then
+        log debug "adding $dev to bridge $bridge"
+        if which brctl >&/dev/null; then
+            brctl addif ${bridge} ${dev}
+        else
+            ip link set ${dev} master ${bridge}
+        fi
     else
-        ip link set ${dev} master ${bridge}
+        log debug "$dev already on bridge $bridge"
     fi
+
     ip link set dev ${dev} up
 }
 
--
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®.