Skip to content

fix: filter IPv6 link-local addresses and routes from host netns - #256

Open
lyuyun wants to merge 1 commit into
kuasar-io:mainfrom
lyuyun:fix-ipv6-link-local
Open

fix: filter IPv6 link-local addresses and routes from host netns#256
lyuyun wants to merge 1 commit into
kuasar-io:mainfrom
lyuyun:fix-ipv6-link-local

Conversation

@lyuyun

@lyuyun lyuyun commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Filter IPv6 link-local network configuration copied from the host network namespace into the sandbox.

This change excludes:

  • IPv6 interface addresses in fe80::/10
  • IPv6 destination routes in fe80::/10

Motivation

IPv6 link-local addresses are scoped to a specific link/interface and are not portable across network namespaces. Copying host-side fe80::/10 addresses or link-local destination routes into the sandbox can produce invalid or misleading guest network configuration.

If IPv6 is enabled inside the sandbox, the guest kernel should create its own link-local address for the guest-side interface instead of inheriting the host-side one.

Notes

This intentionally filters only link-local interface addresses and destination routes. Routes whose next-hop/gateway is link-local are not treated as equivalent here, since those can have different semantics, such as IPv6 default routes using a link-local gateway.

Testing

  • Verified the changes compile.
  • Verified the filtering logic covers fe80::/10 for both interface addresses and destination routes.

@lyuyun
lyuyun requested a review from a team as a code owner June 12, 2026 09:13
Copilot AI review requested due to automatic review settings June 12, 2026 09:13

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces changes to skip IPv6 link-local addresses and routes (fe80::/10) to prevent them from being manually configured inside the guest, as they are auto-generated by the kernel. The feedback suggests a significant improvement: replacing the custom bitwise operations and constants with the standard library's built-in Ipv6Addr::is_unicast_link_local() method, which would make the code more idiomatic, readable, and less error-prone across the implementation and unit tests.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread vmm/sandbox/src/network/link.rs Outdated
Comment thread vmm/sandbox/src/network/route.rs
Comment thread vmm/sandbox/src/network/mod.rs Outdated
Comment thread vmm/sandbox/src/network/mod.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the sandbox network discovery logic to avoid copying non-portable IPv6 link-local configuration (fe80::/10) from the host network namespace into the guest/sandbox.

Changes:

  • Filter IPv6 link-local interface addresses (fe80::/10) when collecting link addresses.
  • Filter IPv6 link-local destination routes (fe80::/10) when collecting routes.
  • Add constants and unit tests to validate the fe80::/10 mask/prefix boundary behavior, plus route-level tests for the new filter.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
vmm/sandbox/src/network/route.rs Skips fe80::/10 destination routes during route parsing and adds unit tests for route filtering.
vmm/sandbox/src/network/mod.rs Introduces shared constants for fe80::/10 detection and tests their correctness at the boundaries.
vmm/sandbox/src/network/link.rs Skips fe80::/10 IPv6 addresses when collecting interface IPs to avoid pushing host link-local config into the guest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vmm/sandbox/src/network/link.rs Outdated
Comment thread vmm/sandbox/src/network/link.rs Outdated
Comment thread vmm/sandbox/src/network/route.rs
@lyuyun
lyuyun force-pushed the fix-ipv6-link-local branch from 842ee4b to 3cd3d55 Compare June 12, 2026 09:42
fe80::/10 link-local addresses and their connected routes (fe80::/64)
are auto-generated by the Linux kernel from the interface MAC address
(EUI-64) and must not be manually configured inside the guest via
setup_sandbox. Pushing them caused EOPNOTSUPP (errno 95) failures
when the guest kernel has IPv6 disabled.

Signed-off-by: lyuyun <lyuyun068@gmail.com>
@lyuyun
lyuyun force-pushed the fix-ipv6-link-local branch from 3cd3d55 to 466defb Compare June 15, 2026 06:56
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.

2 participants