Skip to content

feat!: add Iface::carrier_down and carrier_up to simulate a pulled cable - #64

Merged
Frando merged 4 commits into
mainfrom
feat/iface-carrier
Nov 23, 2026
Merged

Frando merged 4 commits into
mainfrom
feat/iface-carrier

Conversation

@Frando

@Frando Frando commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

link_down is an administrative down: the kernel removes routes, flushes IPv6 addresses unless told otherwise, and sends fail with an error. A pulled cable or a lost Wi-Fi association only drops carrier. The interface stays up and keeps its addresses and routes, which the kernel flags as linkdown, and packets vanish silently. Apps that watch netlink, like iroh's network monitor, see different events for the two, so tests need both.

Iface::carrier_down and carrier_up take the router-side end of the interface's veth pair down and up, which the kernel reports as NO-CARRIER on the device side. Nothing on the device changes, so there is nothing to restore on carrier_up, and link conditions on the router-side veth survive the flap. Dummy interfaces have no peer and return an error. The sim runner gets matching carrier-down and carrier-up steps.

The first commit moves the router-side veth lookup from Iface::apply_condition into NetworkCore::gateway_veth so both callers share it.

Breaking changes

  • LabEventKind is now non-exhaustive and has two new variants, CarrierUp and CarrierDown, emitted by the new methods. Matches on LabEventKind need a _ arm .

@Frando
Frando marked this pull request as ready for review November 13, 2026 14:06
Frando and others added 4 commits November 18, 2026 18:52
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`link_down` is an administrative down. The kernel removes routes and
flushes IPv6 addresses, and sends fail with an error. A pulled cable or
a lost Wi-Fi association only drops carrier: the interface stays up,
keeps its addresses and routes, and packets vanish silently. Apps that
watch netlink see different events for the two, so tests need both.

Carrier is toggled by taking down the router-side end of the veth pair,
which the kernel reports as NO-CARRIER on the device side.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This PR already adds variants, so the break is free now. Later variants
then no longer break code that matches on the enum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Frando
Frando force-pushed the feat/iface-carrier branch from 0fff965 to c57d956 Compare November 18, 2026 17:54
@Frando
Frando merged commit 848c1e6 into main Nov 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant