libs/core: more fixes in network model
[project/luci.git] / libs / core / luasrc / model / network.lua
index 26344c2..5e7d7d6 100644 (file)
@@ -778,42 +778,39 @@ function network.get_interface(self)
 end
 
 function network.get_interfaces(self)
-       local ifaces = { }
+       if self:is_bridge() or (self:is_virtual() and not self:is_floating()) then
+               local ifaces = { }
 
-       local ifn
-       local nfs = { }
-       for ifn in utl.imatch(self:get("ifname")) do
-               ifn = ifn:match("^[^:/]+")
-               nfs[ifn] = interface(ifn, self)
-       end
+               local ifn
+               local nfs = { }
+               for ifn in utl.imatch(self:get("ifname")) do
+                       ifn = ifn:match("^[^:/]+")
+                       nfs[ifn] = interface(ifn, self)
+               end
 
-       for ifn in utl.kspairs(nfs) do
-               ifaces[#ifaces+1] = nfs[ifn]
-       end
+               for ifn in utl.kspairs(nfs) do
+                       ifaces[#ifaces+1] = nfs[ifn]
+               end
 
-       local num = { }
-       local wfs = { }
-       uci_r: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.network%d" %{ s.device, num[s.device] }
-                                       wfs[ifn] = interface(ifn, self)
+               local num = { }
+               local wfs = { }
+               uci_r: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.network%d" %{ s.device, num[s.device] }
+                                               wfs[ifn] = interface(ifn, self)
+                                       end
                                end
-                       end
-               end)
+                       end)
 
-       for ifn in utl.kspairs(wfs) do
-               ifaces[#ifaces+1] = wfs[ifn]
+               for ifn in utl.kspairs(wfs) do
+                       ifaces[#ifaces+1] = wfs[ifn]
+               end
 
-               -- only bridges may cover more than one interface
-               --if not self:is_bridge() then
-               --      break
-               --end
+               return ifaces
        end
-
-       return ifaces
 end
 
 function network.contains_interface(self, ifname)