projects
/
project
/
luci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
libs/core: fixes for network model
[project/luci.git]
/
libs
/
core
/
luasrc
/
model
/
network.lua
diff --git
a/libs/core/luasrc/model/network.lua
b/libs/core/luasrc/model/network.lua
index
e6afaa4
..
718f07d
100644
(file)
--- a/
libs/core/luasrc/model/network.lua
+++ b/
libs/core/luasrc/model/network.lua
@@
-32,7
+32,7
@@
module "luci.model.network"
local ub = uct.bind("network")
local ub = uct.bind("network")
-local ifs, brs
+local ifs, brs
, sws
function init(cursor)
if cursor then
function init(cursor)
if cursor then
@@
-42,11
+42,13
@@
function init(cursor)
ifs = { }
brs = { }
ifs = { }
brs = { }
+ sws = { }
-- read interface information
local n, i
for n, i in ipairs(nxo.getifaddrs()) do
local name = i.name:match("[^:]+")
-- read interface information
local n, i
for n, i in ipairs(nxo.getifaddrs()) do
local name = i.name:match("[^:]+")
+ local prnt = name:match("^([^%.]+)%.")
if not _M:ignore_interface(name) then
ifs[name] = ifs[name] or {
if not _M:ignore_interface(name) then
ifs[name] = ifs[name] or {
@@
-58,6
+60,11
@@
function init(cursor)
ip6addrs = { }
}
ip6addrs = { }
}
+ if prnt then
+ sws[name] = true
+ sws[prnt] = true
+ end
+
if i.family == "packet" then
ifs[name].flags = i.flags
ifs[name].stats = i.data
if i.family == "packet" then
ifs[name].flags = i.flags
ifs[name].stats = i.data
@@
-229,9
+236,7
@@
end
function network.get_interfaces(self)
local ifaces = { }
local iface
function network.get_interfaces(self)
local ifaces = { }
local iface
- for _, iface in ub:list(
- (self:ifname() or '') .. ' ' .. (self:device() or '')
- ) do
+ for _, iface in ipairs(ub:list(self:ifname())) do
iface = iface:match("[^:]+")
if ifs[iface] then
ifaces[#ifaces+1] = interface(iface)
iface = iface:match("[^:]+")
if ifs[iface] then
ifaces[#ifaces+1] = interface(iface)
@@
-242,9
+247,7
@@
end
function network.contains_interface(self, iface)
local i
function network.contains_interface(self, iface)
local i
- local ifaces = ub:list(
- (self:ifname() or '') .. ' ' .. (self:device() or '')
- )
+ local ifaces = ub:list(self:ifname())
if type(iface) ~= "string" then
iface = iface:name()
if type(iface) ~= "string" then
iface = iface:name()
@@
-290,7
+293,7
@@
function interface.type(self)
return "wifi"
elseif brs[self.ifname] then
return "bridge"
return "wifi"
elseif brs[self.ifname] then
return "bridge"
- elseif self.ifname:match("%.") then
+ elseif s
ws[self.ifname] or s
elf.ifname:match("%.") then
return "switch"
else
return "ethernet"
return "switch"
else
return "ethernet"