Browse Source

Merge pull request #16228 from stintel/ovs-datapath_id

openvswitch: support setting OpenFlow datapath ID
lilik-openwrt-22.03
Stijn Tintel 3 years ago
committed by GitHub
parent
commit
2104f7cd51
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 6 deletions
  1. +1
    -1
      net/openvswitch/Makefile
  2. +6
    -5
      net/openvswitch/README.md
  3. +1
    -0
      net/openvswitch/files/openvswitch.config
  4. +21
    -0
      net/openvswitch/files/openvswitch.init

+ 1
- 1
net/openvswitch/Makefile View File

@ -17,7 +17,7 @@ include ./openvswitch.mk
# #
PKG_NAME:=openvswitch PKG_NAME:=openvswitch
PKG_VERSION:=$(ovs_version) PKG_VERSION:=$(ovs_version)
PKG_RELEASE:=4
PKG_RELEASE:=5
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://www.openvswitch.org/releases/ PKG_SOURCE_URL:=https://www.openvswitch.org/releases/
PKG_HASH:=7d5797f2bf2449c6a266149e88f72123540f7fe7f31ad52902057ae8d8f88c38 PKG_HASH:=7d5797f2bf2449c6a266149e88f72123540f7fe7f31ad52902057ae8d8f88c38


+ 6
- 5
net/openvswitch/README.md View File

@ -72,11 +72,12 @@ set to 0 to launch the respective daemons.
The ovs_bridge section also supports the options below, The ovs_bridge section also supports the options below,
for initialising a virtual bridge with an OpenFlow controller. 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 |
| 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 |
The ovs_port section can be used to add ports to a bridge. It supports the options below. The ovs_port section can be used to add ports to a bridge. It supports the options below.


+ 1
- 0
net/openvswitch/files/openvswitch.config View File

@ -11,6 +11,7 @@ config ovs_bridge
option disabled 1 option disabled 1
option name 'my-bridge' option name 'my-bridge'
option controller 'tcp:192.168.0.1' option controller 'tcp:192.168.0.1'
option datapath_id ''
config ovs_port config ovs_port
option disabled 1 option disabled 1


+ 21
- 0
net/openvswitch/files/openvswitch.init View File

@ -171,12 +171,26 @@ ovs_bridge_port_cleanup() {
done done
} }
ovs_bridge_validate_datapath_id() {
local dpid="$1"
if expr "$dpid" : '[[:xdigit:]]\{16\}$' > /dev/null; then
return 0
elif expr "$dpid" : '0x[[:xdigit:]]\{1,16\}$' > /dev/null; then
return 0
else
logger -t openvswitch "invalid datapath_id: $dpid"
return 1
fi
}
ovs_bridge_init() { ovs_bridge_init() {
local cfg="$1" local cfg="$1"
local disabled local disabled
local name local name
local controller local controller
local datapath_id
config_get_bool disabled "$cfg" disabled 0 config_get_bool disabled "$cfg" disabled 0
[ "$disabled" == "0" ] || return [ "$disabled" == "0" ] || return
@ -184,6 +198,13 @@ ovs_bridge_init() {
config_get name "$cfg" name $cfg config_get name "$cfg" name $cfg
ovs-vsctl --may-exist add-br "$name" ovs-vsctl --may-exist add-br "$name"
config_get datapath_id "$cfg" datapath_id
[ -n "$datapath_id" ] && {
ovs_bridge_validate_datapath_id "$datapath_id" && {
ovs-vsctl --if-exists set bridge "$name" other-config:datapath-id="$datapath_id"
}
}
config_list_foreach "$cfg" "ports" ovs_bridge_port_add config_list_foreach "$cfg" "ports" ovs_bridge_port_add
config_foreach ovs_bridge_port_add_complex ovs_port "$name" config_foreach ovs_bridge_port_add_complex ovs_port "$name"
config_get_bool drop "$cfg" "drop_unknown_ports" 0 config_get_bool drop "$cfg" "drop_unknown_ports" 0


Loading…
Cancel
Save