From 937fe715c76258c2ba0e3335b8e3f7a6d58ee636 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer <mschiffer@universe-factory.net> Date: Wed, 27 Apr 2016 12:20:27 +0200 Subject: [PATCH] gluon-mesh-batman-adv-core: make mesh_lan config a bridge There are a few devices which have more than one LAN interface (for example some revision of the TL-WR941ND, which uses a DSA-based switch, so each switch port has its own netdev.) On these devices we need a bridge for mesh-on-lan (as the alternative of adding them to batman-adv individually would need too many MAC addresses.) --- ...340-gluon-mesh-batman-adv-core-mesh-on-lan | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/340-gluon-mesh-batman-adv-core-mesh-on-lan b/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/340-gluon-mesh-batman-adv-core-mesh-on-lan index cbc9cd947..99ca42132 100755 --- a/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/340-gluon-mesh-batman-adv-core-mesh-on-lan +++ b/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/340-gluon-mesh-batman-adv-core-mesh-on-lan @@ -7,7 +7,21 @@ local sysconfig = require 'gluon.sysconfig' local uci = require('luci.model.uci').cursor() local lutil = require 'luci.util' -if sysconfig.lan_ifname and not uci:get('network', 'mesh_lan') then +if not sysconfig.lan_ifname then + os.exit(0) +end + +uci:section('network', 'interface', 'mesh_lan', { + ifname = sysconfig.lan_ifname, + type = 'bridge', + igmp_snooping = 0, + proto = 'batadv', + mesh = 'bat0', + mesh_no_rebroadcast = '1', + macaddr = util.generate_mac(6), +}) + +if uci:get('network', 'mesh_lan', 'auto') == nil then local enable = site.mesh_on_lan if enable then @@ -15,22 +29,15 @@ if sysconfig.lan_ifname and not uci:get('network', 'mesh_lan') then if interfaces then for _, lanif in ipairs(lutil.split(sysconfig.lan_ifname, ' ')) do - if lutil.contains(interfaces, lanif) then - enable = false - break + if lutil.contains(interfaces, lanif) then + enable = false + break end end end end - uci:section('network', 'interface', 'mesh_lan', - { ifname = sysconfig.lan_ifname - , proto = 'batadv' - , mesh = 'bat0' - , mesh_no_rebroadcast = '1' - , macaddr = util.generate_mac(6) - , auto = enable and 1 or 0 - }) - - uci:save('network') + uci:set('network', 'mesh_lan', 'auto', enable and 1 or 0) end + +uci:save('network') -- GitLab