Unverified Commit 1c38906e authored by David Bauer's avatar David Bauer Committed by GitHub
Browse files

Merge pull request #2163 from lemoer/pr_vpn_as_gluon_wired

Generalize proto "gluon_wired.sh"
parents 545713ac bbecd44b
......@@ -7,6 +7,8 @@ init_proto "$@"
proto_gluon_wired_init_config() {
proto_config_add_boolean transitive
proto_config_add_int index
proto_config_add_boolean vxlan
proto_config_add_string vxpeer6addr
}
xor2() {
......@@ -14,8 +16,24 @@ xor2() {
echo -n "${1:1:1}" | tr '0123456789abcdef' '23016745ab89efcd'
}
is_layer3_device () {
local addrlen="$(cat "/sys/class/net/$1/addr_len")"
test "$addrlen" -eq 0
}
# shellcheck disable=SC2086
interface_linklocal() {
if is_layer3_device "$1"; then
if ! ubus call network.interface dump | \
jsonfilter -e "@.interface[@.l3_device='$1']['ipv6-address'][*].address" | \
grep -e '^fe[89ab][0-9a-f]' -m 1; then
proto_notify_error "$config" "MISSING_LL_ADDR_ON_LOWER_IFACE"
proto_block_restart "$config"
exit 1
fi
return
fi
local macaddr="$(ubus call network.device status '{"name": "'"$1"'"}' | jsonfilter -e '@.macaddr')"
local oldIFS="$IFS"; IFS=':'; set -- $macaddr; IFS="$oldIFS"
......@@ -28,15 +46,17 @@ proto_gluon_wired_setup() {
local meshif="$config"
local vxlan="$(lua -e 'print(require("gluon.site").mesh.vxlan(true))')"
local transitive index vxlan vxpeer6addr
json_get_vars transitive index vxlan vxpeer6addr
local transitive index
json_get_vars transitive index
# default args
[ -z "$vxlan" ] && vxlan=1
[ -z "$vxpeer6addr" ] && vxpeer6addr='ff02::15c'
proto_init_update "$ifname" 1
proto_send_update "$config"
if [ "$vxlan" = 'true' ]; then
if [ "$vxlan" -eq 1 ]; then
meshif="vx_$config"
json_init
......@@ -44,8 +64,9 @@ proto_gluon_wired_setup() {
[ -n "$index" ] && json_add_string macaddr "$(lua -e "print(require('gluon.util').generate_mac($index))")"
json_add_string proto 'vxlan6'
json_add_string tunlink "$config"
# ip6addr (the lower interface ip6) is used by the vxlan.sh proto
json_add_string ip6addr "$(interface_linklocal "$ifname")"
json_add_string peer6addr 'ff02::15c'
json_add_string peer6addr "$vxpeer6addr"
json_add_int vid "$(lua -e 'print(tonumber(require("gluon.util").domain_seed_bytes("gluon-mesh-vxlan", 3), 16))')"
json_add_boolean rxcsum '0'
json_add_boolean txcsum '0'
......
......@@ -7,6 +7,7 @@ uci:section('network', 'interface', 'mesh_wan', {
ifname = 'br-wan',
proto = 'gluon_wired',
index = 0,
vxlan = site.mesh.vxlan(true),
})
local enable = site.mesh_on_wan(false)
......
......@@ -15,6 +15,7 @@ uci:section('network', 'interface', 'mesh_lan', {
igmp_snooping = false,
proto = 'gluon_wired',
index = 4,
vxlan = site.mesh.vxlan(true),
})
if sysconfig.lan_ifname:match(' ') then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment