-
Notifications
You must be signed in to change notification settings - Fork 96
Description
Summary
The STP module validates the global stp.protocol setting against device capabilities, but does not validate node-level protocol overrides. This allows users to configure unsupported STP protocols on individual nodes without receiving an error.
Environment
- netlab version: Current (as of branch
fix_minor_stp_issues) - Module:
stp - Affected devices: All devices with STP support
Description
When a user sets stp.protocol at the node level (e.g., nodes.s1.stp.protocol: mstp), the STP module does not validate whether the device supports that protocol. The module only validates the global stp.protocol setting.
Current Code Behavior
In netsim/modules/stp.py, lines 41-47:
protocol = topology.get("stp.protocol","stp")
supported_protocols = features.get("stp.supported_protocols",[])
if protocol not in supported_protocols:
log.error(
f'node {node.name} (device {node.device}) does not support requested STP protocol ({protocol})',
log.IncorrectValue,
'stp')This only checks the global protocol, not node-level overrides.
Steps to Reproduce
- Create a topology with a device that has limited STP protocol support (e.g., FRR which only supports
stp) - Set a node-level protocol override to an unsupported protocol (e.g.,
mstp) - Run
netlab createon the topology
Minimal Test Topology
---
defaults:
device: frr
stp:
protocol: stp # Global default
addressing:
p2p:
ipv4: False # STP only applies to L2 interfaces
groups:
_auto_create: true
switches:
members: [s1, s2]
module: [vlan, stp]
vlans:
red:
mode: bridge
links: [s1-s2]
links:
- s1:
s2:
nodes:
s1:
# Node-level protocol override - should be validated but currently isn't
stp.protocol: mstp # FRR doesn't support MSTP, should errorFile location: tests/ai/stp-validation-issues.yml
Expected Behavior
When running netlab create on the above topology, it should produce an error:
IncorrectValue in stp: node s1 (device frr) does not support requested STP protocol (mstp)
Actual Behavior
The topology is created successfully without any validation errors, even though:
- FRR device only supports
stpprotocol (seenetsim/devices/frr.ymlline 138:supported_protocols: [ stp ]) - Node
s1is configured withstp.protocol: mstpwhich is not supported
Impact
- Severity: Medium
- Impact: Users can configure invalid STP protocols on nodes, leading to:
- Configuration generation that may not work as expected
- Runtime errors when the lab is started
- Confusion about why certain configurations don't work
Suggested Fix
The validation should check node-level protocol overrides in addition to the global protocol. Suggested code change in netsim/modules/stp.py:
# Check global protocol
protocol = topology.get("stp.protocol","stp")
supported_protocols = features.get("stp.supported_protocols",[])
if protocol not in supported_protocols:
log.error(
f'node {node.name} (device {node.device}) does not support requested STP protocol ({protocol})',
log.IncorrectValue,
'stp')
# Check node-level protocol override
node_protocol = node.get('stp.protocol', protocol)
if node_protocol not in supported_protocols:
log.error(
f'node {node.name} (device {node.device}) does not support requested STP protocol ({node_protocol})',
log.IncorrectValue,
'stp')Additional Context
- The global protocol validation works correctly
- Node-level priority validation works correctly (validates multiples of 4096)
- This is a missing validation check, not a logic error
- Related issue: The
protocolattribute instp.ymlnode section is missing a definition (should havecopy: globalor explicit type)
References
- STP module:
netsim/modules/stp.py - STP defaults:
netsim/modules/stp.yml - FRR device features:
netsim/devices/frr.yml(line 138) - Test topology:
tests/ai/stp-validation-issues.yml