OpenVZ Forum


Home » General » Support » howto auto add VE veth to a HN bridge upon VE startup?[Solved]
howto auto add VE veth to a HN bridge upon VE startup?[Solved] [message #16419] Wed, 05 September 2007 19:13 Go to next message
piavlo is currently offline  piavlo
Messages: 159
Registered: January 2007
Senior Member
I have one specific VE with veth device, i want
that during this VE startup ,after the veth device is created,
on VE0 (i.e. HN) this veth will be added as bridge interface.
This should happen before the internal VE network ralter init.d scripts are started.

All I've found is POST_CREATE parameter which points
/etc/vz/dists/scripts/postcreate.sh which is run in VE0,
but is' unclear to me what runs first the postcreate.sh in VE0
or the specific VE init.d scripts?

Also on gentoo wiki i found a similar way to auto mount/umount
partitions then VE starts up with /etc/vz/conf/vps.mount and
/etc/vz/conf/vps.umount or <VPS-ID>.mount and <VPS-ID>.umount
scripts (did not find a detailed info on how this works)
Maybe there is a similar way to auto add veth VE device to VE0 bridge?

Thanks
Alex

[Updated on: Mon, 17 September 2007 11:29]

Report message to a moderator

Re: howto auto add VE veth to a HN bridge upon VE startup? [message #16426 is a reply to message #16419] Thu, 06 September 2007 10:19 Go to previous messageGo to next message
xinhes is currently offline  xinhes
Messages: 6
Registered: August 2006
Location: Sundsvall, Sweden
Junior Member
Yes there is a similar interface. But oddly it's not constructed in exactly the same way as vps.mount/vps.umount. There might be some reason for this that I don't know.

I would have liked something like vps.ifup vps.ifdown where you can add your own stuff (per interface which is $1 to the script) like "brctl addif <bridge> $1"

Instructions on how to use the startup mechanisms can be found here: http://wiki.openvz.org/Virtual_Ethernet_device

Basically you have to create a script to do your stuff and add this script to the file: /etc/vz/vznet.conf like this:
#!/bin/bash
EXTERNAL_SCRIPT="/etc/sysconfig/vz-scripts/veth.ifup"

I tried to add this to vps.mount but oddly enough vps.mount is run before any virtual ethernet devices are created.

/Hans Eric Sandström

Re: howto auto add VE veth to a HN bridge upon VE startup? [message #16429 is a reply to message #16426] Thu, 06 September 2007 11:53 Go to previous messageGo to next message
piavlo is currently offline  piavlo
Messages: 159
Registered: January 2007
Senior Member
Hi Hans,

I've tried the /etc/vz/vznet.conf with custom script which adds the vnet to bridge, and it works, but for some strange reason the VE network is not working, while all network devices and conf seem to be setup correctly.

If instead i start without /etc/vz/vznet.conf
vzctl start 101

and then manually add veth to bridge
brctl addif dmzbr0 veth101.0

the VE network works ok
While the VE routing table & interfaces & HN interfaces
are exactly the same in both cases.

Maybe the /etc/vz/vznet.conf also removes some setup functionality then it is enabled?

Thanks
Alex
Re: howto auto add VE veth to a HN bridge upon VE startup? [message #16437 is a reply to message #16429] Thu, 06 September 2007 14:40 Go to previous messageGo to next message
khorenko is currently offline  khorenko
Messages: 533
Registered: January 2006
Location: Moscow, Russia
Senior Member
Hi Alex,

sorry for the intrusion, i just wonder if you just took the script example from
http://wiki.openvz.org/Virtual_Ethernet_device#Making_a_veth -device_persistent

If yes, i just realized that it simply doesn't add any veth to any bridge. Can you check?

If i'm wrong and you still haven't resolve this, could you please post here VE config, /etc/vz/vznet.conf and a custom script you use?

Thank you,
Konstantin.


If your problem is solved - please, report it!
It's even more important than reporting the problem itself...
Re: howto auto add VE veth to a HN bridge upon VE startup? [message #16447 is a reply to message #16419] Thu, 06 September 2007 18:26 Go to previous messageGo to next message
piavlo is currently offline  piavlo
Messages: 159
Registered: January 2007
Senior Member
/etc/vz/vznet.conf
#!/bin/bash
EXTERNAL_SCRIPT="/etc/vz/veth.bridge.addif"

/etc/vz/veth.bridge.addif
#!/bin/bash

CONFIGFILE=/etc/vz/conf/$VEID.conf
. $CONFIGFILE
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\),.*$/\1/g'`

if [ "$VEID" == "101" ]; then

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

        brctl addif dmzbr0 veth${VEID}.0
        exit $?
fi

exit 0


After the VE 101 is started the bridge has veth101.0
# brctl show
bridge name     bridge id               STP enabled     interfaces
dmzbr0          8000.00123456789a       no              eth2
                                                        veth101.0


The commands netstat -rn & ifconfig -a both in VE and HN return identical output in both cases (then veth is added to bridge by vznet.conf & then instead it is added manually after VE startup with vznet.conf disabled)
But the networking works only in the latter case with vznet.conf disabled Shocked
Which is very strange and the only reason i can think of is that then the vznet.conf is enabled some internal vz net setup functionality gets disabled.

ps. by the way i tried vznet.conf without EXTERNAL_SCRIPT
like this
#!/bin/bash

CONFIGFILE=/etc/vz/conf/$VEID.conf
. $CONFIGFILE
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\),.*$/\1/g'`

if [ "$VEID" == "101" ]; then

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

        brctl addif dmzbr0 veth${VEID}.0
        exit $?
fi

exit 0
Which gives the same result as with EXTERNAL_SCRIPT
So i wonder why is there a need for EXTERNAL_SCRIPT in vznet.conf
if the device setup can be done just directly in vznet.conf
without any EXTERNAL_SCRIPT indirection script?
Re: howto auto add VE veth to a HN bridge upon VE startup? [message #16471 is a reply to message #16447] Fri, 07 September 2007 18:29 Go to previous messageGo to next message
piavlo is currently offline  piavlo
Messages: 159
Registered: January 2007
Senior Member
Maybe one of the devs has an idea what might be wrong?
This the only problem preventing me on putting the system in poroduction.

piavlo wrote on Thu, 06 September 2007 21:26

/etc/vz/vznet.conf
#!/bin/bash
EXTERNAL_SCRIPT="/etc/vz/veth.bridge.addif"

/etc/vz/veth.bridge.addif
#!/bin/bash

CONFIGFILE=/etc/vz/conf/$VEID.conf
. $CONFIGFILE
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\),.*$/\1/g'`

if [ "$VEID" == "101" ]; then

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

        brctl addif dmzbr0 veth${VEID}.0
        exit $?
fi

exit 0


After the VE 101 is started the bridge has veth101.0
# brctl show
bridge name     bridge id               STP enabled     interfaces
dmzbr0          8000.00123456789a       no              eth2
                                                        veth101.0


The commands netstat -rn & ifconfig -a both in VE and HN return identical output in both cases (then veth is added to bridge by vznet.conf & then instead it is added manually after VE startup with vznet.conf disabled)
But the networking works only in the latter case with vznet.conf disabled Shocked
Which is very strange and the only reason i can think of is that then the vznet.conf is enabled some internal vz net setup functionality gets disabled.

ps. by the way i tried vznet.conf without EXTERNAL_SCRIPT
like this
#!/bin/bash

CONFIGFILE=/etc/vz/conf/$VEID.conf
. $CONFIGFILE
VZHOSTIF=`echo $NETIF |sed 's/^.*host_ifname=\(.*\),.*$/\1/g'`

if [ "$VEID" == "101" ]; then

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

        brctl addif dmzbr0 veth${VEID}.0
        exit $?
fi

exit 0
Which gives the same result as with EXTERNAL_SCRIPT
So i wonder why is there a need for EXTERNAL_SCRIPT in vznet.conf
if the device setup can be done just directly in vznet.conf
without any EXTERNAL_SCRIPT indirection script?

Re: howto auto add VE veth to a HN bridge upon VE startup? [message #16493 is a reply to message #16471] Sun, 09 September 2007 17:57 Go to previous messageGo to next message
piavlo is currently offline  piavlo
Messages: 159
Registered: January 2007
Senior Member
bump
Re: howto auto add VE veth to a HN bridge upon VE startup? [message #20062 is a reply to message #16419] Tue, 11 September 2007 18:38 Go to previous messageGo to next message
piavlo is currently offline  piavlo
Messages: 159
Registered: January 2007
Senior Member
up
Re: howto auto add VE veth to a HN bridge upon VE startup? [message #20225 is a reply to message #20062] Thu, 13 September 2007 13:30 Go to previous messageGo to next message
khorenko is currently offline  khorenko
Messages: 533
Registered: January 2006
Location: Moscow, Russia
Senior Member
ok, i have good news for you.
When you add a veth device to the bridge manually it (veth101.0 interface) is already in the UP state.
At the same time when the script /etc/vz/veth.bridge.addif runs veth101.0 is still down cause avahi-daemon hasn't brought it UP yet. Thus brctl adds downed interface into the bridge and that's why veth doesn't work.

To correct this it's enough to add a line to the /etc/vz/veth.bridge.addif:

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

+       ifconfig veth${VEID}.0 0
        brctl addif dmzbr0 veth${VEID}.0
        exit $?


If your problem is solved - please, report it!
It's even more important than reporting the problem itself...
Re: howto auto add VE veth to a HN bridge upon VE startup? [message #20316 is a reply to message #20225] Sun, 16 September 2007 11:37 Go to previous messageGo to next message
piavlo is currently offline  piavlo
Messages: 159
Registered: January 2007
Senior Member
finist wrote on Thu, 13 September 2007 16:30

ok, i have good news for you.
When you add a veth device to the bridge manually it (veth101.0 interface) is already in the UP state.

Yes indeed i did not notice that the veth device was in DOWN state, now it work. Thanks a lot.
Quote:

At the same time when the script /etc/vz/veth.bridge.addif runs veth101.0 is still down cause avahi-daemon hasn't brought it UP yet. Thus brctl adds downed interface into the bridge and that's why veth doesn't work.

I don't use avahi at all, so it would be good to know why when
the vznet.conf is used veth ends up in DOWN state?
Or more correctly that setup functionality is removed then vznet.conf is used?

Thanks
Re: howto auto add VE veth to a HN bridge upon VE startup? [message #20319 is a reply to message #20316] Sun, 16 September 2007 12:07 Go to previous messageGo to next message
piavlo is currently offline  piavlo
Messages: 159
Registered: January 2007
Senior Member
OK just found out the vznetcfg script which sources the vznet.conf file, and runs EXTERNAL_SCRIPT prior to bringing the veth device up.
IMHO the vznetcfg script should be modified upstream to use
EXTERNAL_SCRIPT_PREUP and EXTERNAL_SCRIPT_POSTUP instead of just
EXTERNAL_SCRIPT to allow more granularity in configuring the
network devices.

Alex
Re: howto auto add VE veth to a HN bridge upon VE startup? [message #20358 is a reply to message #20319] Mon, 17 September 2007 09:29 Go to previous messageGo to next message
khorenko is currently offline  khorenko
Messages: 533
Registered: January 2006
Location: Moscow, Russia
Senior Member
piavlo wrote on Sun, 16 September 2007 16:07

OK just found out the vznetcfg script which sources the vznet.conf file, and runs EXTERNAL_SCRIPT prior to bringing the veth device up.


Alex, you are right that vznetcfg brings up the veth device in case of EXTERNAL_SCRIPT variable is empty. But it doesn't run EXTERNAL_SCRIPT _prior_ to bringing the veth device up, if EXTERNAL_SCRIPT is filled it (EXTERNAL_SCRIPT) is executed instead of vznetcfg normal configuration. It was by design - in theory the administrator can write down his own network start up script and it should not depend on what vznetcfg does (cause it can and i suppose it will change its behaviour).

Konstantin.


If your problem is solved - please, report it!
It's even more important than reporting the problem itself...
Re: howto auto add VE veth to a HN bridge upon VE startup? [message #20359 is a reply to message #20358] Mon, 17 September 2007 09:39 Go to previous message
piavlo is currently offline  piavlo
Messages: 159
Registered: January 2007
Senior Member
finist wrote on Mon, 17 September 2007 11:29

piavlo wrote on Sun, 16 September 2007 16:07

OK just found out the vznetcfg script which sources the vznet.conf file, and runs EXTERNAL_SCRIPT prior to bringing the veth device up.


Alex, you are right that vznetcfg brings up the veth device in case of EXTERNAL_SCRIPT variable is empty. But it doesn't run EXTERNAL_SCRIPT _prior_ to bringing the veth device up, if EXTERNAL_SCRIPT is filled it (EXTERNAL_SCRIPT) is executed instead of vznetcfg normal configuration. It was by design - in theory the administrator can write down his own network start up script and it should not depend on what vznetcfg does (cause it can and i suppose it will change its behaviour).

Konstantin.


Yes of course you are right , in a rush i did not notice the exec in exec ${EXTERNAL_SCRIPT} $@

Thanks
Previous Topic: Audit issues
Next Topic: private vs root
Goto Forum:
  


Current Time: Sat May 18 04:13:02 GMT 2024

Total time taken to generate the page: 0.00502 seconds