blob: 8b3a0a53d47c675fcf89981061a250b5f526df3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
#!/bin/sh
[ -n "$INCLUDE_ONLY" ] || {
. /lib/functions.sh
. /lib/functions/network.sh
. ../netifd-proto.sh
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"
local local="$3"
local remote="$4"
local link="$cfg"
local port vid ttl tos mtu macaddr zone rxcsum txcsum srcportmin srcportmax ageing maxaddress learning proxy l2miss l3miss gbp
json_get_vars port vid ttl tos mtu macaddr zone rxcsum txcsum srcportmin srcportmax ageing maxaddress learning proxy l2miss l3miss gbp
proto_init_update "$link" 1
proto_add_tunnel
json_add_string mode "$mode"
[ -n "$tunlink" ] && json_add_string link "$tunlink"
[ -n "$local" ] && json_add_string local "$local"
[ -n "$remote" ] && json_add_string remote "$remote"
[ -n "$ttl" ] && json_add_int ttl "$ttl"
[ -n "$tos" ] && json_add_string tos "$tos"
[ -n "$mtu" ] && json_add_int mtu "$mtu"
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
proto_add_data
[ -n "$zone" ] && json_add_string zone "$zone"
proto_close_data
proto_send_update "$cfg"
config_load network
config_foreach proto_vxlan_setup_peer "vxlan_peer"
}
proto_vxlan_setup() {
local cfg="$1"
local ipaddr peeraddr
json_get_vars ipaddr peeraddr tunlink
( 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
}
vxlan_generic_setup "$cfg" 'vxlan' "$ipaddr" "$peeraddr"
}
proto_vxlan6_setup() {
local cfg="$1"
local ip6addr peer6addr
json_get_vars ip6addr peer6addr tunlink
( 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
}
vxlan_generic_setup "$cfg" 'vxlan6' "$ip6addr" "$peer6addr"
}
proto_vxlan_teardown() {
local cfg="$1"
}
proto_vxlan6_teardown() {
local cfg="$1"
}
vxlan_generic_init_config() {
no_device=1
available=1
proto_config_add_string "tunlink"
proto_config_add_string "zone"
proto_config_add_int "vid"
proto_config_add_int "port"
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() {
vxlan_generic_init_config
proto_config_add_string "ipaddr"
proto_config_add_string "peeraddr"
}
proto_vxlan6_init_config() {
vxlan_generic_init_config
proto_config_add_string "ip6addr"
proto_config_add_string "peer6addr"
}
[ -n "$INCLUDE_ONLY" ] || {
add_protocol vxlan
add_protocol vxlan6
}
|