From 1d490769d87875bbc03de1c1c7b198e4f9f42b91 Mon Sep 17 00:00:00 2001 From: Jouke Witteveen Date: Sun, 27 Jul 2014 22:11:42 +0200 Subject: Add a connection type for openvswitch interfaces Open vSwitch support code contributed by: Jonathan Hudson --- src/lib/connections/openvswitch | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/lib/connections/openvswitch (limited to 'src/lib/connections/openvswitch') 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 + +. "$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: -- cgit v1.2.3-24-g4f1b