diff options
author | Jouke Witteveen <j.witteveen@gmail.com> | 2014-07-27 22:11:42 +0200 |
---|---|---|
committer | Jouke Witteveen <j.witteveen@gmail.com> | 2014-07-27 22:11:42 +0200 |
commit | 1d490769d87875bbc03de1c1c7b198e4f9f42b91 (patch) | |
tree | 5db3daddfc38bda4abbba1d6aaa1963e49a4c1da | |
parent | 3fce1e6f67cd52afa4470c1ee7d42112d9d9405b (diff) | |
download | netctl-1d490769d87875bbc03de1c1c7b198e4f9f42b91.tar.gz netctl-1d490769d87875bbc03de1c1c7b198e4f9f42b91.tar.xz |
Add a connection type for openvswitch interfaces
Open vSwitch support code contributed by:
Jonathan Hudson <jh+arch@daria.co.uk>
-rw-r--r-- | docs/examples/openvswitch | 5 | ||||
-rw-r--r-- | docs/netctl.profile.5.txt | 9 | ||||
-rw-r--r-- | src/lib/connections/openvswitch | 39 |
3 files changed, 53 insertions, 0 deletions
diff --git a/docs/examples/openvswitch b/docs/examples/openvswitch new file mode 100644 index 0000000..c2069b3 --- /dev/null +++ b/docs/examples/openvswitch @@ -0,0 +1,5 @@ +Description="Example Open vSwitch connection" +Interface=ovs-br0 +Connection=openvswitch +BindsToInterfaces=(eth0 eth1) +IP=dhcp diff --git a/docs/netctl.profile.5.txt b/docs/netctl.profile.5.txt index 29a679f..9956c24 100644 --- a/docs/netctl.profile.5.txt +++ b/docs/netctl.profile.5.txt @@ -48,6 +48,8 @@ AVAILABLE CONNECTION TYPES For PPPoE connections. +mobile_ppp+:: For mobile broadband PPP connections that use a USB modem. ++openvswitch+:: + For Open vSwitch bridge interfaces. +tunnel+:: For tunnel interfaces. +tuntap+:: @@ -426,6 +428,13 @@ type: A file to read additional pppd options from. +OPTIONS FOR `openvswitch' CONNECTIONS +------------------------------------- +The interfaces of 'BindsToInterfaces' take part in the bridge named by +'Interface'. Only the *ip options* are understood for connections of +the `openvswitch' type. + + OPTIONS FOR `tunnel' CONNECTIONS -------------------------------- The name of the tunnel interface is specified in 'Interface'. Next to diff --git a/src/lib/connections/openvswitch b/src/lib/connections/openvswitch new file mode 100644 index 0000000..b9b9cfc --- /dev/null +++ b/src/lib/connections/openvswitch @@ -0,0 +1,39 @@ +# Contributed by: Jonathan Hudson <jh+arch@daria.co.uk> + +. "$SUBR_DIR/ip" + +: ${OVSCTL:=ovs-vsctl} + +# Make sure BindsToInterfaces is set +BindsToInterfaces=("${BindsToInterfaces[@]}") + +openvswitch_up() { + systemctl start ovs-vswitchd.service + if ! $OVSCTL br-exists "$Interface" && ! $OVSCTL add-br "$Interface"; then + report_error "Could not create a bridge named '$Interface'" + return 1 + fi + + for port in "${BindsToInterfaces[@]}"; do + ip link set dev "$port" promisc on up + ip addr flush dev "$port" scope host &>/dev/null + ip addr flush dev "$port" scope site &>/dev/null + ip addr flush dev "$port" scope global &>/dev/null + $OVSCTL --may-exist add-port "$Interface" "$port" + done + + bring_interface_up "$Interface" + ip_set +} + +openvswitch_down() { + for port in "${BindsToInterfaces[@]}"; do + ip link set dev "$port" promisc off down + done + + ip_unset + $OVSCTL del-br "$Interface" +} + + +# vim: ft=sh ts=4 et sw=4: |