summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/examples/openvswitch5
-rw-r--r--docs/netctl.profile.5.txt9
-rw-r--r--src/lib/connections/openvswitch39
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: