On Tue, Mar 15, 2005 at 11:32:13PM +0100, Quentin Garnier wrote: [...] > FWIW, this afternoon when I could take a try at booting a domU, I used a > modified vif-bridge script to do bridging by doing this: > > vif = [ 'mac=lalala, bridge=bridge:bridge0:fxp0' ] > > The meaning of the bridge parameter is the following: first it starts > with bridge to distinguish between plain ifconfig case and bridge case, > then it bridges the vif interface with fxp0 on bridge0, creating it if > necessary. I'll send it tomorrow if you want. Here it is. Nothing complicated. Arguably, the interface should be removed from the bridge at down time. -- Quentin Garnier - cube%cubidou.net@localhost - cube%NetBSD.org@localhost "When I find the controls, I'll go where I like, I'll know where I want to be, but maybe for now I'll stay right here on a silent sea." KT Tunstall, Silent Sea, Eye to the Telescope, 2004.
#!/bin/sh
#============================================================================
# /etc/xen/vif-bridge
#
# Script for configuring a vif.
# Xend calls a vif script when configuring a vif up or down.
# This script is the default - but it can be configured for each vif.
#
# Example invocation:
#
# vif-bridge up domain=VM1 vif=vif1.0 bridge=xen-br0 mac=aa:00:00:50:02:f0
#
#
# Usage:
# vif-bridge (up|down) {VAR=VAL}*
#
# Vars:
#
# domain name of the domain the interface is on (required).
# vif vif interface name (required).
# mac vif MAC address (required).
# bridge bridge to add the vif to (required).
#
#============================================================================
# Exit if anything goes wrong
set -e
#this will be logged in xend-debug.log
echo "vif-bridge $*"
# Operation name.
OP=$1
shift
# Pull variables in args into environment
for arg ; do export "${arg}" ; done
# Required parameters. Fail if not set.
domain=${domain:?}
vif=${vif:?}
mac=${mac:?}
bridge=${bridge:?}
# Are we going up or down?
case $OP in
up)
# ${bridge} contains ifconfig parameters in our case.
# It could also be parameters to brctl, or anything else we
# want.
# xend gives us vif?.? as interface name, but on NetBSD
# they're called xvif?.?
case ${bridge} in
bridge:*)
bgparam=${bridge#bridge:}
bgif=${bgparam%%:*}
lanif=${bgparam##*:}
if ! ifconfig -l | grep ${bgif} >/dev/null; then
ifconfig ${bgif} create
brconfig ${bgif} add ${lanif} up
fi
ifconfig x${vif} up
brconfig ${bgif} add x${vif} up
;;
*)
ifconfig x${vif} ${bridge}
;;
esac
exit 0
;;
down)
exit 0
;;
*)
echo 'Invalid command: ' $OP
echo 'Valid commands are: up, down'
exit 1
;;
esac
Attachment:
pgpjb5tHNke5K.pgp
Description: PGP signature