stp: integrate 802.1D Spanning Tree Protocol into BridgeDevice

Adds loop prevention to Ethernet bridges:
- BridgeDevice gains stp: Option<StpState> field
- enable_stp(priority, mac) method initializes STP per-bridge
- BPDU frames (dst 01:80:c2:00:00:00) intercepted in recv(),
  processed locally, never forwarded
- STP hello timer sends periodic BPDUs on all ports (root bridge)
- flood() skips STP-blocked ports
- build_bpdu() made public for bridge integration
- stp module declared in link/mod.rs

The recv() flow now: age MACs → check STP hello timer →
poll ports → detect BPDU (absorb) → normal frame (learn + forward).

Reference: Linux 7.1 net/bridge/br_stp.c, br_stp_bpdu.c, br_stp_timer.c
This commit is contained in:
Red Bear OS
2026-07-08 13:38:38 +03:00
parent 1606a6ffb2
commit 30db94c970
4 changed files with 63 additions and 23 deletions
+1
View File
@@ -5,6 +5,7 @@ pub mod gre;
pub mod ipip;
pub mod loopback;
pub mod qdisc;
pub mod stp;
pub mod tun;
pub mod vlan;
pub mod vxlan;