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 /src/lib/connections/openvswitch | |
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>
Diffstat (limited to 'src/lib/connections/openvswitch')
-rw-r--r-- | src/lib/connections/openvswitch | 39 |
1 files changed, 39 insertions, 0 deletions
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: |