On Wed, May 30, 2007 at 12:50:35PM +0100, Keir Fraser wrote:
>
> All applied now, thanks. Will you provide a patch to fix our network scripts
> to get rid of netloop setup, and remove netloop from our kernel patches (or
> at least disable in default configs)?
Here it is. BTW, the public xen-unstable tree is still dated May 17
so if any changes have been made since then in your tree then this may
not apply cleanly.
[NET] Remove netloop and make copy_skb the default
This patch changes the default setting of copy_skb to true.
It also removes the netloop device from the Xen bridge setup.
These two changes can be used without each other with little
impact. Having only the copy_skb change means a slight overhead
in that we may copy things twice. Having only the latter means
that packets may be held indefinitely in dom0. However, that
can already happen anyway for packets delayed on the way to a
physical NIC rather than delayed after going through netloop,
as well as setups which do not use bridging at all.
The scripts are partly based on work by Daniel P. Berrange.
Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff -r d83621c3a6cc linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Sun Jun 03
11:49:01 2007 +1000
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c Sun Jun 03
11:56:31 2007 +1000
@@ -124,7 +124,7 @@ static unsigned int alloc_index = 0;
static unsigned int alloc_index = 0;
/* Setting this allows the safe use of this driver without netloop. */
-static int MODPARM_copy_skb;
+static int MODPARM_copy_skb = 1;
module_param_named(copy_skb, MODPARM_copy_skb, bool, 0);
MODULE_PARM_DESC(copy_skb, "Copy data received from netfront without netloop");
diff -r d83621c3a6cc tools/examples/network-bridge
--- a/tools/examples/network-bridge Sun Jun 03 11:49:01 2007 +1000
+++ b/tools/examples/network-bridge Sun Jun 03 11:56:31 2007 +1000
@@ -5,9 +5,10 @@
# The script name to use is defined in /etc/xen/xend-config.sxp
# in the network-script field.
#
-# This script creates a bridge (default xenbr${vifnum}), adds a device
-# (default eth${vifnum}) to it, copies the IP addresses from the device
-# to the bridge and adjusts the routes accordingly.
+# This script creates a bridge (default ${netdev}), adds a device
+# (defaults to the device on the default gateway route) 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.
# However, some configurations are upset by this, especially
@@ -20,31 +21,27 @@
#
# Vars:
#
-# vifnum Virtual device number to use (default 0). Numbers >=8
-# require the netback driver to have nloopbacks set to a
-# higher value than its default of 8.
-# bridge The bridge to use (default xenbr${vifnum}).
-# netdev The interface to add to the bridge (default eth${vifnum}).
+# bridge The bridge to use (default ${netdev}).
+# netdev The interface to add to the bridge (default gateway device).
# antispoof Whether to use iptables to prevent spoofing (default no).
#
# Internal Vars:
# pdev="p${netdev}"
-# vdev="veth${vifnum}"
-# vif0="vif0.${vifnum}"
+# tdev=tmpbridge
#
# start:
-# Creates the bridge
-# Copies the IP and MAC addresses from netdev to vdev
+# Creates the bridge as tdev
+# Copies the IP and MAC addresses from pdev to bridge
# Renames netdev to be pdev
-# Renames vdev to be netdev
-# Enslaves pdev, vdev to bridge
+# Renames tdev to bridge
+# Enslaves pdev to bridge
#
# stop:
-# Removes netdev from the bridge
-# Transfers addresses, routes from netdev to pdev
-# Renames netdev to vdev
+# Removes pdev from the bridge
+# Transfers addresses, routes from bridge to pdev
+# Renames bridge to tdev
# Renames pdev to netdev
-# Deletes bridge
+# Deletes tdev
#
# status:
# Print addresses, interfaces, routes
@@ -59,15 +56,13 @@ findCommand "$@"
findCommand "$@"
evalVariables "$@"
-vifnum=${vifnum:-$(ip route list | awk '/^default / { print $NF }' | sed
's/^[^0-9]*//')}
-vifnum=${vifnum:-0}
-bridge=${bridge:-xenbr${vifnum}}
-netdev=${netdev:-eth${vifnum}}
+netdev=${netdev:-$(ip route list | awk '/^default / { print $NF }' |
+ sed 's/.* dev //')}
+bridge=${bridge:-${netdev}}
antispoof=${antispoof:-no}
pdev="p${netdev}"
-vdev="veth${vifnum}"
-vif0="vif0.${vifnum}"
+tdev=tmpbridge
get_ip_info() {
addr_pfx=`ip addr show dev $1 | egrep '^ *inet' | sed -e 's/ *inet //' -e
's/ .*//'`
@@ -157,7 +152,6 @@ antispoofing () {
iptables -P FORWARD DROP
iptables -F FORWARD
iptables -A FORWARD -m physdev --physdev-in ${pdev} -j ACCEPT
- iptables -A FORWARD -m physdev --physdev-in ${vif0} -j ACCEPT
}
# Usage: show_status dev bridge
@@ -184,53 +178,27 @@ op_start () {
fi
if link_exists "$pdev"; then
- # The device is already up.
- return
- fi
- if link_exists veth0 && ! link_exists "$vdev"; then
- 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
-may raise this limit by passing it as a parameter (nloopbacks=<N>); if the
-driver is compiled statically into the kernel, then you may set the parameter
-using netloop.nloopbacks=<N> on the domain 0 kernel command line.
-" >&2
- exit 1
- fi
-
- create_bridge ${bridge}
-
- if link_exists "$vdev"; then
- mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether
\(..:..:..:..:..:..\).*/\1/'`
- preiftransfer ${netdev}
- transfer_addrs ${netdev} ${vdev}
- if ! ifdown ${netdev}; then
- # If ifdown fails, remember the IP details.
- get_ip_info ${netdev}
- ip link set ${netdev} down
- ip addr flush ${netdev}
- fi
- ip link set ${netdev} name ${pdev}
- ip link set ${vdev} name ${netdev}
-
- setup_bridge_port ${pdev}
- setup_bridge_port ${vif0}
- ip link set ${netdev} addr ${mac} arp on
-
- ip link set ${bridge} up
- add_to_bridge ${bridge} ${vif0}
- add_to_bridge2 ${bridge} ${pdev}
- do_ifup ${netdev}
- else
- ip link set ${bridge} arp on
- ip link set ${bridge} multicast on
- # old style without ${vdev}
- transfer_addrs ${netdev} ${bridge}
- transfer_routes ${netdev} ${bridge}
- # Attach the real interface to the bridge.
- add_to_bridge ${bridge} ${netdev}
- fi
+ # The device is already up.
+ return
+ fi
+
+ create_bridge ${tdev}
+
+ preiftransfer ${netdev}
+ transfer_addrs ${netdev} ${tdev}
+ if ! ifdown ${netdev}; then
+ # If ifdown fails, remember the IP details.
+ get_ip_info ${netdev}
+ ip link set ${netdev} down
+ ip addr flush ${netdev}
+ fi
+ ip link set ${netdev} name ${pdev}
+ ip link set ${tdev} name ${bridge}
+
+ setup_bridge_port ${pdev}
+
+ add_to_bridge2 ${bridge} ${pdev}
+ do_ifup ${bridge}
if [ ${antispoof} = 'yes' ] ; then
antispoofing
@@ -245,31 +213,21 @@ op_stop () {
return
fi
- 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}
- if ! ifdown ${netdev}; then
- get_ip_info ${netdev}
- fi
- ip link set ${netdev} down arp off
- ip link set ${netdev} addr fe:ff:ff:ff:ff:ff
- ip link set ${pdev} down
- ip addr flush ${netdev}
- ip link set ${pdev} addr ${mac} arp on
-
- brctl delif ${bridge} ${pdev}
- brctl delif ${bridge} ${vif0}
- ip link set ${bridge} down
-
- ip link set ${netdev} name ${vdev}
- ip link set ${pdev} name ${netdev}
- do_ifup ${netdev}
- else
- transfer_routes ${bridge} ${netdev}
- ip link set ${bridge} down
- fi
- brctl delbr ${bridge}
+ transfer_addrs ${bridge} ${pdev}
+ if ! ifdown ${bridge}; then
+ get_ip_info ${bridge}
+ fi
+ ip link set ${pdev} down
+ ip addr flush ${bridge}
+
+ brctl delif ${bridge} ${pdev}
+ ip link set ${bridge} down
+
+ ip link set ${bridge} name ${tdev}
+ ip link set ${pdev} name ${netdev}
+ do_ifup ${netdev}
+
+ brctl delbr ${tdev}
}
# adds $dev to $bridge but waits for $dev to be in running state first
diff -r d83621c3a6cc tools/examples/vif-bridge
--- a/tools/examples/vif-bridge Sun Jun 03 11:49:01 2007 +1000
+++ b/tools/examples/vif-bridge Sun Jun 03 11:56:31 2007 +1000
@@ -44,6 +44,32 @@ then
then
fatal "Could not find bridge, and none was specified"
fi
+else
+ #
+ # Old style bridge setup with netloop, used to have a bridge name
+ # of xenbrX, enslaving pethX and vif0.X, and then configuring
+ # eth0.
+ #
+ # New style bridge setup does not use netloop, so the bridge name
+ # is ethX and the physical device is enslaved pethX
+ #
+ # So if...
+ #
+ # - User asks for xenbrX
+ # - AND xenbrX doesn't exist
+ # - AND there is a ethX device which is a bridge
+ #
+ # ..then we translate xenbrX to ethX
+ #
+ # This lets old config files work without modification
+ #
+ if [ ! -e "/sys/class/net/$bridge" ] && [ -z "${bridge##xenbr*}" ]
+ then
+ if [ -e "/sys/class/net/eth${bridge#xenbr}/bridge" ]
+ then
+ bridge="eth${bridge#xenbr}"
+ fi
+ fi
fi
RET=0
@@ -68,7 +94,7 @@ handle_iptable
handle_iptable
log debug "Successful vif-bridge $command for $vif, bridge $bridge."
-if [ "$command" = "online" ]
+if [ "$command" == "online" ]
then
success
fi
diff -r d83621c3a6cc tools/examples/xen-network-common.sh
--- a/tools/examples/xen-network-common.sh Sun Jun 03 11:49:01 2007 +1000
+++ b/tools/examples/xen-network-common.sh Sun Jun 03 11:56:31 2007 +1000
@@ -90,8 +90,6 @@ find_dhcpd_init_file()
}
# configure interfaces which act as pure bridge ports:
-# - make quiet: no arp, no multicast (ipv6 autoconf)
-# - set mac address to fe:ff:ff:ff:ff:ff
setup_bridge_port() {
local dev="$1"
@@ -99,9 +97,6 @@ setup_bridge_port() {
ip link set ${dev} down
# ... and configure it
- ip link set ${dev} arp off
- ip link set ${dev} multicast off
- ip link set ${dev} addr fe:ff:ff:ff:ff:ff
ip addr flush ${dev}
}
@@ -114,15 +109,7 @@ create_bridge () {
brctl addbr ${bridge}
brctl stp ${bridge} off
brctl setfd ${bridge} 0
- ip link set ${bridge} arp off
- ip link set ${bridge} multicast off
fi
-
- # A small MTU disables IPv6 (and therefore IPv6 addrconf).
- mtu=$(ip link show ${bridge} | sed -n 's/.* mtu \([0-9]\+\).*/\1/p')
- ip link set ${bridge} mtu 68
- ip link set ${bridge} up
- ip link set ${bridge} mtu ${mtu:-1500}
}
# Usage: add_to_bridge bridge dev
diff -r d83621c3a6cc tools/examples/xend-config.sxp
--- a/tools/examples/xend-config.sxp Sun Jun 03 11:49:01 2007 +1000
+++ b/tools/examples/xend-config.sxp Sun Jun 03 11:56:31 2007 +1000
@@ -116,9 +116,7 @@
##
# To bridge network traffic, like this:
#
-# dom0: fake eth0 -> vif0.0 -+
-# |
-# bridge -> real eth0 -> the network
+# dom0: ----------------- bridge -> real eth0 -> the network
# |
# domU: fake eth0 -> vifN.0 -+
#
diff -r d83621c3a6cc tools/ioemu/patches/qemu-target-i386-dm
--- a/tools/ioemu/patches/qemu-target-i386-dm Sun Jun 03 11:49:01 2007 +1000
+++ b/tools/ioemu/patches/qemu-target-i386-dm Sun Jun 03 11:56:31 2007 +1000
@@ -1405,8 +1405,8 @@ Index: ioemu/target-i386-dm/qemu-ifup
Index: ioemu/target-i386-dm/qemu-ifup
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ ioemu/target-i386-dm/qemu-ifup 2007-05-11 10:01:09.000000000 +0100
-@@ -0,0 +1,9 @@
++++ ioemu/target-i386-dm/qemu-ifup 2007-06-03 11:50:25.000000000 +1000
+@@ -0,0 +1,37 @@
+#!/bin/sh
+
+#. /etc/rc.d/init.d/functions
@@ -1414,5 +1414,33 @@ Index: ioemu/target-i386-dm/qemu-ifup
+
+echo 'config qemu network with xen bridge for ' $*
+
++bridge=$2
++
++#
++# Old style bridge setup with netloop, used to have a bridge name
++# of xenbrX, enslaving pethX and vif0.X, and then configuring
++# eth0.
++#
++# New style bridge setup does not use netloop, so the bridge name
++# is ethX and the physical device is enslaved pethX
++#
++# So if...
++#
++# - User asks for xenbrX
++# - AND xenbrX doesn't exist
++# - AND there is a ethX device which is a bridge
++#
++# ..then we translate xenbrX to ethX
++#
++# This lets old config files work without modification
++#
++if [ ! -e "/sys/class/net/$bridge" ] && [ -z "${bridge##xenbr*}" ]
++then
++ if [ -e "/sys/class/net/eth${bridge#xenbr}/bridge" ]
++ then
++ bridge="eth${bridge#xenbr}"
++ fi
++fi
++
+ifconfig $1 0.0.0.0 up
-+brctl addif $2 $1
++brctl addif $bridge $1
diff -r d83621c3a6cc tools/ioemu/target-i386-dm/qemu-ifup
--- a/tools/ioemu/target-i386-dm/qemu-ifup Sun Jun 03 11:49:01 2007 +1000
+++ b/tools/ioemu/target-i386-dm/qemu-ifup Sun Jun 03 11:56:31 2007 +1000
@@ -5,5 +5,33 @@
echo 'config qemu network with xen bridge for ' $*
+bridge=$2
+
+#
+# Old style bridge setup with netloop, used to have a bridge name
+# of xenbrX, enslaving pethX and vif0.X, and then configuring
+# eth0.
+#
+# New style bridge setup does not use netloop, so the bridge name
+# is ethX and the physical device is enslaved pethX
+#
+# So if...
+#
+# - User asks for xenbrX
+# - AND xenbrX doesn't exist
+# - AND there is a ethX device which is a bridge
+#
+# ..then we translate xenbrX to ethX
+#
+# This lets old config files work without modification
+#
+if [ ! -e "/sys/class/net/$bridge" ] && [ -z "${bridge##xenbr*}" ]
+then
+ if [ -e "/sys/class/net/eth${bridge#xenbr}/bridge" ]
+ then
+ bridge="eth${bridge#xenbr}"
+ fi
+fi
+
ifconfig $1 0.0.0.0 up
-brctl addif $2 $1
+brctl addif $bridge $1
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|