OpenVZ Forum


Home » General » Support » multiple veth Network configuration with vlan and bridge
icon5.gif  multiple veth Network configuration with vlan and bridge [message #24978] Wed, 12 December 2007 17:16 Go to next message
mistur is currently offline  mistur
Messages: 18
Registered: December 2007
Location: Paris
Junior Member

Hi all,

I've post this on the user mailing list as well, but I think it should be better here, if not, you can delete this message.

I'm currently working on a xen to openvz migration and some I have problem to setup the network configuration.

I'm using the lastest kernel patch build to support nfsroot for the openvz host under ubuntu dapper 6.06 LTS

I will have at least 12 vlan on the OVZ host, and 2 or 3 vlan in each VE

for example, NETIF for the VEID 101

NETIF="ifname=eth1.10,mac=00:16:3E:00:00:1E,host_ifname=veth101.10,host_mac=00:E0:81:4B:2F:DB;ifname=eth1.19,mac=00:16:3E:00:00:1E,host_ifname=veth101&.19,host_mac=00:E0:81:4B:2F:DB"


and I want an EXTERNAL_SCRIPT that check if the bridge exist, and if not create and add the interface

my first idea was adding a new variable that indicate all the vlan we have to configure :

VETH_BRIDGE="brvlan10 brvlan19"

with this script :

#!/bin/bash
# /usr/sbin/vznetaddroute
# a script to bring up virtual network interfaces (veth's) in a VE
CONFIGFILE=/etc/vz/conf/$VEID.conf
. $CONFIGFILE
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\)\..*,.*$/\1/g'`

for BRIDGE in ${VETH_BRIDGE} ; do

        VLAN=`echo ${BRIDGE} | sed 's/brvlan//'`

        if [ ! -n "${VZHOSTIF}.${VLAN}" ]; then
                echo "According to $CONFIGFILE VE$VEID has no veth interface configured."
                exit 1
        fi

        if [ ! -n "${BRIDGE}" ]; then
           echo "According to $CONFIGFILE VE$VEID has no veth bridge configured."
           exit 1
        fi

        echo "Adding interface ${VZHOSTIF}.${VLAN} to bridge ${BRIDGE} on VE0"

        if [ -z "`/usr/sbin/brctl show | /bin/grep ${BRIDGE}`" ]; then
           /usr/sbin/brctl addbr ${BRIDGE}
           /usr/sbin/brctl addif ${BRIDGE} eth1.${VLAN}
           /sbin/ip link set ${BRIDGE} up
        fi

        /usr/sbin/brctl addif ${BRIDGE} ${VZHOSTIF}.${VLAN}
        /sbin/ip link set ${VZHOSTIF}.${VLAN} up
done

exit 0

When I start my VE, I have :

# vzctl start 101
Starting VE ...
VE is mounted
Setting CPU limit: 241132
Setting CPU units: 55555
Configure meminfo: 502650
Set hostname: adviseo03
Configure veth devices: veth101.10 veth101.19
Adding interface veth101.10 to bridge brvlan10 on VE0
Adding interface veth101.19 to bridge brvlan19 on VE0
interface veth101.19 does not exist!
SIOCGIFFLAGS: No such device
Adding interface veth101.10 to bridge brvlan10 on VE0
device veth101.10 is already a member of a bridge; can't enslave it to bridge brvlan10.
Adding interface veth101.19 to bridge brvlan19 on VE0
VE start in progress...


so at start vzctl already know we will have 2 net device : "Configure veth devices: veth101.10 veth101.19"

so the EXTERNAL_SCRIPT is execute 2 times, one time for each veth, so I shouldn't need to setup VETH_BRIDGE if in the EXTERNAL_SCRIPT, I'm able to know with veth is currently configured

It's not easy to explain until it is still quite complicated for me

so the question is :

is it possible to know in the EXTERNAL_SCRIPT, for which interface, the script is execute ?

thanks for your help

Yoann

Re: multiple veth Network configuration with vlan and bridge [message #24983 is a reply to message #24978] Wed, 12 December 2007 17:56 Go to previous message
mistur is currently offline  mistur
Messages: 18
Registered: December 2007
Location: Paris
Junior Member

mistur wrote on Wed, 12 December 2007 18:16

is it possible to know in the EXTERNAL_SCRIPT, for which interface, the script is execute ?



Well, I gave a look to the source code and got my answer ($3)... it's working perfectly.

NETIF still the same :

NETIF="ifname=eth1.10,mac=00:16:3E:00:00:1E,host_ifname=veth10.10,host_mac=00:E0:81:4B:2F:DB;ifname=eth1.19,mac=00:16:3E:00:00:1E,host_ifname=veth10.19,host_mac=00:E0:81:4B:2F:DB"


and the script begin :

#!/bin/bash
# /usr/sbin/vznetaddroute
# a script to bring up virtual network interfaces (veth's) in a VE
CONFIGFILE=/etc/vz/conf/$VEID.conf
. $CONFIGFILE
VETH=$3
VZHOSTIF=`echo ${VETH} | cut -f1 -d"."`
VLAN=`echo ${VETH} | cut -f2 -d"."`
VETH_BRIDGE=brvlan${VLAN}

if [ ! -n "${VZHOSTIF}.${VLAN}" ]; then
        echo "According to $CONFIGFILE VE$VEID has no veth interface configured."
        exit 1
fi

if [ ! -n "${VETH_BRIDGE}" ]; then
   echo "According to $CONFIGFILE VE$VEID has no veth VETH_BRIDGE configured."
   exit 1
fi

echo "Adding interface ${VZHOSTIF}.${VLAN} to VETH_BRIDGE ${VETH_BRIDGE} on VE0"

if [ -z "`/usr/sbin/brctl show | /bin/grep ${VETH_BRIDGE}`" ]; then
   /usr/sbin/brctl addbr ${VETH_BRIDGE}
   /usr/sbin/brctl addif ${VETH_BRIDGE} eth1.${VLAN}
   /sbin/ip link set ${VETH_BRIDGE} up
fi

/usr/sbin/brctl addif ${VETH_BRIDGE} ${VZHOSTIF}.${VLAN}
/sbin/ip link set ${VZHOSTIF}.${VLAN} up
exit 0
---- END SCRIPT ----


sorry for the noise

Yoann
Previous Topic: Updated VPS will not start
Next Topic: *SOLVED* How ican hidden real ram for a server
Goto Forum:
  


Current Time: Fri Aug 09 20:31:49 GMT 2024

Total time taken to generate the page: 0.03253 seconds