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:
parent
8bcd0975af
commit
0d6f957196
38
package/gluon-core/files/lib/netifd/proto/gluon_wired.sh
Executable file
38
package/gluon-core/files/lib/netifd/proto/gluon_wired.sh
Executable 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
|
@ -3,14 +3,24 @@
|
|||||||
local site = require 'gluon.site_config'
|
local site = require 'gluon.site_config'
|
||||||
local uci = require('simple-uci').cursor()
|
local uci = require('simple-uci').cursor()
|
||||||
|
|
||||||
if not uci:get('network', 'mesh_wan') then
|
local old_proto = uci:get('network', 'mesh_wan', 'proto')
|
||||||
uci:section('network', 'interface', 'mesh_wan', {
|
|
||||||
ifname = 'br-wan',
|
uci:section('network', 'interface', 'mesh_wan', {
|
||||||
proto = 'gluon_mesh',
|
ifname = 'br-wan',
|
||||||
transitive = true,
|
proto = 'gluon_wired',
|
||||||
fixed_mtu = true,
|
index = 0,
|
||||||
auto = site.mesh_on_wan or false,
|
})
|
||||||
})
|
|
||||||
|
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
|
end
|
||||||
|
|
||||||
|
uci:delete('network', 'mesh_wan', 'fixed_mtu')
|
||||||
|
|
||||||
uci:save('network')
|
uci:save('network')
|
||||||
|
@ -10,13 +10,15 @@ if not sysconfig.lan_ifname then
|
|||||||
os.exit(0)
|
os.exit(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local old_proto = uci:get('network', 'mesh_lan', 'proto')
|
||||||
|
|
||||||
uci:section('network', 'interface', 'mesh_lan', {
|
uci:section('network', 'interface', 'mesh_lan', {
|
||||||
ifname = sysconfig.lan_ifname,
|
ifname = sysconfig.lan_ifname,
|
||||||
type = 'bridge',
|
type = 'bridge',
|
||||||
igmp_snooping = false,
|
igmp_snooping = false,
|
||||||
proto = 'gluon_mesh',
|
proto = 'gluon_wired',
|
||||||
transitive = true,
|
index = 4,
|
||||||
fixed_mtu = true,
|
legacy = old_proto == 'gluon_mesh',
|
||||||
})
|
})
|
||||||
|
|
||||||
if uci:get('network', 'mesh_lan', 'auto') == nil then
|
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)
|
uci:set('network', 'mesh_lan', 'auto', enable or false)
|
||||||
end
|
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')
|
uci:save('network')
|
||||||
|
Loading…
Reference in New Issue
Block a user