OpenVSwitch: Difference between revisions

From Alpine Linux
No edit summary
No edit summary
Line 35: Line 35:
To enable spanning tree (if needed):
To enable spanning tree (if needed):


ovs-vsctl set bridge lan stp_enable=true


ovs-vsctl set bridge lan stp_enable=true
LACP Timer setting 'fast' mode:
ovs-vsctl set port bond0 other_config:lacp-time=fast


== Using OVS appctl ==
== Using OVS appctl ==

Revision as of 11:56, 25 May 2015

This document describes how to configure an OpenVSwitch in Alpine Linux.

Installing OVS

apk add openvswitch
rc-update add ovs-modules
rc-update add ovsdb-server
rc-update add ovs-vswitchd
rc-service ovs-modules start
rc-service ovsdb-server start
rc-service ovs-vswitchd start

Using ovs-vsctl

Open VSwithes are manually managed with the ovs-vsctl command.

To manually create a switch named "lan":

ovs-vsctl add-br lan

To add interface eth0 to the switch "lan":

ovs-vsctl add-port lan eth0

Note that you need to set the link status to up on the added interfaces.

ip link set dev eth0 up

To see what OVS are defined:

ovs-vsctl list-br

To see what interfaces are linked to the lan OVS:

ovs-vsctl list-ports lan

To enable spanning tree (if needed):

ovs-vsctl set bridge lan stp_enable=true

LACP Timer setting 'fast' mode: ovs-vsctl set port bond0 other_config:lacp-time=fast

Using OVS appctl

ovs-appctl lacp/show bond0

Configuration file

configured in /etc/network/interfaces

auto eth0 lan
iface eth0 inet manual
 up ifconfig eth0 0.0.0.0 up
 down ifconfig eth0 down

iface lan inet dhcp

OVS and qemu

Helper scripts

ovs-ifup-

#!/bin/sh
switch=$(echo $0|/usr/bin/cut -d- -f3)
[ -z ${switch} ] && echo "Please define some symlink with suffix to use." && exit 1
[ $# -lt 1 ] && echo "Too few params. Must be 1 and is $#." && exit 2
/sbin/ifconfig $1 0.0.0.0 up
ovs-vsctl add-port ${switch} $1
logger "qemu: $1 added to ${switch} at startup of VM"

ovs-ifdown-

#!/bin/sh
switch=$(echo $0|/usr/bin/cut -d- -f3)
[ -z ${switch} ] && echo "Please define some symlink with suffix to use." && exit 1
[ $# -lt 1 ] && echo "Too few params. Must be 1 and is $#." && exit 2
/sbin/ifconfig $1 0.0.0.0 down
ovs-vsctl del-port ${switch} $1
logger "qemu: $1 removed from ${switch} at shutdown of VM"

OVS and LXC

Helper scripts

lxc-ovs-ifdown-

#!/bin/sh
switch=$(echo $0|/usr/bin/cut -d- -f4)
[ -z ${switch} ] && echo "Please define some symlink with suffix to use." && return 1
[ $# -lt 5 ] && echo "Too few params. Must be 5 and is $#." && exit 2
nic=$5
/usr/bin/ovs-vsctl del-port ${switch} ${nic}
/usr/bin/logger "lxc: ${nic} removed from ${switch} at shutdown of VM."

Caveats

Beware to have OVS package files available with no hassle at next reboot! this ca be a problem when running from ram with no cache...