All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] network-bridge script support for multiple external interfaces
@ 2005-10-14 13:23 Charles Duffy
  2005-10-14 17:02 ` David Hopwood
  0 siblings, 1 reply; 3+ messages in thread
From: Charles Duffy @ 2005-10-14 13:23 UTC (permalink / raw)
  To: xen-devel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] network-bridge script support for multiple external interfaces
  2005-10-14 13:23 [PATCH] network-bridge script support for multiple external interfaces Charles Duffy
@ 2005-10-14 17:02 ` David Hopwood
  2005-10-15  0:51   ` Charles Duffy
  0 siblings, 1 reply; 3+ messages in thread
From: David Hopwood @ 2005-10-14 17:02 UTC (permalink / raw)
  To: xen-devel

Charles Duffy wrote:
>  # antispoof  Whether to use iptables to prevent spoofing (default yes).
[...]
>  antispoof=${antispoof:-no}

The antispoof default is not consistent with the comment.

-- 
David Hopwood <david.nospam.hopwood@blueyonder.co.uk>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] network-bridge script support for multiple external interfaces
  2005-10-14 17:02 ` David Hopwood
@ 2005-10-15  0:51   ` Charles Duffy
  0 siblings, 0 replies; 3+ messages in thread
From: Charles Duffy @ 2005-10-15  0:51 UTC (permalink / raw)
  To: xen-devel

David Hopwood wrote:
> Charles Duffy wrote:
>>  # antispoof  Whether to use iptables to prevent spoofing (default yes).
> [...]
>>  antispoof=${antispoof:-no}
> 
> The antispoof default is not consistent with the comment.
> 

Quite so. (That's original behavior, though, and so any fix for it 
should be checked in as a separate changeset -- from my 
revision-control-nazi days I still have a strong preference for keeping 
different fixes in different changesets so that they can be merged, 
accepted or rejected, and otherwise handled individually).

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-10-15  0:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-14 13:23 [PATCH] network-bridge script support for multiple external interfaces Charles Duffy
2005-10-14 17:02 ` David Hopwood
2005-10-15  0:51   ` Charles Duffy

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.