diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-09-21 22:21:12 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-09-21 22:21:13 +0200 |
commit | 79b1ab8dc67c9011a3d5e5397ad4d73a6c537d80 (patch) | |
tree | 3fe2ce42be3be7a2f396bd75087414858c8d963f | |
parent | d22b476e0e1ca2a173ecf9c85596b4f02646e772 (diff) | |
download | vyos-1x-79b1ab8dc67c9011a3d5e5397ad4d73a6c537d80.tar.gz vyos-1x-79b1ab8dc67c9011a3d5e5397ad4d73a6c537d80.zip |
bridge: ifconfig: T2653: only delete member interfaces which still exist
When removing e.g. a macsec interface and also its associated member interface
from the bridge, it will happen that the macsec interface instance is long gone
before we reach the code in the bridge interface which will remove it from the
bridge itself.
When this is the case, we can not call BridgeIf.del_port() as it will throw an
exception that the interface does not exist. We now only remove a bridge member
if the interface in question is still available in the kernel.
-rw-r--r-- | python/vyos/ifconfig/bridge.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/python/vyos/ifconfig/bridge.py b/python/vyos/ifconfig/bridge.py index 4c76fe996..c133a56fc 100644 --- a/python/vyos/ifconfig/bridge.py +++ b/python/vyos/ifconfig/bridge.py @@ -13,6 +13,8 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see <http://www.gnu.org/licenses/>. +from netifaces import interfaces + from vyos.ifconfig.interface import Interface from vyos.ifconfig.stp import STP from vyos.validate import assert_boolean @@ -228,8 +230,8 @@ class BridgeIf(Interface): # remove interface from bridge tmp = vyos_dict_search('member.interface_remove', config) - if tmp: - for member in tmp: + for member in (tmp or []): + if member in interfaces(): self.del_port(member) STPBridgeIf = STP.enable(BridgeIf) |