From 8e630e9f6dbf943ce6be1c33d13f476422b1f52d Mon Sep 17 00:00:00 2001 From: David Bauer Date: Wed, 19 May 2021 23:44:59 +0200 Subject: [PATCH] gluon-core: adapt to new bridge handling --- .../luasrc/lib/gluon/upgrade/020-interfaces | 7 +++++ .../luasrc/lib/gluon/upgrade/110-network | 14 +++++++-- .../lib/gluon/upgrade/220-interface-lan | 30 ++++++++++++------- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces index 5bb1926d..d9183e4f 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces @@ -73,4 +73,11 @@ end uci:delete('network', 'lan') uci:delete('network', 'wan') +uci:foreach('network', 'device', function(dev) + if dev['type'] ~= 'bridge' then return end + if dev['ifname'] ~= 'lan' or dev['ifname'] ~= 'wan' then return end + + uci:delete('network', dev['.name']) +end) + uci:save('network') diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/110-network b/package/gluon-core/luasrc/lib/gluon/upgrade/110-network index 79c50d27..777e6437 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/110-network +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/110-network @@ -1,12 +1,22 @@ #!/usr/bin/lua local uci = require('simple-uci').cursor() +local util = require 'gluon.util' local sysconfig = require 'gluon.sysconfig' +local interfaces = {} +for wanif in sysconfig.wan_ifname:gmatch('%S+') do + util.add_to_set(interfaces, wanif) +end + +uci:section('network', 'device', 'br_wan', { + ifname = 'br-wan', + type = 'bridge', + ports = interfaces, +}) uci:section('network', 'interface', 'wan', { - ifname = sysconfig.wan_ifname, - type = 'bridge', + ifname = 'br-wan', igmp_snooping = true, multicast_querier = false, peerdns = false, diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/220-interface-lan b/package/gluon-core/luasrc/lib/gluon/upgrade/220-interface-lan index 19ccfb49..f95851ee 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/220-interface-lan +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/220-interface-lan @@ -11,28 +11,30 @@ if not sysconfig.lan_ifname then end uci:section('network', 'interface', 'mesh_lan', { - ifname = sysconfig.lan_ifname, + ifname = 'br-mesh_lan', igmp_snooping = false, proto = 'gluon_wired', index = 4, vxlan = site.mesh.vxlan(true), }) -if sysconfig.lan_ifname:match(' ') then - uci:set('network', 'mesh_lan', 'type', 'bridge') -else - uci:delete('network', 'mesh_lan', 'type') -end +uci:delete('network', 'mesh_lan', 'type') + +uci:section('network', 'device', 'br_mesh_lan', { + name = 'br-mesh_lan', + type = 'bridge', +}) local enable = site.mesh_on_lan(false) local old_auto = uci:get('network', 'mesh_lan', 'auto') local old_disabled = uci:get('network', 'mesh_lan', 'disabled') -if old_auto ~= nil or old_disabled ~= nil then - enable = old_auto ~= '0' and old_disabled ~= '1' +local new_disabled = uci:get('network', 'br_mesh_lan', 'disabled') +if old_auto ~= nil or old_disabled ~= nil or new_disabled ~= nil then + enable = old_auto ~= '0' and old_disabled ~= '1' and new_disabled ~= '1' end if enable then - local interfaces = uci:get_list('network', 'client', 'ifname') + local interfaces = uci:get_list('network', 'br_client', 'ports') if interfaces then for lanif in sysconfig.lan_ifname:gmatch('%S+') do @@ -44,12 +46,20 @@ if enable then end end -uci:set('network', 'mesh_lan', 'disabled', not enable) +uci:set('network', 'br_mesh_lan', 'disabled', not enable) +if enable then + local interfaces = {} + for lanif in sysconfig.lan_ifname:gmatch('%S+') do + util.add_to_set(interfaces, lanif) + end + uci:set('network', 'br_mesh_lan', 'ports', interfaces) +end if uci:get('network', 'mesh_lan', 'transitive') == nil then uci:set('network', 'mesh_lan', 'transitive', true) end +uci:delete('network', 'mesh_lan', 'disabled') uci:delete('network', 'mesh_lan', 'auto') uci:delete('network', 'mesh_lan', 'fixed_mtu') uci:delete('network', 'mesh_lan', 'legacy')