summaryrefslogtreecommitdiff
path: root/python/vyos/ifconfig/stp.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-10-17 20:06:36 +0200
committerChristian Poessinger <christian@poessinger.com>2020-10-17 22:06:49 +0200
commitb5ef10cfeb839dca28ae5376bfabafe29ae07aec (patch)
tree10f5858d48e91f93ca440d2cd24c5c78c7a36add /python/vyos/ifconfig/stp.py
parent1353c006469754ae96c1cc4e6238d80e735985bc (diff)
downloadvyos-1x-b5ef10cfeb839dca28ae5376bfabafe29ae07aec.tar.gz
vyos-1x-b5ef10cfeb839dca28ae5376bfabafe29ae07aec.zip
ifconfig: T2985: support on demand bridge creation
The current implementation for bridge based interfaces has an issue which is caused by priority inheritance. We always assumed that the bridge interface will be created last, but this may not be true in all cases, where some interfaces will be created "on demand" - e.g. OpenVPN or late (VXLAN, GENEVE). As we already have a bunch of verify steps in place we should not see a bridge interface leak to the underlaying infrastructure code. This means, whenever an interface will be member of a bridge, and the bridge does yet not exist, we will create it in advance in the interface context, as the bridge code will be run in the same commit but maybe sooner or later. This will also be the solution for T2924.
Diffstat (limited to 'python/vyos/ifconfig/stp.py')
-rw-r--r--python/vyos/ifconfig/stp.py70
1 files changed, 0 insertions, 70 deletions
diff --git a/python/vyos/ifconfig/stp.py b/python/vyos/ifconfig/stp.py
deleted file mode 100644
index 5e83206c2..000000000
--- a/python/vyos/ifconfig/stp.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright 2019 VyOS maintainers and contributors <maintainers@vyos.io>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# 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 vyos.ifconfig.interface import Interface
-
-from vyos.validate import assert_positive
-
-
-class STP:
- """
- A spanning-tree capable interface. This applies only to bridge port member
- interfaces!
- """
-
- @classmethod
- def enable (cls, adaptee):
- adaptee._sysfs_set = {**adaptee._sysfs_set, **cls._sysfs_set}
- adaptee.set_path_cost = cls.set_path_cost
- adaptee.set_path_priority = cls.set_path_priority
- return adaptee
-
- _sysfs_set = {
- 'path_cost': {
- # XXX: we should set a maximum
- 'validate': assert_positive,
- 'location': '/sys/class/net/{ifname}/brport/path_cost',
- 'errormsg': '{ifname} is not a bridge port member'
- },
- 'path_priority': {
- # XXX: we should set a maximum
- 'validate': assert_positive,
- 'location': '/sys/class/net/{ifname}/brport/priority',
- 'errormsg': '{ifname} is not a bridge port member'
- },
- }
-
- def set_path_cost(self, cost):
- """
- Set interface path cost, only relevant for STP enabled interfaces
-
- Example:
-
- >>> from vyos.ifconfig import Interface
- >>> Interface('eth0').set_path_cost(4)
- """
- self.set_interface('path_cost', cost)
-
- def set_path_priority(self, priority):
- """
- Set interface path priority, only relevant for STP enabled interfaces
-
- Example:
-
- >>> from vyos.ifconfig import Interface
- >>> Interface('eth0').set_path_priority(4)
- """
- self.set_interface('path_priority', priority)