Skip to content

fix: keep IPv6 addresses across link down/up on dual-stack devices - #47

Open
Frando wants to merge 2 commits into
mainfrom
fix/link-up-dualstack
Open

Frando wants to merge 2 commits into
mainfrom
fix/link-up-dualstack

Conversation

@Frando

@Frando Frando commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Iface::link_up failed with EHOSTUNREACH on any dual-stack device after link_down, because Linux flushes IPv6 addresses when a link goes down and the v6 default route then has no on-link gateway. Every namespace now sets keep_addr_on_down=1 so global addresses survive the transition. The kernel drops link-local addresses regardless of that sysctl, so link_up also re-adds the seeded link-local. Addresses and the default routes come back; routes added outside patchbay do not.

We keep addresses with the sysctl instead of re-adding the ones patchbay tracks. The sysctl also preserves addresses patchbay does not know about, and it makes an admin down issued from user code recoverable. Re-adding tracked addresses covers neither case and would still need the link-local special case.

The sysctl changes kernel behavior in every namespace, routers included. Nothing in patchbay takes router interfaces down, so in practice this only affects device link_down, which did not work on dual-stack before.

With Ipv6Profile::Realistic, the kept addresses rerun duplicate address detection after link_up, so v6 is usable about two seconds later. That matches initial setup in that profile, and the link_up docs now say so.

The new link_down_up_dual_stack test reproduces the failure from the issue and checks that both v6 addresses and v6 connectivity are back after the flap. The RouterPreset::Home scenario from the issue and the realistic profile were also checked by hand.

Closes #46

🤖 Generated with Claude Code

@Frando
Frando marked this pull request as ready for review September 11, 2026 17:07
@Frando
Frando force-pushed the fix/link-up-dualstack branch from 672e9cb to fcab3e2 Compare September 25, 2026 11:54
Linux flushes an interface's IPv6 addresses when the link goes down, so
`Iface::link_up` failed with EHOSTUNREACH when re-adding the v6 default
route on any dual-stack device: the gateway was no longer on-link. We now
set `keep_addr_on_down=1` in every namespace so global addresses survive
the transition. The kernel drops link-local addresses regardless of that
sysctl, so `link_up` re-adds the seeded link-local as well.

Closes #46
@Frando
Frando force-pushed the fix/link-up-dualstack branch from fcab3e2 to 0c2a10a Compare September 25, 2026 12:14
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

link_up() fails with EHOSTUNREACH on dual-stack devices after link_down()

1 participant