luci-base: network.lua: fix bridge related functions 1951/head
authorAnton Kikin <a.kikin@tano-systems.com>
Sun, 15 Jul 2018 12:55:04 +0000 (15:55 +0300)
committerAnton Kikin <a.kikin@tano-systems.com>
Sat, 7 Dec 2019 19:28:17 +0000 (22:28 +0300)
This commit fixes these bugs:

1. Functions interface.bridge_id() and interface.bridge_stp() uses self.br field
   that is not exists at all

2. Function interface.is_bridgeport() return true only for bridge interface, not for
   bridge port interfaces.

Signed-off-by: Anton Kikin <a.kikin@tano-systems.com>
modules/luci-compat/luasrc/model/network.lua

index b3fc2a7c28db7ae191048431f289eee23e356835..67a1cc402a08c852bbc2d9b6474edc52a04d4e18 100644 (file)
@@ -371,6 +371,7 @@ function init(cursor)
                                        b.ifnames[1].bridge = b
                                end
                                _bridge[r[1]] = b
+                               _interfaces[r[1]].bridge = b
                        elseif b then
                                b.ifnames[#b.ifnames+1] = _interfaces[r[2]]
                                b.ifnames[#b.ifnames].bridge = b
@@ -1452,16 +1453,16 @@ function interface.ports(self)
 end
 
 function interface.bridge_id(self)
-       if self.br then
-               return self.br.id
+       if self.dev and self.dev.bridge then
+               return self.dev.bridge.id
        else
                return nil
        end
 end
 
 function interface.bridge_stp(self)
-       if self.br then
-               return self.br.stp
+       if self.dev and self.dev.bridge then
+               return self.dev.bridge.stp
        else
                return false
        end
@@ -1480,7 +1481,8 @@ function interface.is_bridge(self)
 end
 
 function interface.is_bridgeport(self)
-       return self.dev and self.dev.bridge and true or false
+       return self.dev and self.dev.bridge and
+              (self.dev.bridge.name != self:name()) and true or false
 end
 
 function interface.tx_bytes(self)