Changeset 5391

Show
Ignore:
Timestamp:
10/10/09 15:53:39 (4 years ago)
Author:
jow
Message:

libs/core: fixes for network model

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/libs/core/luasrc/model/network.lua

    r5387 r5391  
    3333 
    3434local ub = uct.bind("network") 
    35 local ifs, brs 
     35local ifs, brs, sws 
    3636 
    3737function init(cursor) 
     
    4343        ifs = { } 
    4444        brs = { } 
     45        sws = { } 
    4546 
    4647        -- read interface information 
     
    4849        for n, i in ipairs(nxo.getifaddrs()) do 
    4950            local name = i.name:match("[^:]+") 
     51            local prnt = name:match("^([^%.]+)%.") 
    5052 
    5153            if not _M:ignore_interface(name) then 
     
    5860                    ip6addrs = { } 
    5961                } 
     62 
     63                if prnt then 
     64                    sws[name] = true 
     65                    sws[prnt] = true 
     66                end 
    6067 
    6168                if i.family == "packet" then 
     
    230237    local ifaces = { } 
    231238    local iface 
    232     for _, iface in ub:list( 
    233         (self:ifname() or '') .. ' ' .. (self:device() or '') 
    234     ) do 
     239    for _, iface in ipairs(ub:list(self:ifname())) do 
    235240        iface = iface:match("[^:]+") 
    236241        if ifs[iface] then 
     
    243248function network.contains_interface(self, iface) 
    244249    local i 
    245     local ifaces = ub:list( 
    246         (self:ifname() or '') .. ' ' .. (self:device() or '') 
    247     ) 
     250    local ifaces = ub:list(self:ifname()) 
    248251 
    249252    if type(iface) ~= "string" then 
     
    291294    elseif brs[self.ifname] then 
    292295        return "bridge" 
    293     elseif self.ifname:match("%.") then 
     296    elseif sws[self.ifname] or self.ifname:match("%.") then 
    294297        return "switch" 
    295298    else