X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fcore%2Fluasrc%2Fmodel%2Fnetwork.lua;h=eff84f8108e0935e378a0bcc997361062be51775;hp=a85def89a2619d0189c92b8d1f611eec4e40378b;hb=84cbbf39682ebfc5f662d820294c76988110d55c;hpb=ce024e350a52d8e1520d10d3e5c648e44f63edfe diff --git a/libs/core/luasrc/model/network.lua b/libs/core/luasrc/model/network.lua index a85def89a..eff84f810 100644 --- a/libs/core/luasrc/model/network.lua +++ b/libs/core/luasrc/model/network.lua @@ -449,6 +449,7 @@ function get_interfaces(self) local ifaces = { } local seen = { } local nfs = { } + local baseof = { } -- find normal interfaces _uci_real:foreach("network", "interface", @@ -470,9 +471,26 @@ function get_interfaces(self) -- find vlan interfaces _uci_real:foreach("network", "switch_vlan", function(s) - local base = s.device or "-" - if not base:match("^eth%d") then - base = "eth0" + if not s.device then + return + end + + local base = baseof[s.device] + if not base then + if not s.device:match("^eth%d") then + local l + for l in utl.execi("swconfig dev %q help 2>/dev/null" % s.device) do + if not base then + base = l:match("^%w+: (%w+)") + end + end + if not base or not base:match("^eth%d") then + base = "eth0" + end + else + base = s.device + end + baseof[s.device] = base end local vid = tonumber(s.vid or s.vlan) @@ -755,7 +773,7 @@ function protocol.is_floating(self) end function protocol.is_empty(self) - if self:is_virtual() then + if self:is_floating() then return false else local rv = true @@ -819,17 +837,17 @@ function protocol.get_interface(self) else local ifn = nil local num = { } - for ifn in utl.imatch(_uci_state:get("network", self.sid, "ifname")) do + for ifn in utl.imatch(_uci_real:get("network", self.sid, "ifname")) do ifn = ifn:match("^[^:/]+") return ifn and interface(ifn, self) end ifn = nil - _uci_state:foreach("wireless", "wifi-iface", + _uci_real:foreach("wireless", "wifi-iface", function(s) if s.device then num[s.device] = num[s.device] and num[s.device] + 1 or 1 if s.network == self.sid then - ifn = s.ifname or "%s.network%d" %{ s.device, num[s.device] } + ifn = "%s.network%d" %{ s.device, num[s.device] } return false end end @@ -909,7 +927,10 @@ interface = utl.class() function interface.__init__(self, ifname, network) local wif = _wifi_lookup(ifname) - if wif then self.wif = wifinet(wif) end + if wif then + self.wif = wifinet(wif) + self.ifname = _uci_state:get("wireless", wif, "ifname") + end self.ifname = self.ifname or ifname self.dev = _interfaces[self.ifname]