3 [ -n "$INCLUDE_ONLY" ] ||
{
5 .
/lib
/functions
/network.sh
10 proto_vxlan_setup_peer
() {
11 type bridge
&> /dev
/null ||
{
12 proto_notify_error
"$cfg" "MISSING_BRIDGE_COMMAND"
16 local peer_config
="$1"
26 config_get vxlan
"${peer_config}" "vxlan"
27 config_get lladdr
"${peer_config}" "lladdr"
28 config_get dst
"${peer_config}" "dst"
29 config_get src_vni
"${peer_config}" "src_vni"
30 config_get vni
"${peer_config}" "vni"
31 config_get port
"${peer_config}" "port"
32 config_get via
"${peer_config}" "via"
34 [ "$cfg" = "$vxlan" ] ||
{
35 # This peer section belongs to another device
40 proto_notify_error
"$cfg" "MISSING_PEER_ADDRESS"
45 ${lladdr:-00:00:00:00:00:00} \
48 ${src_vni:+src_vni $src_vni} \
54 vxlan_generic_setup
() {
62 local port vid ttl tos mtu macaddr zone rxcsum txcsum
63 json_get_vars port vid ttl tos mtu macaddr zone rxcsum txcsum
65 proto_init_update
"$link" 1
68 json_add_string mode
"$mode"
70 [ -n "$tunlink" ] && json_add_string link
"$tunlink"
71 [ -n "$local" ] && json_add_string
local "$local"
72 [ -n "$remote" ] && json_add_string remote
"$remote"
74 [ -n "$ttl" ] && json_add_int ttl
"$ttl"
75 [ -n "$tos" ] && json_add_string tos
"$tos"
76 [ -n "$mtu" ] && json_add_int mtu
"$mtu"
78 json_add_object
'data'
79 [ -n "$port" ] && json_add_int port
"$port"
80 [ -n "$vid" ] && json_add_int id
"$vid"
81 [ -n "$macaddr" ] && json_add_string macaddr
"$macaddr"
82 [ -n "$rxcsum" ] && json_add_boolean rxcsum
"$rxcsum"
83 [ -n "$txcsum" ] && json_add_boolean txcsum
"$txcsum"
89 [ -n "$zone" ] && json_add_string zone
"$zone"
92 proto_send_update
"$cfg"
95 config_foreach proto_vxlan_setup_peer
"vxlan_peer"
101 local ipaddr peeraddr
102 json_get_vars ipaddr peeraddr tunlink
104 ( proto_add_host_dependency
"$cfg" '' "$tunlink" )
106 [ -z "$ipaddr" ] && {
107 local wanif
="$tunlink"
108 if [ -z "$wanif" ] && ! network_find_wan wanif
; then
109 proto_notify_error
"$cfg" "NO_WAN_LINK"
113 if ! network_get_ipaddr ipaddr
"$wanif"; then
114 proto_notify_error
"$cfg" "NO_WAN_LINK"
119 vxlan_generic_setup
"$cfg" 'vxlan' "$ipaddr" "$peeraddr"
122 proto_vxlan6_setup
() {
125 local ip6addr peer6addr
126 json_get_vars ip6addr peer6addr tunlink
128 ( proto_add_host_dependency
"$cfg" '' "$tunlink" )
130 [ -z "$ip6addr" ] && {
131 local wanif
="$tunlink"
132 if [ -z "$wanif" ] && ! network_find_wan6 wanif
; then
133 proto_notify_error
"$cfg" "NO_WAN_LINK"
137 if ! network_get_ipaddr6 ip6addr
"$wanif"; then
138 proto_notify_error
"$cfg" "NO_WAN_LINK"
143 vxlan_generic_setup
"$cfg" 'vxlan6' "$ip6addr" "$peer6addr"
146 proto_vxlan_teardown
() {
150 proto_vxlan6_teardown
() {
154 vxlan_generic_init_config
() {
158 proto_config_add_string
"tunlink"
159 proto_config_add_string
"zone"
161 proto_config_add_int
"vid"
162 proto_config_add_int
"port"
163 proto_config_add_int
"ttl"
164 proto_config_add_int
"tos"
165 proto_config_add_int
"mtu"
166 proto_config_add_boolean
"rxcsum"
167 proto_config_add_boolean
"txcsum"
168 proto_config_add_string
"macaddr"
171 proto_vxlan_init_config
() {
172 vxlan_generic_init_config
173 proto_config_add_string
"ipaddr"
174 proto_config_add_string
"peeraddr"
177 proto_vxlan6_init_config
() {
178 vxlan_generic_init_config
179 proto_config_add_string
"ip6addr"
180 proto_config_add_string
"peer6addr"
183 [ -n "$INCLUDE_ONLY" ] ||
{