vxlan: backport upstream support

Signed-off-by: Johannes Kimmel <fff@bareminimum.eu>
This commit is contained in:
Johannes Kimmel 2020-12-16 07:32:50 +01:00
parent 31df0a3779
commit f1b5b5f16f
Signed by: jkimmel
GPG Key ID: 6B8F7858CE2AF6A5
3 changed files with 432 additions and 202 deletions

View File

@ -0,0 +1,432 @@
diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile
index 31640c80cd..ed35719aaa 100644
--- a/package/network/config/netifd/Makefile
+++ b/package/network/config/netifd/Makefile
@@ -5,9 +5,9 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git
-PKG_SOURCE_DATE:=2019-08-05
-PKG_SOURCE_VERSION:=5e02f94411b06f192fb2a7d9be9abde3549153a8
-PKG_MIRROR_HASH:=96e158584c605e96aceb3ce7e8ad8faa8e774ffd67d59558b2d6c2ff49d0f1a5
+PKG_SOURCE_DATE:=2020-12-13
+PKG_SOURCE_VERSION:=458b1a7e9473c150a40cae5d8be174f4bb03bd39
+PKG_MIRROR_HASH:=424aefb55aedebfcffd540a2c02a42aeb574b7ebb1a6b546ca9965d9280d82e5
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_LICENSE:=GPL-2.0
diff --git a/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-tune b/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-packet-steering
similarity index 72%
rename from package/network/config/netifd/files/etc/hotplug.d/net/20-smp-tune
rename to package/network/config/netifd/files/etc/hotplug.d/net/20-smp-packet-steering
index ab9a90418e..8a86bf75f6 100644
--- a/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-tune
+++ b/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-packet-steering
@@ -14,7 +14,7 @@ find_irq_cpu() {
[ -n "$match" ] && {
set -- $match
shift
- for cur in `seq 1 $NPROCS`; do
+ for cur in $(seq 1 $NPROCS); do
[ "$1" -gt 0 ] && {
cpu=$(($cur - 1))
break
@@ -34,8 +34,8 @@ set_hex_val() {
echo "$val" > "$file"
}
-default_ps="$(uci get "network.@globals[0].default_ps")"
-[ -n "$default_ps" -a "$default_ps" != 1 ] && exit 0
+packet_steering="$(uci get "network.@globals[0].packet_steering")"
+[ "$packet_steering" != 1 ] && exit 0
exec 512>/var/lock/smp_tune.lock
flock 512 || exit 1
@@ -52,16 +52,16 @@ for dev in /sys/class/net/*; do
irq_cpu="$(find_irq_cpu "$device")"
irq_cpu_mask="$((1 << $irq_cpu))"
- for q in ${dev}/queues/rx-*; do
- set_hex_val "$q/rps_cpus" "$(($PROC_MASK & ~$irq_cpu_mask))"
+ for q in ${dev}/queues/tx-*; do
+ set_hex_val "$q/xps_cpus" "$PROC_MASK"
done
- ntxq="$(ls -d ${dev}/queues/tx-* | wc -l)"
+ # ignore dsa slave ports for RPS
+ subsys="$(readlink "${dev}/device/subsystem")"
+ subsys="$(basename "$subsys")"
+ [ "$subsys" = "mdio_bus" ] && continue
- idx=$(($irq_cpu + 1))
- for q in ${dev}/queues/tx-*; do
- set_hex_val "$q/xps_cpus" "$((1 << $idx))"
- let "idx = idx + 1"
- [ "$idx" -ge "$NPROCS" ] && idx=0
+ for q in ${dev}/queues/rx-*; do
+ set_hex_val "$q/rps_cpus" "$PROC_MASK"
done
done
diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network
index 2321a309a5..dc208c4ce0 100755
--- a/package/network/config/netifd/files/etc/init.d/network
+++ b/package/network/config/netifd/files/etc/init.d/network
@@ -40,11 +40,6 @@ stop_service() {
sleep 1
}
-service_running() {
- ubus -t 30 wait_for network.interface
- /sbin/wifi reload_legacy
-}
-
validate_atm_bridge_section()
{
uci_validate_section network "atm-bridge" "${1}" \
diff --git a/package/network/config/netifd/files/etc/uci-defaults/14_migrate-dhcp-release b/package/network/config/netifd/files/etc/uci-defaults/14_migrate-dhcp-release
new file mode 100644
index 0000000000..f1b384eecc
--- /dev/null
+++ b/package/network/config/netifd/files/etc/uci-defaults/14_migrate-dhcp-release
@@ -0,0 +1,23 @@
+. /lib/functions.sh
+
+migrate_release() {
+ local config="$1"
+ local proto
+ local release
+
+ config_get proto "$config" proto
+ config_get release "$config" release
+
+ [ "$proto" = "dhcp" ] && [ -n "$release" ] && {
+ norelease="$((!$release))"
+ uci_set network "$config" norelease "$norelease"
+ uci_remove network "$config" release
+ }
+
+}
+
+config_load network
+config_foreach migrate_release interface
+uci commit network
+
+exit 0
diff --git a/package/network/config/netifd/files/lib/netifd/dhcp.script b/package/network/config/netifd/files/lib/netifd/dhcp.script
index 00604f40e7..6585b641d6 100755
--- a/package/network/config/netifd/files/lib/netifd/dhcp.script
+++ b/package/network/config/netifd/files/lib/netifd/dhcp.script
@@ -46,10 +46,16 @@ setup_interface () {
proto_add_dns_search "$i"
done
+ # TODO: Deprecate timesvr in favor of timesrv
+ if [ -n "$timesvr" -a -z "$timesrv" ]; then
+ timesrv="$timesvr"
+ echo "Environment variable 'timesvr' will be deprecated; use 'timesrv' instead."
+ fi
+
proto_add_data
[ -n "$ZONE" ] && json_add_string zone "$ZONE"
[ -n "$ntpsrv" ] && json_add_string ntpserver "$ntpsrv"
- [ -n "$timesvr" ] && json_add_string timeserver "$timesvr"
+ [ -n "$timesrv" ] && json_add_string timeserver "$timesrv"
[ -n "$hostname" ] && json_add_string hostname "$hostname"
[ -n "$message" ] && json_add_string message "$message"
[ -n "$timezone" ] && json_add_int timezone "$timezone"
diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
index 0d06eba06e..3034b2ba68 100755
--- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
+++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
@@ -14,7 +14,7 @@ proto_dhcp_init_config() {
proto_config_add_string clientid
proto_config_add_string vendorid
proto_config_add_boolean 'broadcast:bool'
- proto_config_add_boolean 'release:bool'
+ proto_config_add_boolean 'norelease:bool'
proto_config_add_string 'reqopts:list(string)'
proto_config_add_boolean 'defaultreqopts:bool'
proto_config_add_string iface6rd
@@ -35,8 +35,8 @@ proto_dhcp_setup() {
local config="$1"
local iface="$2"
- local ipaddr hostname clientid vendorid broadcast release reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
- json_get_vars ipaddr hostname clientid vendorid broadcast release reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute
+ local ipaddr hostname clientid vendorid broadcast norelease reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
+ json_get_vars ipaddr hostname clientid vendorid broadcast norelease reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute
local opt dhcpopts
for opt in $reqopts; do
@@ -50,7 +50,7 @@ proto_dhcp_setup() {
[ "$defaultreqopts" = 0 ] && defaultreqopts="-o" || defaultreqopts=
[ "$broadcast" = 1 ] && broadcast="-B" || broadcast=
- [ "$release" = 1 ] && release="-R" || release=
+ [ "$norelease" = 1 ] && norelease="" || norelease="-R"
[ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C"
[ -n "$iface6rd" ] && proto_export "IFACE6RD=$iface6rd"
[ "$iface6rd" != 0 -a -f /lib/netifd/proto/6rd.sh ] && append dhcpopts "-O 212"
@@ -70,7 +70,7 @@ proto_dhcp_setup() {
${ipaddr:+-r $ipaddr} \
${hostname:+-x "hostname:$hostname"} \
${vendorid:+-V "$vendorid"} \
- $clientid $defaultreqopts $broadcast $release $dhcpopts
+ $clientid $defaultreqopts $broadcast $norelease $dhcpopts
}
proto_dhcp_renew() {
diff --git a/package/network/config/netifd/files/lib/network/config.sh b/package/network/config/netifd/files/lib/network/config.sh
index 0ded45edc4..4cd28e4ce1 100755
--- a/package/network/config/netifd/files/lib/network/config.sh
+++ b/package/network/config/netifd/files/lib/network/config.sh
@@ -6,13 +6,13 @@
find_config() {
local device="$1"
local ifdev ifl3dev ifobj
- for ifobj in `ubus list network.interface.\*`; do
+ for ifobj in $(ubus list network.interface.\*); do
interface="${ifobj##network.interface.}"
(
json_load "$(ifstatus $interface)"
json_get_var ifdev device
json_get_var ifl3dev l3_device
- if [[ "$device" = "$ifdev" ]] || [[ "$device" = "$ifl3dev" ]]; then
+ if [ "$device" = "$ifdev" ] || [ "$device" = "$ifl3dev" ]; then
echo "$interface"
exit 0
else
diff --git a/package/network/config/netifd/files/sbin/ifup b/package/network/config/netifd/files/sbin/ifup
index 5515b91f76..15be535bbf 100755
--- a/package/network/config/netifd/files/sbin/ifup
+++ b/package/network/config/netifd/files/sbin/ifup
@@ -37,7 +37,7 @@ done
[ "$modes" = "down up" ] && ubus call network reload
if [ -n "$ifup_all" ]; then
- for interface in `ubus -S list 'network.interface.*'`; do
+ for interface in $(ubus -S list 'network.interface.*'); do
if_call "${interface##network.interface.}"
done
[ -n "$setup_wifi" ] && /sbin/wifi up
diff --git a/package/network/config/netifd/files/usr/share/udhcpc/default.script b/package/network/config/netifd/files/usr/share/udhcpc/default.script
index ac765a6363..0a9eb0180e 100755
--- a/package/network/config/netifd/files/usr/share/udhcpc/default.script
+++ b/package/network/config/netifd/files/usr/share/udhcpc/default.script
@@ -14,8 +14,8 @@ set_classless_routes() {
}
setup_interface() {
- echo "udhcpc: ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+}"
- ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+}
+ echo "udhcpc: ip addr add $ip/${subnet:-255.255.255.0} broadcast ${broadcast:-+} dev $interface"
+ ip addr add $ip/${subnet:-255.255.255.0} broadcast ${broadcast:-+} dev $interface
[ -n "$router" ] && [ "$router" != "0.0.0.0" ] && [ "$router" != "255.255.255.255" ] && {
echo "udhcpc: setting default routers: $router"
@@ -41,7 +41,7 @@ setup_interface() {
applied=
case "$1" in
deconfig)
- ifconfig "$interface" 0.0.0.0
+ ip -4 addr flush dev "$interface"
;;
renew)
setup_interface update
diff --git a/package/network/config/vxlan/Makefile b/package/network/config/vxlan/Makefile
index 13fcf0c55d..97972d6d85 100644
--- a/package/network/config/vxlan/Makefile
+++ b/package/network/config/vxlan/Makefile
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=vxlan
-PKG_RELEASE:=3
+PKG_RELEASE:=7
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
diff --git a/package/network/config/vxlan/files/vxlan.sh b/package/network/config/vxlan/files/vxlan.sh
index 7b1c703955..a087c4a3ce 100755
--- a/package/network/config/vxlan/files/vxlan.sh
+++ b/package/network/config/vxlan/files/vxlan.sh
@@ -7,6 +7,50 @@
init_proto "$@"
}
+proto_vxlan_setup_peer() {
+ type bridge &> /dev/null || {
+ proto_notify_error "$cfg" "MISSING_BRIDGE_COMMAND"
+ exit
+ }
+
+ local peer_config="$1"
+
+ local vxlan
+ local lladdr
+ local dst
+ local src_vni
+ local vni
+ local port
+ local via
+
+ config_get vxlan "${peer_config}" "vxlan"
+ config_get lladdr "${peer_config}" "lladdr"
+ config_get dst "${peer_config}" "dst"
+ config_get src_vni "${peer_config}" "src_vni"
+ config_get vni "${peer_config}" "vni"
+ config_get port "${peer_config}" "port"
+ config_get via "${peer_config}" "via"
+
+ [ "$cfg" = "$vxlan" ] || {
+ # This peer section belongs to another device
+ return
+ }
+
+ [ -n "${dst}" ] || {
+ proto_notify_error "$cfg" "MISSING_PEER_ADDRESS"
+ exit
+ }
+
+ bridge fdb append \
+ ${lladdr:-00:00:00:00:00:00} \
+ dev ${cfg} \
+ dst ${dst} \
+ ${src_vni:+src_vni $src_vni} \
+ ${vni:+vni $vni} \
+ ${port:+port $port} \
+ ${via:+via $via}
+}
+
vxlan_generic_setup() {
local cfg="$1"
local mode="$2"
@@ -15,9 +59,8 @@ vxlan_generic_setup() {
local link="$cfg"
- local port vid ttl tos mtu macaddr zone rxcsum txcsum
- json_get_vars port vid ttl tos mtu macaddr zone rxcsum txcsum
-
+ local port vid ttl tos mtu macaddr zone rxcsum txcsum srcportmin srcportmax ageing maxaddress learning rsc proxy l2miss l3miss gbp
+ json_get_vars port vid ttl tos mtu macaddr zone rxcsum txcsum srcportmin srcportmax ageing maxaddress learning rsc proxy l2miss l3miss gbp
proto_init_update "$link" 1
@@ -35,9 +78,20 @@ vxlan_generic_setup() {
json_add_object 'data'
[ -n "$port" ] && json_add_int port "$port"
[ -n "$vid" ] && json_add_int id "$vid"
+ [ -n "$srcportmin" ] && json_add_int srcportmin "$srcportmin"
+ [ -n "$srcportmax" ] && json_add_int srcportmax "$srcportmax"
+ [ -n "$ageing" ] && json_add_int ageing "$ageing"
+ [ -n "$maxaddress" ] && json_add_int maxaddress "$maxaddress"
[ -n "$macaddr" ] && json_add_string macaddr "$macaddr"
[ -n "$rxcsum" ] && json_add_boolean rxcsum "$rxcsum"
[ -n "$txcsum" ] && json_add_boolean txcsum "$txcsum"
+ [ -n "$learning" ] && json_add_boolean learning "$learning"
+ [ -n "$rsc" ] && json_add_boolean rsc "$rsc"
+ [ -n "$proxy" ] && json_add_boolean proxy "$proxy"
+ [ -n "$l2miss" ] && json_add_boolean l2miss "$l2miss"
+ [ -n "$l3miss" ] && json_add_boolean l3miss "$l3miss"
+ [ -n "$gbp" ] && json_add_boolean gbp "$gbp"
+
json_close_object
proto_close_tunnel
@@ -47,6 +101,9 @@ vxlan_generic_setup() {
proto_close_data
proto_send_update "$cfg"
+
+ config_load network
+ config_foreach proto_vxlan_setup_peer "vxlan_peer"
}
proto_vxlan_setup() {
@@ -55,26 +112,13 @@ proto_vxlan_setup() {
local ipaddr peeraddr
json_get_vars ipaddr peeraddr tunlink
- [ -z "$peeraddr" ] && {
- proto_notify_error "$cfg" "MISSING_ADDRESS"
- proto_block_restart "$cfg"
- exit
- }
-
( proto_add_host_dependency "$cfg" '' "$tunlink" )
- [ -z "$ipaddr" ] && {
- local wanif="$tunlink"
- if [ -z "$wanif" ] && ! network_find_wan wanif; then
- proto_notify_error "$cfg" "NO_WAN_LINK"
- exit
- fi
-
- if ! network_get_ipaddr ipaddr "$wanif"; then
- proto_notify_error "$cfg" "NO_WAN_LINK"
- exit
- fi
- }
+ case "$ipaddr" in
+ "auto"|"")
+ ipaddr="0.0.0.0"
+ ;;
+ esac
vxlan_generic_setup "$cfg" 'vxlan' "$ipaddr" "$peeraddr"
}
@@ -85,26 +129,14 @@ proto_vxlan6_setup() {
local ip6addr peer6addr
json_get_vars ip6addr peer6addr tunlink
- [ -z "$peer6addr" ] && {
- proto_notify_error "$cfg" "MISSING_ADDRESS"
- proto_block_restart "$cfg"
- exit
- }
-
( proto_add_host_dependency "$cfg" '' "$tunlink" )
- [ -z "$ip6addr" ] && {
- local wanif="$tunlink"
- if [ -z "$wanif" ] && ! network_find_wan6 wanif; then
- proto_notify_error "$cfg" "NO_WAN_LINK"
- exit
- fi
-
- if ! network_get_ipaddr6 ip6addr "$wanif"; then
- proto_notify_error "$cfg" "NO_WAN_LINK"
- exit
- fi
- }
+ case "$ip6addr" in
+ "auto"|"")
+ # ensure tunnel via ipv6
+ ip6addr="::"
+ ;;
+ esac
vxlan_generic_setup "$cfg" 'vxlan6' "$ip6addr" "$peer6addr"
}
@@ -129,9 +161,20 @@ vxlan_generic_init_config() {
proto_config_add_int "ttl"
proto_config_add_int "tos"
proto_config_add_int "mtu"
+ proto_config_add_int "srcportmin"
+ proto_config_add_int "srcportmax"
+ proto_config_add_int "ageing"
+ proto_config_add_int "maxaddress"
proto_config_add_boolean "rxcsum"
proto_config_add_boolean "txcsum"
+ proto_config_add_boolean "learning"
+ proto_config_add_boolean "rsc"
+ proto_config_add_boolean "proxy"
+ proto_config_add_boolean "l2miss"
+ proto_config_add_boolean "l3miss"
+ proto_config_add_boolean "gbp"
proto_config_add_string "macaddr"
+
}
proto_vxlan_init_config() {

View File

@ -1,43 +0,0 @@
From: Johannes Kimmel <fff@bareminimum.eu>
Date: Mon, 20 Jul 2020 08:05:09 +0200
Subject: vxlan: remove mandatory peeraddr
vxlan can be configured without a peer address. This is used to prepare
an interface and add peers later.
Fixes: FS#2743
Signed-off-by: Johannes Kimmel <fff@bareminimum.eu>
Acked-by: Matthias Schiffer <mschiffer@universe-factory.net>
(cherry picked from commit 5222aadbf353b7cc030c39aa816f33951b104552)
diff --git a/package/network/config/vxlan/files/vxlan.sh b/package/network/config/vxlan/files/vxlan.sh
index 7b1c7039551b7781f5f7a8e73b964db698f3697b..bdcaa628c4416cc83258dd38a6fc0978ea55a3bb 100755
--- a/package/network/config/vxlan/files/vxlan.sh
+++ b/package/network/config/vxlan/files/vxlan.sh
@@ -55,12 +55,6 @@ proto_vxlan_setup() {
local ipaddr peeraddr
json_get_vars ipaddr peeraddr tunlink
- [ -z "$peeraddr" ] && {
- proto_notify_error "$cfg" "MISSING_ADDRESS"
- proto_block_restart "$cfg"
- exit
- }
-
( proto_add_host_dependency "$cfg" '' "$tunlink" )
[ -z "$ipaddr" ] && {
@@ -85,12 +79,6 @@ proto_vxlan6_setup() {
local ip6addr peer6addr
json_get_vars ip6addr peer6addr tunlink
- [ -z "$peer6addr" ] && {
- proto_notify_error "$cfg" "MISSING_ADDRESS"
- proto_block_restart "$cfg"
- exit
- }
-
( proto_add_host_dependency "$cfg" '' "$tunlink" )
[ -z "$ip6addr" ] && {

View File

@ -1,159 +0,0 @@
From: Johannes Kimmel <fff@bareminimum.eu>
Date: Mon, 20 Jul 2020 08:05:10 +0200
Subject: vxlan: add capability for multiple fdb entries
Similar to wireguard, vxlan can configure multiple peers or add specific
entries to the fdb for a single mac address.
While you can still use peeraddr/peer6addr option within the proto
vxlan/vxlan6 section to not break existing configurations, this patch
allows to add multiple sections that conigure fdb entries via the bridge
command. As such, the bridge command is now a dependency of the vxlan
package. (To be honest without the bridge command available, vxlan isn't
very much fun to use or debug at all)
Field names are taken direclty from the bridge command.
Example with all supported parameters, since this hasn't been documented so
far:
config interface 'vx0'
option proto 'vxlan6' # use vxlan over ipv6
# main options
option ip6addr '2001:db8::1' # listen address
option tunlink 'wan6' # optional if listen address given
option peer6addr '2001:db8::2' # now optional
option port '8472' # this is the standard port under linux
option vid '42' # VXLAN Network Identifier to use
option mtu '1430' # vxlan6 has 70 bytes overhead
# extra options
option rxcsum '0' # allow receiving packets without checksum
option txcsum '0' # send packets without checksum
option ttl '16' # specifies the TTL value for outgoing packets
option tos '0' # specifies the TOS value for outgoing packets
option macaddr '11:22:33:44:55:66' # optional, manually specify mac
# default is a random address
Single peer with head-end replication. Corresponds to the following call
to bridge:
$ bridge fdb append 00:00:00:00:00:00 dev vx0 dst 2001:db8::3
config vxlan_peer
option vxlan 'vx0'
option dst '2001:db8::3' # always required
For multiple peers, this section can be repeated for each dst address.
It's possible to specify a multicast address as destination. Useful when
multicast routing is available or within one lan segment:
config vxlan_peer
option vxlan 'vx0'
option dst 'ff02::1337' # multicast group to join.
# all bum traffic will be send there
option via 'eth1' # for multicast, an outgoing interface needs
# to be specified
All available peer options for completeness:
config vxlan_peer
option vxlan 'vx0' # the interface to configure
option lladdr 'aa:bb:cc:dd:ee:ff' # specific mac,
option dst '2001:db8::4' # connected to this peer
option via 'eth0.1' # use this interface only
option port '4789' # use different port for this peer
option vni '23' # override vni for this peer
option src_vni '123' # see man 3 bridge
Signed-off-by: Johannes Kimmel <fff@bareminimum.eu>
(cherry picked from commit 65e9de3c333bae1ccef1dfb0cc008ad6f13958e4)
diff --git a/package/network/config/vxlan/Makefile b/package/network/config/vxlan/Makefile
index 13fcf0c55d07d97f5dcc3cbfcf2478020e7107cc..7232f71b45e6f72f2c62a245ad44cb9ade144f52 100644
--- a/package/network/config/vxlan/Makefile
+++ b/package/network/config/vxlan/Makefile
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=vxlan
-PKG_RELEASE:=3
+PKG_RELEASE:=4
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
diff --git a/package/network/config/vxlan/files/vxlan.sh b/package/network/config/vxlan/files/vxlan.sh
index bdcaa628c4416cc83258dd38a6fc0978ea55a3bb..d063c47d47d0f4e339b21e97f4e25f55a33c0497 100755
--- a/package/network/config/vxlan/files/vxlan.sh
+++ b/package/network/config/vxlan/files/vxlan.sh
@@ -7,6 +7,50 @@
init_proto "$@"
}
+proto_vxlan_setup_peer() {
+ type bridge &> /dev/null || {
+ proto_notify_error "$cfg" "MISSING_BRIDGE_COMMAND"
+ exit
+ }
+
+ local peer_config="$1"
+
+ local vxlan
+ local lladdr
+ local dst
+ local src_vni
+ local vni
+ local port
+ local via
+
+ config_get vxlan "${peer_config}" "vxlan"
+ config_get lladdr "${peer_config}" "lladdr"
+ config_get dst "${peer_config}" "dst"
+ config_get src_vni "${peer_config}" "src_vni"
+ config_get vni "${peer_config}" "vni"
+ config_get port "${peer_config}" "port"
+ config_get via "${peer_config}" "via"
+
+ [ "$cfg" = "$vxlan" ] || {
+ # This peer section belongs to another device
+ return
+ }
+
+ [ -n "${dst}" ] || {
+ proto_notify_error "$cfg" "MISSING_PEER_ADDRESS"
+ exit
+ }
+
+ bridge fdb append \
+ ${lladdr:-00:00:00:00:00:00} \
+ dev ${cfg} \
+ dst ${dst} \
+ ${src_vni:+src_vni $src_vni} \
+ ${vni:+vni $vni} \
+ ${port:+port $port} \
+ ${via:+via $via}
+}
+
vxlan_generic_setup() {
local cfg="$1"
local mode="$2"
@@ -18,7 +62,6 @@ vxlan_generic_setup() {
local port vid ttl tos mtu macaddr zone rxcsum txcsum
json_get_vars port vid ttl tos mtu macaddr zone rxcsum txcsum
-
proto_init_update "$link" 1
proto_add_tunnel
@@ -47,6 +90,9 @@ vxlan_generic_setup() {
proto_close_data
proto_send_update "$cfg"
+
+ config_load network
+ config_foreach proto_vxlan_setup_peer "vxlan_peer"
}
proto_vxlan_setup() {