From 2c37a6983ffcff1fe4ba92eb703a616036d2324d Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Wed, 13 Oct 2021 01:07:19 +0300 Subject: [PATCH] openflow: sync changes from openwrt-packages c05103da9 openvswitch: add option for OpenFlow datapath desc b2bfb572a openvswitch: fix build with libunbound 9e45d4534 openvswitch: add option for failure mode Signed-off-by: Stijn Tintel --- feeds/openflow/openvswitch/Makefile | 4 +- feeds/openflow/openvswitch/README.md | 14 +++--- .../openvswitch/files/openvswitch.config | 2 + .../openvswitch/files/openvswitch.init | 43 +++++++++++++++++++ 4 files changed, 55 insertions(+), 8 deletions(-) diff --git a/feeds/openflow/openvswitch/Makefile b/feeds/openflow/openvswitch/Makefile index cf24b26ed..224d41b40 100644 --- a/feeds/openflow/openvswitch/Makefile +++ b/feeds/openflow/openvswitch/Makefile @@ -17,7 +17,7 @@ include ./openvswitch.mk # PKG_NAME:=openvswitch PKG_VERSION:=$(ovs_version) -PKG_RELEASE:=6 +PKG_RELEASE:=9 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://www.openvswitch.org/releases/ PKG_HASH:=5c7baed537364d43af36c15dde298c95d35cb2cb3204b4d3fe9b0fc73c97f16d @@ -155,7 +155,7 @@ ovs_libopenvswitch_title:=Open vSwitch (libopenvswitch.so) ovs_libopenvswitch_hidden:=1 ovs_libopenvswitch_depends:=+libopenssl +!(arc||arceb):libunwind ovs_libopenvswitch_depends+=+libatomic -ifeq ($(CONFIG_KEEPALIVED_ROUTES),y) +ifeq ($(CONFIG_OPENVSWITCH_WITH_LIBUNBOUND),y) ovs_libopenvswitch_depends+=+libunbound endif ovs_libopenvswitch_files:=usr/lib/libopenvswitch*.so* diff --git a/feeds/openflow/openvswitch/README.md b/feeds/openflow/openvswitch/README.md index 5cc8bbffe..b5911a597 100644 --- a/feeds/openflow/openvswitch/README.md +++ b/feeds/openflow/openvswitch/README.md @@ -85,12 +85,14 @@ after adding or changing these options. 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 | -| datapath_id | string | no | (none) | The OpenFlow datapath ID for this bridge | +| 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 | +| datapath_id | string | no | (none) | The OpenFlow datapath ID for this bridge | +| datapath_desc | string | no | (none) | The OpenFlow datapath description for this bridge | +| fail_mode | string | no | standalone | The bridge failure mode | The ovs_port section can be used to add ports to a bridge. It supports the options below. diff --git a/feeds/openflow/openvswitch/files/openvswitch.config b/feeds/openflow/openvswitch/files/openvswitch.config index c812b7dd6..8fb9d1a79 100644 --- a/feeds/openflow/openvswitch/files/openvswitch.config +++ b/feeds/openflow/openvswitch/files/openvswitch.config @@ -14,7 +14,9 @@ config ovs_bridge option disabled 1 option name 'my-bridge' option controller 'tcp:192.168.0.1' + option datapath_desc '' option datapath_id '' + option fail_mode 'standalone' config ovs_port option disabled 1 diff --git a/feeds/openflow/openvswitch/files/openvswitch.init b/feeds/openflow/openvswitch/files/openvswitch.init index 229e6869b..f4a88edcf 100755 --- a/feeds/openflow/openvswitch/files/openvswitch.init +++ b/feeds/openflow/openvswitch/files/openvswitch.init @@ -187,6 +187,31 @@ ovs_bridge_validate_datapath_id() { fi } +ovs_bridge_validate_datapath_desc() { + local dpdesc="$1" + + if [ "$(echo $dpdesc | wc -c)" -le 255 ]; then + return 0 + else + logger -t openvswitch "invalid datapath_desc: $dpdesc" + return 1 + fi +} + +ovs_bridge_validate_fail_mode() { + local fail_mode="$1" + + case "$fail_mode" in + secure|standalone) + return 0 + ;; + *) + logger -t openvswitch "invalid fail_mode: $fail_mode" + return 1 + ;; + esac +} + ovs_bridge_init() { local cfg="$1" @@ -208,6 +233,24 @@ ovs_bridge_init() { } } + config_get datapath_desc "$cfg" datapath_desc + [ -n "$datapath_desc" ] && { + ovs_bridge_validate_datapath_desc "$datapath_desc" && { + ovs-vsctl --if-exists set bridge "$name" other-config:dp-desc="$datapath_desc" + } + } + + config_get fail_mode "$cfg" fail_mode + [ -n "$fail_mode" ] && { + ovs_bridge_validate_fail_mode "$fail_mode" && { + ovs-vsctl set-fail-mode "$name" "$fail_mode" 2> /dev/null + } || { + ovs-vsctl del-fail-mode "$name" 2> /dev/null + } + } || { + ovs-vsctl del-fail-mode "$name" 2> /dev/null + } + config_list_foreach "$cfg" "ports" ovs_bridge_port_add config_foreach ovs_bridge_port_add_complex ovs_port "$name" config_get_bool drop "$cfg" "drop_unknown_ports" 0