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-devel

[Xen-devel] [PATCH] network-bridge script support for multiple external

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] network-bridge script support for multiple external interfaces
From: Charles Duffy <cduffy@xxxxxxxxxxx>
Date: Fri, 14 Oct 2005 08:23:17 -0500
Delivery-date: Fri, 14 Oct 2005 13:24:35 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050716)
The attached patch allows the network-bridge script to be used to generate multiple bridges corresponding to different physical interfaces. It adds a new parameter, "virtnum", used to refer both to the loopback interface to be used and to set defaults regarding the physical interface and bridge name.

Thus, if one wishes to start xen-br0 on eth0 and xen-br1 on eth1, one need only call:

network-bridge start ## virtnum is 0 by default
network-bridge start virtnum=1

...well, that and set loopback.nloopbacks=2 in the Dom0 kernel parameters.
diff -r 70aa62954e91 tools/examples/network-bridge
--- a/tools/examples/network-bridge     Fri Oct 14 00:42:34 2005
+++ b/tools/examples/network-bridge     Fri Oct 14 08:13:17 2005
@@ -5,8 +5,8 @@
 # The script name to use is defined in /etc/xen/xend-config.sxp
 # in the network-script field.
 #
-# This script creates a bridge (default xen-br0), adds a device
-# (default eth0) to it, copies the IP addresses from the device
+# This script creates a bridge (default xen-br${virtnum}), adds a device
+# (default eth${virtnum}) to it, copies the IP addresses from the device
 # to the bridge and adjusts the routes accordingly.
 #
 # If all goes well, this should ensure that networking stays up.
@@ -20,8 +20,11 @@
 #
 # Vars:
 #
-# bridge     The bridge to use (default xen-br0).
-# netdev     The interface to add to the bridge (default eth0).
+# virtnum    Virtual device number to use (default 0). Numbers >=1
+#            require the netback driver to have nloopbacks set to a
+#            higher value than its default of 1.
+# bridge     The bridge to use (default xen-br${virtnum}).
+# netdev     The interface to add to the bridge (default eth${virtnum}).
 # antispoof  Whether to use iptables to prevent spoofing (default yes).
 #
 # start:
@@ -60,11 +63,12 @@
 # Pull variables in args in to environment.
 for arg ; do export "${arg}" ; done
 
-bridge=${bridge:-xen-br0}
-netdev=${netdev:-eth0}
+virtnum=${virtnum:-0}
+bridge=${bridge:-xen-br${virtnum}}
+netdev=${netdev:-eth${virtnum}}
 antispoof=${antispoof:-no}
 
-echo "*network $OP bridge=$bridge netdev=$netdev antispoof=$antispoof" >&2
+echo "*network $OP bridge=$bridge netdev=$netdev antispoof=$antispoof 
virtnum=$virtnum" >&2
 
 # Usage: transfer_addrs src dst
 # Copy all IP addresses (including aliases) from device $src to device $dst.
@@ -182,11 +186,11 @@
 
     create_bridge ${bridge}
 
-    if ifconfig 2>/dev/null | grep -q veth0 ; then
-        return
-    fi
-
-    if ifconfig veth0 2>/dev/null | grep -q veth0 ; then
+    if ifconfig 2>/dev/null | grep -q veth${virtnum} ; then
+        return
+    fi
+
+    if ifconfig veth${virtnum} 2>/dev/null | grep -q veth${virtnum} ; then
        mac=`ifconfig ${netdev} | grep HWadd | sed -e 
's/.*\(..:..:..:..:..:..\).*/\1/'`
        if ! ifdown ${netdev} ; then
                # if ifup didn't work, see if we have an ip= on cmd line
@@ -199,14 +203,14 @@
                fi
        fi
        ip link set ${netdev} name p${netdev}
-       ip link set veth0 name ${netdev}
+       ip link set veth${virtnum} name ${netdev}
        ifconfig p${netdev} 0.0.0.0 -arp down
        ifconfig p${netdev} hw ether fe:ff:ff:ff:ff:ff
        ifconfig ${netdev} hw ether ${mac}
-       add_to_bridge ${bridge} vif0.0
+       add_to_bridge ${bridge} vif0.${virtnum}
        add_to_bridge ${bridge} p${netdev}
        ip link set ${bridge} up
-       ip link set vif0.0 up
+       ip link set vif0.${virtnum} up
        ip link set p${netdev} up
        if ! ifup ${netdev} ; then
                if [ ${kip} ] ; then
@@ -218,7 +222,7 @@
                fi
         fi
     else
-       # old style without veth0
+       # old style without veth${virtnum}
        transfer_addrs ${netdev} ${bridge}
         transfer_routes ${netdev} ${bridge}
     fi
@@ -233,10 +237,10 @@
         return
     fi
 
-    if ifconfig peth0 2>/dev/null | grep -q peth0 ; then
-
-        ifconfig vif0.0 down
-        mac=`ifconfig eth0 | grep HWadd | \
+    if ifconfig peth${virtnum} 2>/dev/null | grep -q peth${virtnum} ; then
+
+        ifconfig vif0.${virtnum} down
+        mac=`ifconfig eth${virtnum} | grep HWadd | \
             sed -e 's/.*\(..:..:..:..:..:..\).*/\1/'`
         ifconfig ${netdev} 0.0.0.0 down
         ifconfig ${netdev} hw ether fe:ff:ff:ff:ff:ff
@@ -245,11 +249,11 @@
         ifconfig p${netdev} hw ether ${mac} arp 
         brctl delif ${bridge} p${netdev}
 
-        ip link set eth0 name veth0
-        ip link set peth0 name eth0
+        ip link set eth${virtnum} name veth${virtnum}
+        ip link set peth${virtnum} name eth${virtnum}
         ifconfig ${bridge} down
         brctl delbr ${bridge}
-        ifup eth0
+        ifup eth${virtnum}
 
     else
         transfer_routes ${bridge} ${netdev}
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>