Spanning tree counts shut ports as edges, and a ring with a shut port black-holes a switch #1274
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge#1274
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What happens
Four switches in a ring, a PC on
s1and a PC ons3. All links up:s3'sFa0/2is blocked (root portelected elsewhere) and a ping between the PCs works.
Now make the
s2–s3link unusable in the two ways a network operator does it:shutdownons3 Fa0/1(the same cable)s3 Fa0/2still blockedSame physical outcome, two different verdicts — and the second one black-holes a whole switch:
s3's onlyremaining ring port is
Fa0/2, and spanning tree keeps it blocked becausecomputeStp()still counts theFa0/1edge as part of the tree.computeStp()asks only whether the link is up:so a port someone shut, and a port whose far end someone shut, stay in the graph as usable edges.
Verified while filing this
Making the STP port filter use
Device.ifaceStatus(iface, topo)(the rule every other table uses) makes theblocked set agree with the cable-out case — nothing blocked — which is the correct tree for a ring with a
broken link. The ping still fails, with the tree now correct:
So there are two defects here, and this issue covers both because they interlock:
replicated around the break, a MAC is learned on the wrong side, and a host's ARP cache ends up holding
its own address. Broadcast storms and
loop: egress equals ingressdrops appear.Expected
same way a pulled cable is not;
show spanning-treesays a port is not in the tree and why;and no host caching its own address.
Notes
This was found while auditing the flood path (#1273), which is fixed separately: floods now skip ports that
cannot carry a frame, so the storm above is no longer made worse by flooding into dead ports. That fix does
not remove this defect — it is measured on top of it.
Both halves are fixed and measured on top of #1273 (flood no longer enters dead ports).
Root cause of the second half:
_deliver()checked the sending port — enabled, peer present, link up — and never the receiving one. A frame aimed at an administratively-down port was delivered, learned from and forwarded, so the ring never actually broke: frames were replicated around it,s3learned the far host on the port it could not use, and that is whyb's reply went out of a dead port anda's ARP cache ended up holding10.0.0.9 -> 02:00:00:00:04:00(its own address, a switch's bridge MAC).Fixed:
computeStp()asksDevice.ifaceStatus(iface, topo)instead of only whether the cable is up, so a shut port and a port whose far end is shut are not edges;_deliver()refuses delivery into a port that is administratively down, counting one discard on the sender naming the far end:peer port shut (pc eth0). A packet waiting on the ARP that request carried is cleared rather than reported a second time, so one lost ping is one counted loss.After:
s3 Fa0/2and in the ring with a shut port:
s3MAC table holds the far host on the live side only, nothing is learned on the shut port, zeroloop: egress equals ingressdrops, and both hosts' ARP caches hold only each other's real MACs.test/stp-shut-port.test.js— 27 checks, 13 of which fail withengine/simulator.jsreverted. One existing assertion intest/interface-drops.test.jspinned the weaker reason (no ARP reply from 10.0.0.9) that the old code could offer; it now asserts the sharperpeer port shut (pc eth0)while keeping the invariant that the tally equals the event log and that the ping's sentence is the discard's sentence.