X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Fluci-base%2Fluasrc%2Fmodel%2Fnetwork.lua;h=741daa48169759b2cf6ca71d73bf052220fce640;hp=ce9259f310ae2b84dc8d9125bda23260f789b4f6;hb=57e58b9bf9e9bbf4eeed0daf0515280376d7e611;hpb=e626599c261e1795f49bbe59b0476fd5496bf079 diff --git a/modules/luci-base/luasrc/model/network.lua b/modules/luci-base/luasrc/model/network.lua index ce9259f31..741daa481 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 @@ -650,8 +666,8 @@ function get_status_by_address(self, addr) end function get_wannet(self) - local net = self:get_status_by_route("0.0.0.0", 0) - return net and network(net) + local net, stat = self:get_status_by_route("0.0.0.0", 0) + return net and network(net, stat.proto) end function get_wandev(self) @@ -660,8 +676,8 @@ function get_wandev(self) end function get_wan6net(self) - local net = self:get_status_by_route("::", 0) - return net and network(net) + local net, stat = self:get_status_by_route("::", 0) + return net and network(net, stat.proto) end function get_wan6dev(self)