summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-11-21 00:31:06 +0100
committerJo-Philipp Wich <jow@openwrt.org>2015-11-21 00:31:06 +0100
commit55f458326dc77dd35dce2c22df2353b2a0192627 (patch)
treeb1984838ef9a53eef3592d44e0fe4c473a50d3a3
parentfbfa62627f66f98b6dd37ed6050c9b99f2479881 (diff)
luci-base: use board.json to infer switch netdev
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
-rw-r--r--modules/luci-base/luasrc/model/network.lua18
1 files changed, 17 insertions, 1 deletions
diff --git a/modules/luci-base/luasrc/model/network.lua b/modules/luci-base/luasrc/model/network.lua
index ce9259f310..81fc416fed 100644
--- a/modules/luci-base/luasrc/model/network.lua
+++ b/modules/luci-base/luasrc/model/network.lua
@@ -16,6 +16,7 @@ local utl = require "luci.util"
local dsp = require "luci.dispatcher"
local uci = require "luci.model.uci"
local lng = require "luci.i18n"
+local jsc = require "luci.jsonc"
module "luci.model.network"
@@ -473,6 +474,21 @@ function get_interface(self, i)
end
end
+local function swdev_from_board_json()
+ local boardinfo = jsc.parse(nfs.readfile("/etc/board.json") or "")
+ if type(boardinfo) == "table" and type(boardinfo.network) == "table" then
+ local net, val
+ for net, val in pairs(boardinfo.network) do
+ if type(val) == "table" and type(val.ifname) == "string" and
+ val.create_vlan == true
+ then
+ return val.ifname
+ end
+ end
+ end
+ return nil
+end
+
function get_interfaces(self)
local iface
local ifaces = { }
@@ -514,7 +530,7 @@ function get_interfaces(self)
end
end
if not base or not base:match("^eth%d") then
- base = "eth0"
+ base = swdev_from_board_json() or "eth0"
end
else
base = s.device