summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/vyos/ifconfig/__init__.py1
-rw-r--r--python/vyos/ifconfig/stp.py19
-rwxr-xr-xsrc/conf_mode/interfaces-bridge.py6
3 files changed, 14 insertions, 12 deletions
diff --git a/python/vyos/ifconfig/__init__.py b/python/vyos/ifconfig/__init__.py
index d6584215b..d08a8b528 100644
--- a/python/vyos/ifconfig/__init__.py
+++ b/python/vyos/ifconfig/__init__.py
@@ -23,7 +23,6 @@ from vyos.ifconfig.ethernet import EthernetIf
from vyos.ifconfig.geneve import GeneveIf
from vyos.ifconfig.loopback import LoopbackIf
from vyos.ifconfig.macvlan import MACVLANIf
-from vyos.ifconfig.stp import STPIf
from vyos.ifconfig.vxlan import VXLANIf
from vyos.ifconfig.wireguard import WireGuardIf
from vyos.ifconfig.vtun import VTunIf
diff --git a/python/vyos/ifconfig/stp.py b/python/vyos/ifconfig/stp.py
index 741322d0d..97a3c1ff3 100644
--- a/python/vyos/ifconfig/stp.py
+++ b/python/vyos/ifconfig/stp.py
@@ -19,12 +19,20 @@ from vyos.ifconfig.interface import Interface
from vyos.validate import *
-class STPIf(Interface):
+class STP:
"""
A spanning-tree capable interface. This applies only to bridge port member
interfaces!
"""
- _sysfs_set = {**Interface._sysfs_set, **{
+
+ @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,
@@ -37,15 +45,8 @@ class STPIf(Interface):
'location': '/sys/class/net/{ifname}/brport/priority',
'errormsg': '{ifname} is not a bridge port member'
},
- }}
-
- default = {
- 'type': 'stp',
}
- def __init__(self, ifname, **kargs):
- super().__init__(ifname, **kargs)
-
def set_path_cost(self, cost):
"""
Set interface path cost, only relevant for STP enabled interfaces
diff --git a/src/conf_mode/interfaces-bridge.py b/src/conf_mode/interfaces-bridge.py
index f8f20bf5c..c45ab13a8 100755
--- a/src/conf_mode/interfaces-bridge.py
+++ b/src/conf_mode/interfaces-bridge.py
@@ -20,7 +20,8 @@ from copy import deepcopy
from sys import exit
from netifaces import interfaces
-from vyos.ifconfig import BridgeIf, STPIf
+from vyos.ifconfig import BridgeIf
+from vyos.ifconfig.stp import STP
from vyos.configdict import list_diff
from vyos.config import Config
from vyos import ConfigError
@@ -322,9 +323,10 @@ def apply(bridge):
for addr in bridge['address']:
br.add_addr(addr)
+ STPBridgeIf = STP.enable(BridgeIf)
# configure additional bridge member options
for member in bridge['member']:
- i = STPIf(member['name'])
+ i = STPBridgeIf(member['name'])
# configure ARP cache timeout
i.set_arp_cache_tmo(bridge['arp_cache_tmo'])
# ignore link state changes