All of lore.kernel.org
 help / color / mirror / Atom feed
From: Charles Duffy <cduffy@spamcop.net>
To: xen-devel@lists.xensource.com
Subject: [PATCH] network-bridge script support for multiple external interfaces
Date: Fri, 14 Oct 2005 08:23:17 -0500	[thread overview]
Message-ID: <diobg9$2ri$1@sea.gmane.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 550 bytes --]

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.

[-- Attachment #2: xen-unstable-multibridge-support.patch --]
[-- Type: text/x-patch, Size: 4064 bytes --]

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}

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

             reply	other threads:[~2005-10-14 13:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-14 13:23 Charles Duffy [this message]
2005-10-14 17:02 ` [PATCH] network-bridge script support for multiple external interfaces David Hopwood
2005-10-15  0:51   ` Charles Duffy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='diobg9$2ri$1@sea.gmane.org' \
    --to=cduffy@spamcop.net \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.