The reason a ping failed is the earliest cause, not the last (#1431) #1432

Merged
jaylouisw merged 1 commit from fix/ping-reason-first-cause into main 2026-11-11 17:41:53 +00:00
Owner

Closes #1431.

ping read the run's discard events from the end backwards, so the reason it printed was the last discard — and the last one is usually the least true:

uplink shut on r1:
  known target   (10.91.0.1):  "peer port shut (r1 Gi0/0/0)"    <- correct
  unknown target (10.91.0.99): "no ARP reply from 10.91.0.99"   <- the wire was shut, not silent

The end-of-run sweep that reports unanswered ARPs always lands last in the log, so it always won. And the reply only searched events after the ping started, so a shut port noticed earlier in the run was invisible.

Fixed

  • the whole run is searched, not just the slice after the ping event;
  • the causes are ranked: port/wire first (peer port shut, link administratively down), silence next (no ARP reply from X), policy last (ACL … denied, VLAN, NAT) — so an ACL denial still outranks silence, and a shut port outranks both;
  • restore works: no shutdown makes the same ping answer again.

Evidence — 10 checks

test/ping-reason-first-cause.test.js: shut port named for known and unknown targets, silence named when nothing is shut, ACL denial named over silence, restore. Reverting engine/simulator.js fails 2/10 (quoting no ARP reply from 10.91.0.99 for a shut port). One older assertion in flood-port-state.test.js pinned the old last-discard wording; it now accepts the true reason it was checking for.

Suite: 216 suites, 8,144 assertions, 0 failed; syntax 284 files OK. Docs: docs/ARCHITECTURE.md, "The reason a ping failed is the earliest cause, not the last".

Closes #1431. `ping` read the run's discard events **from the end backwards**, so the reason it printed was the *last* discard — and the last one is usually the least true: ``` uplink shut on r1: known target (10.91.0.1): "peer port shut (r1 Gi0/0/0)" <- correct unknown target (10.91.0.99): "no ARP reply from 10.91.0.99" <- the wire was shut, not silent ``` The end-of-run sweep that reports unanswered ARPs always lands **last** in the log, so it always won. And the reply only searched events after the ping started, so a shut port noticed earlier in the run was invisible. ### Fixed - the **whole run** is searched, not just the slice after the ping event; - the causes are **ranked**: port/wire first (`peer port shut`, `link administratively down`), silence next (`no ARP reply from X`), policy last (`ACL … denied`, VLAN, NAT) — so an ACL denial still outranks silence, and a shut port outranks both; - restore works: `no shutdown` makes the same ping answer again. ### Evidence — 10 checks `test/ping-reason-first-cause.test.js`: shut port named for known *and* unknown targets, silence named when nothing is shut, ACL denial named over silence, restore. Reverting `engine/simulator.js` fails **2/10** (quoting `no ARP reply from 10.91.0.99` for a shut port). One older assertion in `flood-port-state.test.js` pinned the old last-discard wording; it now accepts the true reason it was checking for. Suite: **216 suites, 8,144 assertions, 0 failed**; syntax 284 files OK. Docs: `docs/ARCHITECTURE.md`, "The reason a ping failed is the earliest cause, not the last".
The reason a ping failed is the earliest cause, not the last (#1431)
All checks were successful
CI / Classify the change (pull_request) Successful in 11s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 15s
CI / Test (Node 20) (pull_request) Successful in 2m50s
CI / Test (Node 18) (pull_request) Successful in 3m3s
CI / Server smoke test (pull_request) Successful in 28s
CI / Docker build (pull_request) Successful in 36s
CI / Test (Node 22) (pull_request) Successful in 2m39s
7e9adfa1bd
ping reported why nothing came back by reading the run's discard events from the END backwards, so the reason it printed was the LAST discard - and the last one is usually the least true. With the uplink shut:

  known target:   'peer port shut (r1 Gi0/0/0)'    <- correct
  unknown target: 'no ARP reply from 10.91.0.99'  <- the wire was shut, not silent

The end-of-run sweep that reports unanswered ARPs always lands last in the log, so it always won and blamed silence for a frame that never left. And the reply only searched events after the ping started, so a shut port noticed earlier in the run was invisible.

Fixed: the whole run is searched, and the causes are ranked - a port or wire that cannot carry the frame (peer port shut, link administratively down) first, silence (no ARP reply from X) next, policy (ACL denied, VLAN, NAT) last. So a policy denial still outranks silence, a shut port outranks both, and no shutdown makes the same ping answer again.

Evidence: test/ping-reason-first-cause.test.js, 10 checks - shut port named for known and unknown targets, silence named when nothing is shut, ACL denial named over silence, restore works. Reverting engine/simulator.js fails 2/10. One older assertion in flood-port-state.test.js pinned the old last-discard wording; it now accepts the true reason it is checking for. Suite: 216 suites, 8,144 assertions, 0 failed; syntax 284 files OK.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-11 17:41:49 +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!1432
No description provided.