Browse Source

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

The new proto will simplify the switch to VXLAN encapsulation.
Matthias Schiffer 6 years ago
parent
commit
0d6f957196

+ 38 - 0
package/gluon-core/files/lib/netifd/proto/gluon_wired.sh

@@ -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

+ 18 - 8
package/gluon-core/luasrc/lib/gluon/upgrade/210-interface-wan

@@ -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')

+ 14 - 3
package/gluon-core/luasrc/lib/gluon/upgrade/220-interface-lan

@@ -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')