From 39d0c8f45949b06ece9db05a82341acc4d638980 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Mon, 4 May 2015 21:18:58 +0200 Subject: [PATCH 1/2] mesh-batman-adv: mesh_on_lan This adds mesh_on_lan functionality. A new optional site.conf option, mesh_on_lan, has been added. If set to 'true', all LAN ports will be used for meshing instead of being part of the client bridge. --- docs/user/site.rst | 3 +++ .../gluon-mesh-batman-adv-core/check_site.lua | 1 + .../310-gluon-mesh-batman-adv-core-mesh | 3 ++- ...340-gluon-mesh-batman-adv-core-mesh-on-lan | 23 +++++++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100755 package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/340-gluon-mesh-batman-adv-core-mesh-on-lan diff --git a/docs/user/site.rst b/docs/user/site.rst index 689dd51d..68705ce4 100644 --- a/docs/user/site.rst +++ b/docs/user/site.rst @@ -119,6 +119,9 @@ fastd_mesh_vpn mesh_on_wan : optional Enables the mesh on the WAN port (``true`` or ``false``). +mesh_on_lan : optional + Enables the mesh on the LAN port (``true`` or ``false``). + autoupdater : package Configuration for the autoupdater feature of Gluon. :: diff --git a/package/gluon-mesh-batman-adv-core/check_site.lua b/package/gluon-mesh-batman-adv-core/check_site.lua index baed26cb..e76ca9e9 100644 --- a/package/gluon-mesh-batman-adv-core/check_site.lua +++ b/package/gluon-mesh-batman-adv-core/check_site.lua @@ -13,3 +13,4 @@ for _, config in ipairs({'wifi24', 'wifi5'}) do end need_boolean('mesh_on_wan', false) +need_boolean('mesh_on_lan', false) diff --git a/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/310-gluon-mesh-batman-adv-core-mesh b/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/310-gluon-mesh-batman-adv-core-mesh index c9638c4b..a51b20e2 100755 --- a/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/310-gluon-mesh-batman-adv-core-mesh +++ b/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/310-gluon-mesh-batman-adv-core-mesh @@ -2,6 +2,7 @@ local sysconfig = require 'gluon.sysconfig' local sysctl = require 'gluon.sysctl' +local site = require 'gluon.site_config' local uci = require('luci.model.uci').cursor() @@ -20,7 +21,7 @@ uci:commit('batman-adv') if not uci:get('network', 'client') then local ifname - if sysconfig.lan_ifname then + if sysconfig.lan_ifname and not site.mesh_on_lan then ifname = sysconfig.lan_ifname .. ' bat0' else ifname = 'bat0' 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 new file mode 100755 index 00000000..f9cbde03 --- /dev/null +++ b/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/340-gluon-mesh-batman-adv-core-mesh-on-lan @@ -0,0 +1,23 @@ +#!/usr/bin/lua + +local site = require 'gluon.site_config' +local uci = require 'luci.model.uci' +local util = require 'gluon.util' +local sysconfig = require 'gluon.sysconfig' + +local c = uci.cursor() + +if sysconfig.lan_ifname then + if not c:get('network', 'mesh_lan') then + c:section('network', 'interface', 'mesh_lan', + { ifname = sysconfig.lan_ifname + , proto = 'batadv' + , mesh = 'bat0' + , macaddr = util.generate_mac(1, 1) + , auto = site.mesh_on_lan and 1 or 0 + }) + end +end + +c:save('network') +c:commit('network') From d4c3467bc336581eb9ac9db77277d9d82b8ac9b6 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Mon, 4 May 2015 21:18:58 +0200 Subject: [PATCH 2/2] luci-portconfig: allow toggling of mesh_on_lan --- .../lua/luci/model/cbi/admin/portconfig.lua | 18 ++++++++++++++++++ package/gluon-luci-portconfig/i18n/de.po | 3 +++ .../i18n/gluon-luci-portconfig.pot | 3 +++ 3 files changed, 24 insertions(+) diff --git a/package/gluon-luci-portconfig/files/usr/lib/lua/luci/model/cbi/admin/portconfig.lua b/package/gluon-luci-portconfig/files/usr/lib/lua/luci/model/cbi/admin/portconfig.lua index ccade674..8166539c 100644 --- a/package/gluon-luci-portconfig/files/usr/lib/lua/luci/model/cbi/admin/portconfig.lua +++ b/package/gluon-luci-portconfig/files/usr/lib/lua/luci/model/cbi/admin/portconfig.lua @@ -13,6 +13,7 @@ $Id$ ]]-- local uci = luci.model.uci.cursor() +local sysconfig = require 'gluon.sysconfig' local wan = uci:get_all("network", "wan") local wan6 = uci:get_all("network", "wan6") @@ -86,6 +87,13 @@ o = s:option(Flag, "mesh_wan", translate("Enable meshing on the WAN interface")) o.default = uci:get_bool("network", "mesh_wan", "auto") and o.enabled or o.disabled o.rmempty = false +if sysconfig.lan_ifname then + o = s:option(Flag, "mesh_lan", translate("Enable meshing on the LAN interface")) + o.default = uci:get_bool("network", "mesh_lan", "auto") and o.enabled or o.disabled + o.rmempty = false +end + + function f.handle(self, state, data) if state == FORM_VALID then uci:set("network", "wan", "proto", data.ipv4) @@ -110,6 +118,16 @@ function f.handle(self, state, data) uci:set("network", "mesh_wan", "auto", data.mesh_wan) + if sysconfig.lan_ifname then + uci:set("network", "mesh_lan", "auto", data.mesh_lan) + + if data.mesh_lan == '1' then + uci:set("network", "client", "ifname", "bat0") + else + uci:set("network", "client", "ifname", sysconfig.lan_ifname .. " bat0") + end + end + uci:save("network") uci:commit("network") diff --git a/package/gluon-luci-portconfig/i18n/de.po b/package/gluon-luci-portconfig/i18n/de.po index 6cc06e20..2197fdbe 100644 --- a/package/gluon-luci-portconfig/i18n/de.po +++ b/package/gluon-luci-portconfig/i18n/de.po @@ -19,6 +19,9 @@ msgstr "Automatisch (RA/DHCPv6)" msgid "Enable meshing on the WAN interface" msgstr "Mesh auf dem WAN-Port aktivieren" +msgid "Enable meshing on the LAN interface" +msgstr "Mesh auf dem LAN-Port aktivieren" + msgid "Static" msgstr "Statisch" diff --git a/package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot b/package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot index 1800f8d0..31ac71d3 100644 --- a/package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot +++ b/package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot @@ -10,6 +10,9 @@ msgstr "" msgid "Enable meshing on the WAN interface" msgstr "" +msgid "Enable meshing on the LAN interface" +msgstr "" + msgid "Static" msgstr ""