I’ve been asked quite a bit about how I do our network setup with Ganeti. I admit that it did take me a bit to figure out a sane way to do it in Gentoo. Unfortunately (at least in baselayout-1.x) bringing up VLANs with bridge interfaces in Gentoo is rather a pain. What I’m about to describe is basically a hack and there’s probably a better way to do this. I hope it gets improved in baselayout-2.x but I haven’t had a chance to take a look. Please feel free to add comments on what you feel will work better.

The key problem I ran into was dealing with starting up the vlan interfaces first, then starting up the bridged interfaces in the correct order. Here’s a peek at the network config on one of our Ganeti hosts on Gentoo:

# bring up bridge interfaces manually after eth0 is up
postup() {
    local vlans="42 113"
    if [ "${IFACE}" = "eth0" ] ; then
        for vlan in $vlans ; do
            /etc/init.d/net.br${vlan} start
            if [ "${vlan}" = "113" ] ; then
                # make sure the bridges get going first
                sleep 10
            fi
        done
    fi
}
# bring down bridge interfaces first
predown() {
    local vlans="42 113"
    if [ "${IFACE}" = "eth0" ] ; then
        for vlan in $vlans ; do
            /etc/init.d/net.br${vlan} stop
        done
    fi
}

# Setup trunked VLANs
vlans_eth0="42 113"
config_eth0=( "null" )
vconfig_eth0=( "set_name_type VLAN_PLUS_VID_NO_PAD" )
config_vlan42=( "null" )
config_vlan113=( "null" )

# Bring up primary IP on eth0 via the bridged interface
bridge_br42="vlan42"
config_br42=( "10.18.0.150 netmask 255.255.254.0" )
routes_br42=( "default gw 10.18.0.1" )

# Setup bridged VLAN interfaces
bridge_br113="vlan113"
config_br113=( "null" )

# Backend drbd network
config_eth1=( "192.168.19.136 netmask 255.255.255.0" )

The latter portion of the config its fairly normal. I setup eth0 to null, set the VLAN’s to null, then I add settings to the bridge interfaces. In our case we have the IP for the node itself on br42. The rest of the VLAN’s are just set to null. Finally we setup the backend secondary IP.

The first part of the config is the “fun stuff”. In order for this to work you need to only add net.eth0 and net.eth1 to the default enabled level. The post_up() function will start the bridge interfaces after eth0 has started and iterates through the list of vlans/bridges. Since I’m using the bridge interface as the primary host connection, I added a simple sleep at the end to let it see the traffic first.

That’s it! A fun hack that seems to work. I would love to hear feedback on this :)

Be Sociable, Share!
  • Twitter
  • Facebook
  • email
  • LinkedIn
  • HackerNews
  • Reddit
  • http://www.gentoo.org Matthew “quantum” Summers

    Lance,

    Excellent article. For this piece I shall donate $50 to OSUOSL, as promised. Networking in virtualized environments, especially on larger scales, can be tricky. Its great to see how you have solved some of these issues using Gentoo.

    Thanks a ton!
    Matt

  • januszzz

    Hello,

    for me that part was easy, as I’ve got the battle won with OpenVZ where interfaces came and go :-)

    Today I do it in more sophisticated way, but core is the same. I use baselayout-2. I have posted everything here:

    http://en.gentoo-wiki.com/wiki/OpenVZ_VLAN

    Anyway, its good to have it on Gentoo homesite :-)

  • Radu Benea

    just an observation, to simplify a bit, you could move the sleep after the for statement and thus it wouldn’t require an extra if

    • lance

      Good catch! I’m surprised I missed noticing that before.

  • Py

    I think in Baselayout-2

    rc_need_net.br42=”net.vlan42″

    would do the trick or I am wrong?

  • John

    I just use routed networking, it’s usually easier and more flexible (as long as you don’t need dhcp). I’ve managed to set up a ganeti host on a laptop that has either wifi or wired networking using one extra tun/tap interface (since ganeti *needs* and interface to be up) and routed networking.

  • lance

    I’ve been meaning to play with routed networking but what we’re doing for production works well.