AW: AW: [Users] Multiple bridge support
Dietmar Maurer
dietmar at proxmox.com
Thu Jul 3 08:30:59 EDT 2008
Hi Kir,
> Von: Kir Kolyshkin [mailto:kir at openvz.org]
> Gesendet: Donnerstag, 03. Juli 2008 13:35
> An: users at openvz.org; Dietmar Maurer
> Betreff: Re: AW: [Users] Multiple bridge support
>
> How do you invoke it? Using EXTERNAL_SCRIPT?
>
> Would be good to have a patch adding (conditional?)
> invocation of vznetaddbr to vznetcfg.
One idea was to add a new global option in vz.conf:
DEF_BRIDGE=XXXX
If set, we automatically setup the bridge (we need to pass an additional
parameter to vznetcfg, but i guess thats no problem at all). That also
avoid a hardcoded default bridge name (vmbr0).
Here is the totally untested code. If you like the idea I will test it
;-)
---------------------------------------
#!/bin/sh
CONFIGFILE='@PKGCONFDIR@/vz.conf'
[ -f "$CONFIGFILE" ] &&. $CONFIGFILE
VZNETCFG='@PKGCONFDIR@/vznet.conf'
[ -f "$VZNETCFG" ] && . "$VZNETCFG"
usage()
{
echo >&2 "vznetcfg init veth <dev> [<bridge>]"
}
init_veth()
{
local dev="$1"
local bridge="$2"
if [ -n "$DEV_BRIDGE" ]; then
if [ ! -n "$bridge" ]; then
bridge=$DEV_BRIDGE
fi
echo "Adding interface $dev to bridge $bridge on CT0 for
CT$VEID"
/sbin/ifconfig $dev 0
echo 1 > /proc/sys/net/ipv4/conf/$dev/proxy_arp
echo 1 > /proc/sys/net/ipv4/conf/$dev/forwarding
/usr/sbin/brctl addif $bridge $dev
else
ip link set "$dev" up
fi
}
# Call the external script if defined
if [ -n "$EXTERNAL_SCRIPT" -a -x "$EXTERNAL_SCRIPT" ]; then
export VEID
exec "$EXTERNAL_SCRIPT" $@
fi
if test $# -le 2; then
usage
exit 0
fi
CMD="$1"
case "$CMD$2" in
initveth)
if test $# -le 3; then
usage
exit 1
fi
init_veth "$3" "$4"
;;
*)
echo "invalid action"
exit 1
;;
esac
exit 0
More information about the Users
mailing list