A flood goes to ports that are up, not to every port nobody shut (#1273) #1275

Merged
jaylouisw merged 1 commit from fix/flood-port-state into main 2026-11-09 21:04:22 +00:00
Owner

A flood goes to ports that are up, not to every port nobody shut

Fixes #1273.

s1 drops: {"total": 12, "byReason": {"no cable": 6, ...}}      <- after three answered pings, nothing wrong

The bug

_forwardL2() built its broadcast list from activeInterfaces(), which filters enabled and nothing else. So
every broadcast was queued to every spare port, dropped on delivery, and show interfaces reported discards
on ports that were never part of the path. Twelve discards on a two-switch lab, none of them anybody's fault
and none of them actionable — and a spare port could not report the truth, which is that nothing has used it.

A real switch floods to ports that are up, not to every port it owns.

Now

  • a flood candidate must be able to carry a frame — Device.ifaceStatus(iface, topo), the rule
    show interfaces, show arp, show mac address-table, show ip route, BGP, OSPF, LAG selection and the
    canvas already share (eight callers; the list is now in docs/LINK-STATE.md);
  • a port-channel member is left to the bundle: whether a member can carry is decided in engine/lag.js,
    in one place, and the timeline records what it skipped (#1263). Applying the same test twice made the
    bundle's own record unreachable — it did, in this branch, before that exception was added. The suite caught
    it;
  • a spare port now reads 0 packets input, 0 packets output with no discard line;
  • the ports that carried the traffic still report it, and a frame aimed at a known destination behind a dead
    port is still a real discard, still counted.

Evidence

test/flood-port-state.test.js — 19 checks:

  • spare ports carry nothing in either direction and record no discard, while the port that carried the
    traffic still reports output — the fix cannot be "count nothing";
  • a port whose cable is down is not a flood target and takes nothing in;
  • a shut port is not a flood target, and the failure still carries a reason naming the shut link or the
    unanswered ARP;
  • a healthy lab prints no drop summary at all;
  • a link that really did drop frames still reports them.

Reverting engine/simulator.js fails 3. The lag-member-down suite (30 checks) still passes, which is what
pins the bundle exception.

Found on the way, filed as #1274

computeStp() still counts a shut port — and a port whose far end is shut — as an edge of the tree. In a
four-switch ring, shutdown on one port leaves a switch with no path while pulling the same cable heals it;
correcting the tree is not enough, because the forwarding path then still breaks (brute-force measurements,
MAC learned on the wrong side, a host caching its own address). Both are written up in #1274 with the tables;
this PR does not claim to fix it.

Suite: 150 suites, 6,304 assertions, 0 failed.

A flood goes to ports that are up, not to every port nobody shut Fixes #1273. ``` s1 drops: {"total": 12, "byReason": {"no cable": 6, ...}} <- after three answered pings, nothing wrong ``` ## The bug `_forwardL2()` built its broadcast list from `activeInterfaces()`, which filters `enabled` and nothing else. So every broadcast was queued to every spare port, dropped on delivery, and `show interfaces` reported discards on ports that were never part of the path. Twelve discards on a two-switch lab, none of them anybody's fault and none of them actionable — and a spare port could not report the truth, which is that nothing has used it. A real switch floods to ports that are **up**, not to every port it owns. ## Now * a flood candidate must be able to carry a frame — `Device.ifaceStatus(iface, topo)`, the rule `show interfaces`, `show arp`, `show mac address-table`, `show ip route`, BGP, OSPF, LAG selection and the canvas already share (eight callers; the list is now in `docs/LINK-STATE.md`); * a **port-channel member is left to the bundle**: whether a member can carry is decided in `engine/lag.js`, in one place, and the timeline records what it skipped (#1263). Applying the same test twice made the bundle's own record unreachable — it did, in this branch, before that exception was added. The suite caught it; * a spare port now reads `0 packets input, 0 packets output` with no discard line; * the ports that carried the traffic still report it, and a frame aimed at a known destination behind a dead port is still a real discard, still counted. ## Evidence `test/flood-port-state.test.js` — 19 checks: * spare ports carry nothing in either direction and record **no** discard, while the port that carried the traffic still reports output — the fix cannot be "count nothing"; * a port whose cable is down is not a flood target and takes nothing in; * a shut port is not a flood target, and the failure still carries a reason naming the shut link or the unanswered ARP; * a healthy lab prints no drop summary at all; * a link that really did drop frames still reports them. Reverting `engine/simulator.js` fails 3. The `lag-member-down` suite (30 checks) still passes, which is what pins the bundle exception. ## Found on the way, filed as #1274 `computeStp()` still counts a shut port — and a port whose far end is shut — as an edge of the tree. In a four-switch ring, `shutdown` on one port leaves a switch with no path *while pulling the same cable heals it*; correcting the tree is not enough, because the forwarding path then still breaks (brute-force measurements, MAC learned on the wrong side, a host caching its own address). Both are written up in #1274 with the tables; this PR does not claim to fix it. Suite: 150 suites, 6,304 assertions, 0 failed.
A flood goes to ports that are up, not to every port nobody shut (#1273)
All checks were successful
CI / Classify the change (pull_request) Successful in 12s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 16s
CI / Test (Node 20) (pull_request) Successful in 2m2s
CI / Test (Node 18) (pull_request) Successful in 2m7s
CI / Server smoke test (pull_request) Successful in 34s
CI / Docker build (pull_request) Successful in 48s
CI / Test (Node 22) (pull_request) Successful in 1m51s
b98866f02a
`_forwardL2()` built its broadcast list from `activeInterfaces()`, which filters `enabled` and nothing else.
So every broadcast went out of every spare port, was dropped on delivery, and `show interfaces` reported
discards on ports that were never part of the path: twelve discards on a two-switch lab after three answered
pings, none of them anybody's fault and none of them actionable.

Now:
* a flood candidate must be a port that can carry a frame - `Device.ifaceStatus(iface, topo)`, the rule
  `show interfaces`, `show arp`, `show mac address-table`, `show ip route`, BGP, OSPF, LAG selection and the
  canvas already share;
* a member of a port-channel is deliberately left to the bundle: whether a member can carry is decided in
  `engine/lag.js`, in one place, and the timeline records what it skipped (#1263). Applying the same test
  twice would have made the bundle's own record unreachable - it did, in this branch, before the exception
  was added;
* a spare port now reads `0 packets input, 0 packets output` with no discard line; the ports that carried the
  traffic still report it; and a frame aimed at a known destination behind a dead port is still counted as a
  real discard.

test/flood-port-state.test.js (19 checks): spare ports carry nothing and record no discards while the ports
that carried the traffic still report output; a port whose cable is down is not a flood target and takes
nothing in; a shut port is not a flood target and the failure still carries a reason; a healthy lab prints no
drop summary at all; and a link that really did drop frames still reports them. Reverting engine/simulator.js
fails 3.

Found on the way and filed as #1274, not fixed here: `computeStp()` still counts a shut port - and a port
whose far end is shut - as an edge, so a four-switch ring with one port shut leaves a switch black-holed
while pulling the same cable heals it. The measurements are in the issue, including what happens after the
tree is corrected.

docs/LINK-STATE.md gains a table of every caller of the "can this port carry a frame" rule, because there are
now eight of them and the list is the point.

Suite: 150 suites, 6,304 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-09 21:04:18 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge!1275
No description provided.