W_DUPLEX_MISMATCH can now fire, and a forced line rate is stored (#1259) #1260

Merged
jaylouisw merged 1 commit from fix/speed-duplex into main 2026-11-09 19:42:23 +00:00
Owner

W_DUPLEX_MISMATCH can now fire, and a forced line rate is stored

Fixes #1259.

Gi0 (ethernet, 1G), MAC 02:00:00:00:00:00
  status: up, protocol: up
  ip: 10.0.0.1/24
  peer: sw/Fa0/2
  speed: 100Mb/s (forced), duplex: half

The gap

Two things described a link's physical behaviour and neither could be set:

  • Interface.duplex was 'full' for every port in the catalogue and no command changed it — so
    W_DUPLEX_MISMATCH, a warning docs/CONNECTORS.md publishes in its code table, could only be produced
    from inside a test that passes duplexA/duplexB straight to validateLink. The rule was documented,
    implemented and unreachable.
  • There was no speed command. speed 100 came back "Unrecognized command", and a port that had been
    forced to 100 Mb/s went on describing itself as 1G: not stored, not printed by show running-config, not
    reported by show interfaces, and the link kept its auto-negotiated rate.

show interfaces also never reported the rate or duplex at all — the first thing you look at when a link is
up but slow.

Now

  • speed auto|<mbps> and duplex auto|full|half in interface config. A rate the port cannot do is refused
    naming the port, the rate asked for and what it supports —
    % Gi0 does not support 10G - it supports 10M, 100M, 1G — and the previous rate is left untouched, so a
    refusal cannot half-apply.
  • Rates are parsed by engine/media.js, the parser the catalogue uses, so speed 1G and speed 1000
    are the same port rate rather than two answers from two parsers.
  • A forced rate narrows the port's capabilities in validateLink, which leaves negotiation one option:
    the cable's rate, its serialisation delay (measured: RTT 103.3 µs → 118.0 µs at 100M) and its warnings all
    follow from one change. Two ends forced to different rates intersect emptily and hit the existing
    "no common line rate" rule rather than a new one.
  • Topology.renegotiate(devId, iface) re-runs the verdict for an existing cable through the same rule that
    created it, and takes the link down when there is no rate in common: a cable that cannot agree on a
    rate does not carry frames, and those frames are counted as dropped with that reason (#1258).
  • show interfaces reports (forced) vs (auto), adds link runs at … when the pair caps lower than
    either port, and link: down (no common rate with the peer) when negotiation failed.
  • show running-config prints speed/duplex only when set, so the round trip stays byte-identical and
    a default config gains no noise.

Found while doing it

Topology.revalidateFor(linkId) assumed the caller's A side was link.a. Re-checking a cable from the other
end handed the validator its own port as "the peer", which came back as two E_PORT_IN_USE errors — a cable
that plainly exists looking like a second cable in the same socket. It now takes the device you are asking
from; the one-argument form keeps its old meaning.

Evidence

test/speed-duplex.test.js — 55 checks:

  • forcing a rate updates the port and the cable, and show interfaces says (forced);
  • speed 1G == speed 1000, via the catalogue parser (asserted, not assumed);
  • an impossible rate is refused with the port, the rate and the ladder, and neither the port nor the link
    moves; a non-rate word is refused;
  • speed auto / no speed return to auto and renegotiate back up;
  • duplex half is accepted, reported, and makes W_DUPLEX_MISMATCH fire, naming both ends — and goes
    quiet when the ends agree;
  • the forced rate reaches the data plane: the same ping is measurably slower at 100M;
  • two ends forced differently take the link down, show interfaces says why and the status agrees, nothing
    crosses, the loss is counted with the reason, and matching the rates again brings it back up;
  • the config is a fixed point: printed, replayed into a fresh device, state survives, byte-identical;
  • the catalogue ships no forced rate and no half duplex, and a default config prints neither line;
  • the re-check marker flips with the end you ask from, and the wrong orientation is what produced the
    phantom E_PORT_IN_USE.

Reverting engine/cli.js fails 32 of the 55; reverting engine/topology.js fails 13.

docs/CLI.md gains "Line rate and duplex"; docs/CONNECTORS.md's W_DUPLEX_MISMATCH row now says how to
set it.

Suite: 143 suites, 6,135 assertions, 0 failed.

`W_DUPLEX_MISMATCH` can now fire, and a forced line rate is stored Fixes #1259. ``` Gi0 (ethernet, 1G), MAC 02:00:00:00:00:00 status: up, protocol: up ip: 10.0.0.1/24 peer: sw/Fa0/2 speed: 100Mb/s (forced), duplex: half ``` ## The gap Two things described a link's physical behaviour and neither could be set: * **`Interface.duplex` was `'full'` for every port in the catalogue** and no command changed it — so `W_DUPLEX_MISMATCH`, a warning `docs/CONNECTORS.md` publishes in its code table, could only be produced from inside a test that passes `duplexA`/`duplexB` straight to `validateLink`. The rule was documented, implemented and unreachable. * **There was no `speed` command.** `speed 100` came back "Unrecognized command", and a port that had been forced to 100 Mb/s went on describing itself as 1G: not stored, not printed by `show running-config`, not reported by `show interfaces`, and the link kept its auto-negotiated rate. `show interfaces` also never reported the rate or duplex at all — the first thing you look at when a link is up but slow. ## Now * `speed auto|<mbps>` and `duplex auto|full|half` in interface config. A rate the port cannot do is refused naming the port, the rate asked for and what it supports — `% Gi0 does not support 10G - it supports 10M, 100M, 1G` — and the previous rate is left untouched, so a refusal cannot half-apply. * Rates are parsed by **`engine/media.js`**, the parser the catalogue uses, so `speed 1G` and `speed 1000` are the same port rate rather than two answers from two parsers. * A forced rate **narrows the port's capabilities** in `validateLink`, which leaves negotiation one option: the cable's rate, its serialisation delay (measured: RTT 103.3 µs → 118.0 µs at 100M) and its warnings all follow from one change. Two ends forced to different rates intersect emptily and hit the **existing** "no common line rate" rule rather than a new one. * `Topology.renegotiate(devId, iface)` re-runs the verdict for an existing cable through the same rule that created it, and takes the link **down** when there is no rate in common: a cable that cannot agree on a rate does not carry frames, and those frames are counted as dropped with that reason (#1258). * `show interfaces` reports `(forced)` vs `(auto)`, adds `link runs at …` when the pair caps lower than either port, and `link: down (no common rate with the peer)` when negotiation failed. * `show running-config` prints `speed`/`duplex` **only when set**, so the round trip stays byte-identical and a default config gains no noise. ## Found while doing it `Topology.revalidateFor(linkId)` assumed the caller's A side was `link.a`. Re-checking a cable from the other end handed the validator its own port as "the peer", which came back as two `E_PORT_IN_USE` errors — a cable that plainly exists looking like a second cable in the same socket. It now takes the device you are asking from; the one-argument form keeps its old meaning. ## Evidence `test/speed-duplex.test.js` — 55 checks: * forcing a rate updates the port **and the cable**, and `show interfaces` says `(forced)`; * `speed 1G` == `speed 1000`, via the catalogue parser (asserted, not assumed); * an impossible rate is refused with the port, the rate and the ladder, and neither the port nor the link moves; a non-rate word is refused; * `speed auto` / `no speed` return to auto and renegotiate back up; * `duplex half` is accepted, reported, and **makes `W_DUPLEX_MISMATCH` fire**, naming both ends — and goes quiet when the ends agree; * the forced rate reaches the data plane: the same ping is measurably slower at 100M; * two ends forced differently take the link down, `show interfaces` says why and the status agrees, nothing crosses, the loss is counted with the reason, and matching the rates again brings it back up; * the config is a fixed point: printed, replayed into a fresh device, state survives, byte-identical; * the catalogue ships **no** forced rate and **no** half duplex, and a default config prints neither line; * the re-check marker flips with the end you ask from, and the wrong orientation is what produced the phantom `E_PORT_IN_USE`. Reverting `engine/cli.js` fails 32 of the 55; reverting `engine/topology.js` fails 13. `docs/CLI.md` gains "Line rate and duplex"; `docs/CONNECTORS.md`'s `W_DUPLEX_MISMATCH` row now says how to set it. Suite: 143 suites, 6,135 assertions, 0 failed.
W_DUPLEX_MISMATCH can now fire, and a forced line rate is stored (#1259)
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 1m50s
CI / Test (Node 18) (pull_request) Successful in 1m54s
CI / Server smoke test (pull_request) Successful in 32s
CI / Docker build (pull_request) Successful in 44s
CI / Test (Node 22) (pull_request) Successful in 1m49s
7cb00e287f
Two things described a link's physical behaviour and neither could be set:

* `Interface.duplex` was 'full' for every port in the catalogue and no command changed it, so
  `W_DUPLEX_MISMATCH` - a warning the connector docs publish - was unreachable outside the tests that pass
  duplexA/duplexB straight to validateLink;
* there was no `speed` command at all, so a port forced to 100 Mb/s went on describing itself as 1G: not
  stored, not printed, not replayed, and the link kept its auto-negotiated rate.

Now:
* `speed auto|<mbps>` and `duplex auto|full|half` in interface config; a rate the port cannot do is refused
  naming the port, the rate asked for and what it supports (`Gi0 does not support 10G - it supports 10M,
  100M, 1G`), and the previous rate is left untouched;
* rates are parsed by engine/media.js, the parser the catalogue uses, so `speed 1G` and `speed 1000` are the
  same port rate rather than two answers;
* a forced rate narrows the port's capabilities in validateLink, so negotiation has one option left: the
  cable's rate, its serialisation delay (RTT rises, measured) and its warnings all follow, and two ends
  forced to different rates intersect emptily and hit the existing "no common line rate" rule;
* `Topology.renegotiate(devId, iface)` re-runs the verdict for an existing cable through the same rule that
  created it, and brings the link down when there is no rate in common - a cable that cannot agree on a rate
  does not carry frames, and the drops are counted with that reason (#1258);
* `show interfaces` reports `speed: 100Mb/s (forced), duplex: half`, `link runs at …` when the pair caps
  lower, and `link: down (no common rate with the peer)` when negotiation failed;
* `show running-config` prints `speed`/`duplex` only when set, and the config still replays byte-identically.

Found while doing it: `Topology.revalidateFor(linkId)` assumed the caller's A side was `link.a`, so
re-checking a cable from the other end handed the validator its own port as "the peer" and came back as two
E_PORT_IN_USE errors. It now takes the device you are asking from (one-argument form unchanged).

test/speed-duplex.test.js (55 checks): forcing, refusal, auto/`no`, one rate parser, the duplex warning
firing and going quiet, RTT measurably slower at 100M, no-common-rate taking the link down and traffic
stopping, the config round trip as a fixed point, the catalogue shipping no forced rate and no half duplex,
and the re-check marker flipping with the asking end. Reverting engine/cli.js fails 32 of the 55; reverting
engine/topology.js fails 13.

Suite: 143 suites, 6,135 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-09 19:42:19 +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!1260
No description provided.