WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Added link_exists function, for neatness. Check for the

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Added link_exists function, for neatness. Check for the existence of the pdev
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 15 Nov 2005 21:16:14 +0000
Delivery-date: Tue, 15 Nov 2005 21:17:35 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID bb270cb5d2e850aa4fef20902c4d54f9d916f1ff
# Parent  6d981d34cf52dc98a7bffcca9e90f7cde0ba88e2
Added link_exists function, for neatness.  Check for the existence of the pdev
before issuing the diagnostic about the missing vdev.  Having a pdev but no
vdev is a strong indicator that the network-bridge script has run once already,
and so there is nothing to worry about.  Having the vdev and no corresponding
pdev is still diagnosed.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r 6d981d34cf52 -r bb270cb5d2e8 tools/examples/network-bridge
--- a/tools/examples/network-bridge     Mon Nov 14 11:28:47 2005
+++ b/tools/examples/network-bridge     Tue Nov 15 14:54:51 2005
@@ -138,6 +138,23 @@
 }" | sh -e
 }
 
+
+##
+# link_exists interface
+#
+# Returns 0 if the interface named exists (whether up or down), 1 otherwise.
+#
+link_exists()
+{
+    if ip link show "$1" >&/dev/null
+    then
+        return 0
+    else
+        return 1
+    fi
+}
+
+
 # Usage: create_bridge bridge
 create_bridge () {
     local bridge=$1
@@ -193,8 +210,12 @@
        return
     fi
 
-    if ! ip link show 2>/dev/null | grep -q "^[0-9]*: ${vdev}"; then
-        echo "
+    if ! link_exists "$vdev"; then
+        if link_exists "$pdev"; then
+            # The device is already up.
+            return
+        else
+            echo "
 Link $vdev is missing.
 This may be because you have reached the limit of the number of interfaces
 that the loopback driver supports.  If the loopback driver is a module, you
@@ -202,12 +223,13 @@
 driver is compiled statically into the kernel, then you may set the parameter
 using loopback.nloopbacks=<N> on the domain 0 kernel command line.
 " >&2
-        exit 1
+            exit 1
+        fi
     fi
 
     create_bridge ${bridge}
 
-    if ip link show ${vdev} 2>/dev/null >/dev/null; then
+    if link_exists "$vdev"; then
        mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether 
\(..:..:..:..:..:..\).*/\1/'`
        preiftransfer ${netdev}
        transfer_addrs ${netdev} ${vdev}
@@ -260,11 +282,11 @@
     if [ "${bridge}" == "null" ]; then
        return
     fi
-    if ! ip link show ${bridge} >/dev/null 2>&1; then
+    if ! link_exists "$bridge"; then
        return
     fi
 
-    if ip link show ${pdev} 2>/dev/null >/dev/null; then
+    if link_exists "$pdev"; then
        ip link set dev ${vif0} down
        mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether 
\(..:..:..:..:..:..\).*/\1/'`
        transfer_addrs ${netdev} ${pdev}

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Added link_exists function, for neatness. Check for the existence of the pdev, Xen patchbot -unstable <=