gluon-core: introduce new gluon_wired netifd proto for wired meshing

The new proto will simplify the switch to VXLAN encapsulation.
This commit is contained in:
Matthias Schiffer 2017-06-21 17:14:41 +02:00
parent 8bcd0975af
commit 0d6f957196
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
3 changed files with 70 additions and 11 deletions

View File

@ -0,0 +1,38 @@
#!/bin/sh
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
proto_gluon_wired_init_config() {
proto_config_add_boolean transitive
}
proto_gluon_wired_setup() {
local config="$1"
local ifname="$2"
local transitive
json_get_vars transitive
proto_init_update "$ifname" 1
proto_send_update "$config"
json_init
json_add_string name "${config}_mesh"
json_add_string ifname "@${config}"
json_add_string proto 'gluon_mesh'
json_add_boolean fixed_mtu 1
[ -n "$transitive" ] && json_add_boolean transitive "$transitive"
json_close_object
ubus call network add_dynamic "$(json_dump)"
}
proto_gluon_wired_teardown() {
export config="$1"
proto_init_update "*" 0
proto_send_update "$config"
}
add_protocol gluon_wired

View File

@ -3,14 +3,24 @@
local site = require 'gluon.site_config'
local uci = require('simple-uci').cursor()
if not uci:get('network', 'mesh_wan') then
uci:section('network', 'interface', 'mesh_wan', {
ifname = 'br-wan',
proto = 'gluon_mesh',
transitive = true,
fixed_mtu = true,
auto = site.mesh_on_wan or false,
})
local old_proto = uci:get('network', 'mesh_wan', 'proto')
uci:section('network', 'interface', 'mesh_wan', {
ifname = 'br-wan',
proto = 'gluon_wired',
index = 0,
})
if uci:get('network', 'mesh_wan', 'auto') == nil then
uci:set('network', 'mesh_wan', 'auto', site.mesh_on_wan or false)
end
if uci:get('network', 'mesh_wan', 'transitive') == nil then
uci:set('network', 'mesh_wan', 'transitive', true)
end
if uci:get('network', 'mesh_wan', 'legacy') == nil then
uci:set('network', 'mesh_wan', 'legacy', old_proto == 'gluon_mesh')
end
uci:delete('network', 'mesh_wan', 'fixed_mtu')
uci:save('network')

View File

@ -10,13 +10,15 @@ if not sysconfig.lan_ifname then
os.exit(0)
end
local old_proto = uci:get('network', 'mesh_lan', 'proto')
uci:section('network', 'interface', 'mesh_lan', {
ifname = sysconfig.lan_ifname,
type = 'bridge',
igmp_snooping = false,
proto = 'gluon_mesh',
transitive = true,
fixed_mtu = true,
proto = 'gluon_wired',
index = 4,
legacy = old_proto == 'gluon_mesh',
})
if uci:get('network', 'mesh_lan', 'auto') == nil then
@ -38,4 +40,13 @@ if uci:get('network', 'mesh_lan', 'auto') == nil then
uci:set('network', 'mesh_lan', 'auto', enable or false)
end
if uci:get('network', 'mesh_lan', 'transitive') == nil then
uci:set('network', 'mesh_lan', 'transitive', true)
end
if uci:get('network', 'mesh_lan', 'legacy') == nil then
uci:set('network', 'mesh_lan', 'legacy', old_proto == 'gluon_mesh')
end
uci:delete('network', 'mesh_lan', 'fixed_mtu')
uci:save('network')