A BGP session needs a port that can carry a frame (#1269) #1270

Merged
jaylouisw merged 1 commit from fix/bgp-link-state into main 2026-11-09 20:33:43 +00:00
Owner

A BGP session needs a port that can carry a frame

Fixes #1269.

Neighbor         V  AS      State           Reason
10.0.0.1         4  65001   Idle            egress Gi0 cannot carry a frame (link down)

0 of 1 neighbour(s) established
0 prefix(es) installed from BGP

The bug

Two routers peering over one cable. Pull the cable:

1 of 1 neighbour(s) established
1 prefix(es) installed from BGP

B  10.0.0.0       /24  [20/0] via 10.0.0.1  Gi0

The session went on calling itself Established, kept the prefix it had learned over it, and show ip route went on offering a B route whose next hop could not be reached — the routing table claiming a path
that does not exist. Shutting the far port did the same thing.

_bgpReachable() asked iface.enabled — "did somebody shut this port" — and nothing else. Not the cable, not
the link, not the far end. That is exactly the question show ip interface brief was answering wrongly
before #1237, and the rule that answers it correctly (Device.ifaceStatus(iface, topo)) has existed since.

Now

  • _bgpReachable() requires the egress port to carry a frame, and refuses with the reason the fault
    actually is: E_LINK_DOWN → cannot carry a frame (link down), (peer shut down), (down: no cable).
    A port someone shut keeps E_IFACE_DOWN, because "down on the router" would send the operator to the wrong
    config;
  • the session ends, and the prefixes are withdrawn — no B row survives a session that is down;
    restoring the cable brings both back;
  • show ip bgp now lists the prefixes it installed — network, next hop, metric, local preference, weight,
    AS path with origin code, session type — with the prefix length from net.prefixOf(), the same rule
    show ip route uses, so the two tables cannot print the same route two ways (#1249);
  • with nothing installed, no prefix header is printed over nothing.

Evidence

test/bgp-session-link-state.test.js — 25 checks:

  • a live session lists its prefix with next hop, AS path, origin and session type;
  • a pulled cable ends the session, names the wire rather than a shutdown, withdraws the prefix, leaves no
    B row, and a ping across the dead cable fails — the data plane agreeing with the control plane;
  • a shut far port says peer shut down instead — the same fault from the other end says a different thing,
    correctly;
  • restoring the cable restores the session and the route;
  • the prefix list and the B rows agree prefix for prefix including the prefix length;
  • zero prefixes prints no empty table.

Reverting engine/simulator.js fails 8; engine/cli.js fails 4. The existing bgp-session suite still
passes (24 checks), so the refusal codes it asserts are unchanged.

docs/CLI.md gains "Reading show ip bgp" and both commands in the table.

Suite: 148 suites, 6,265 assertions, 0 failed.

A BGP session needs a port that can carry a frame Fixes #1269. ``` Neighbor V AS State Reason 10.0.0.1 4 65001 Idle egress Gi0 cannot carry a frame (link down) 0 of 1 neighbour(s) established 0 prefix(es) installed from BGP ``` ## The bug Two routers peering over one cable. Pull the cable: ``` 1 of 1 neighbour(s) established 1 prefix(es) installed from BGP B 10.0.0.0 /24 [20/0] via 10.0.0.1 Gi0 ``` The session went on calling itself **Established**, kept the prefix it had learned over it, and `show ip route` went on offering a `B` route whose next hop could not be reached — the routing table claiming a path that does not exist. Shutting the far port did the same thing. `_bgpReachable()` asked `iface.enabled` — "did somebody shut this port" — and nothing else. Not the cable, not the link, not the far end. That is exactly the question `show ip interface brief` was answering wrongly before #1237, and the rule that answers it correctly (`Device.ifaceStatus(iface, topo)`) has existed since. ## Now * `_bgpReachable()` requires the egress port to **carry a frame**, and refuses with the reason the fault actually is: `E_LINK_DOWN` → `cannot carry a frame (link down)`, `(peer shut down)`, `(down: no cable)`. A port someone shut keeps `E_IFACE_DOWN`, because "down on the router" would send the operator to the wrong config; * the session ends, and **the prefixes are withdrawn** — no `B` row survives a session that is down; restoring the cable brings both back; * `show ip bgp` now lists the prefixes it installed — network, next hop, metric, local preference, weight, AS path with origin code, session type — with the prefix length from `net.prefixOf()`, the same rule `show ip route` uses, so the two tables cannot print the same route two ways (#1249); * with nothing installed, no prefix header is printed over nothing. ## Evidence `test/bgp-session-link-state.test.js` — 25 checks: * a live session lists its prefix with next hop, AS path, origin and session type; * a pulled cable ends the session, names **the wire** rather than a shutdown, withdraws the prefix, leaves no `B` row, and a ping across the dead cable fails — the data plane agreeing with the control plane; * a shut far port says `peer shut down` instead — the same fault from the other end says a different thing, correctly; * restoring the cable restores the session and the route; * the prefix list and the `B` rows agree prefix for prefix **including the prefix length**; * zero prefixes prints no empty table. Reverting `engine/simulator.js` fails 8; `engine/cli.js` fails 4. The existing `bgp-session` suite still passes (24 checks), so the refusal codes it asserts are unchanged. `docs/CLI.md` gains "Reading `show ip bgp`" and both commands in the table. Suite: 148 suites, 6,265 assertions, 0 failed.
A BGP session needs a port that can carry a frame (#1269)
All checks were successful
CI / Classify the change (pull_request) Successful in 10s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 14s
CI / Test (Node 20) (pull_request) Successful in 1m57s
CI / Test (Node 18) (pull_request) Successful in 2m4s
CI / Server smoke test (pull_request) Successful in 34s
CI / Docker build (pull_request) Successful in 40s
CI / Test (Node 22) (pull_request) Successful in 1m54s
278c1b0b63
Two routers peering over one cable: pull the cable and `show ip bgp` still reported
`1 of 1 neighbour(s) established`, `1 prefix(es) installed from BGP`, and `show ip route` still offered
`B 10.0.0.0/24 [20/0] via 10.0.0.1 Gi0` - a route whose next hop could not be reached. Shutting the far port
did the same.

`_bgpReachable()` asked `iface.enabled` - "did somebody shut this port" - and nothing else. That is the
question `show ip interface brief` was answering wrongly before #1237, and the rule that answers it correctly
(`Device.ifaceStatus(iface, topo)`) has existed since.

Now:
* `_bgpReachable()` requires the egress port to be able to carry a frame, and refuses with the reason the
  fault actually is: `E_LINK_DOWN` / `cannot carry a frame (link down)`, `(peer shut down)`, `(down: no
  cable)`. A port someone shut keeps its existing `E_IFACE_DOWN`, because that is a different fault and
  "down on the router" sends the operator to the wrong config;
* the session therefore ends, and the prefixes it carried are withdrawn - no `B` row survives a session that
  is down. Restoring the cable brings both back;
* `show ip bgp` now lists the prefixes it installed: network, next hop, metric, local preference, weight, AS
  path with origin code, and session type. The prefix length comes from `net.prefixOf()`, the same rule
  `show ip route` uses, so the two tables cannot print the same route two ways (#1249);
* with nothing installed, no prefix header is printed over nothing.

test/bgp-session-link-state.test.js (25 checks): a live session lists its prefix with next hop, path and
session type; a pulled cable ends the session, names the wire rather than a shutdown, withdraws the prefix,
leaves no B row, and a ping across it fails; a shut far port says `peer shut down` instead; restoring the
cable restores session and route; the prefix list and the B rows agree prefix for prefix including the
prefix length; and zero prefixes prints no empty table. Reverting engine/simulator.js fails 8,
engine/cli.js fails 4; the existing bgp-session suite still passes.

Suite: 148 suites, 6,265 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-09 20:33:40 +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!1270
No description provided.