openvswitch: adds new UCI section ovs_bridge
authorSimon Kinane <skinane@fb.com>
Sun, 26 Jul 2020 19:58:53 +0000 (20:58 +0100)
committerYousong Zhou <yszhou4tech@gmail.com>
Tue, 28 Jul 2020 04:46:17 +0000 (12:46 +0800)
This new config section in package openvswitch
supports creating a named bridge, and setting
its' OpenFlow controller end-point.

An example config is included in /rom/etc/config/openvswitch

Signed-off-by: Simon Kinane <skinane@fb.com>
net/openvswitch/Makefile
net/openvswitch/README.md
net/openvswitch/files/openvswitch.config
net/openvswitch/files/openvswitch.init

index f8fc3acaf9d4fb42373f29d0823f1b2f287f4356..bc690ed45b9ac78ecbef9b6f92e9be4e5a81e437 100644 (file)
@@ -17,7 +17,7 @@ include ./openvswitch.mk
 #
 PKG_NAME:=openvswitch
 PKG_VERSION:=$(ovs_version)
-PKG_RELEASE:=5
+PKG_RELEASE:=6
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://www.openvswitch.org/releases/
 PKG_HASH:=dd5f727427e36cab22bdeae61529d8c8fccacc53d968cfa7658f7f935ddda531
index 541056a498780bcccacaa1c4c9dfce1ce6ca26d6..9008a886b82c5e235737be46e80946e7cf3493ce 100644 (file)
@@ -60,3 +60,20 @@ E.g. replace in-tree datapath module with upstream version
        opkg remove --force-depends kmod-openvswitch-intree
        opkg install kmod-openvswitch
        ovs-ctl force-reload-kmod
+
+# UCI configuration options
+
+There are 4 config section types in package openvswitch:
+ovs ovn_northd, ovn_controller & ovs_bridge.
+
+Each of these supports a disabled option, which should be 
+set to 0 to launch the respective daemons.
+
+The ovs_bridge section also supports the options below,
+for initialising a virtual bridge with an OpenFlow controller.
+
+| Name       | Type    | Required | Default                        | Description                                                |
+|------------|---------|----------|--------------------------------|------------------------------------------------------------|
+| disabled   | boolean | no       | 0                              | If set to true, disable initialisation of the named bridge |
+| name       | string  | no       | Inherits UCI config block name | The name of the switch in the OVS daemon                   |
+| controller | string  | no       | (none)                         | The endpoint of an OpenFlow controller for this bridge     |
index 1bd23775ec1a58efba82f5796dce51f2642b64b2..88c2ebc254b83c5125046d106584f69ca7ea453c 100644 (file)
@@ -6,3 +6,8 @@ config ovn_northd north
 
 config ovn_controller controller
        option disabled 1
+
+config ovs_bridge
+       option disabled 1
+       option name 'my-bridge'
+       option controller 'tcp:192.168.0.1'
\ No newline at end of file
index aa1e72ac3e7bfae59a911261608311d00147a537..a4cde9d1f164028f842c1599d296547e8ab3b824 100755 (executable)
@@ -36,6 +36,8 @@ ovs_action() {
        for cfgtype in ovs ovn_northd ovn_controller; do
                config_foreach "ovs_xx" "$cfgtype" "$action" "$cfgtype"
        done
+
+       config_foreach ovs_bridge_init "ovs_bridge"
 }
 
 ovs_xx() {
@@ -51,7 +53,7 @@ ovs_xx() {
                status|stop) ;;
                *)
                        config_get_bool disabled "$cfg" disabled 0
-                       [ "$disabled" -le 0 ] || return
+                       [ "$disabled" == "0" ] || return
                        ;;
        esac
 
@@ -65,3 +67,21 @@ ovs_xx() {
                        ;;
        esac
 }
+
+ovs_bridge_init() {
+       local cfg="$1"
+
+       local disabled
+       local name
+       local controller
+
+       config_get_bool disabled "$cfg" disabled 0
+       [ "$disabled" == "0" ] || return
+
+       config_get name "$cfg" name $cfg
+       ovs-vsctl --may-exist add-br "$name"
+
+       config_get controller "$cfg" controller
+       [ -n "$controller" ] && \
+               ovs-vsctl set-controller "$name" "$controller"
+}