Skip to content

Fix native Windows TUN setup#133

Merged
encodeous merged 3 commits into
encodeous:mainfrom
tionis:windows-bugfixes
Jul 7, 2026
Merged

Fix native Windows TUN setup#133
encodeous merged 3 commits into
encodeous:mainfrom
tionis:windows-bugfixes

Conversation

@tionis

@tionis tionis commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Fixes a few issues found while running Nylon natively on Windows:

  • use the netsh interface ipv6 context when configuring IPv6 aliases
  • set the Wintun adapter MTU to Nylon's configured TUN MTU instead of leaving it at 65535
  • drop malformed TUN packets when the advertised packet length exceeds the bytes read

tionis added 3 commits July 6, 2026 22:34
Use the netsh ipv6 context for IPv6 address aliases instead of the IPv4 interface ip context so Windows nodes can assign their Nylon ULA address.
Wintun adapters can come up with a 65535 IPv6 MTU on Windows, while Nylon internally assumes the configured TUN MTU. That lets the OS hand oversized packets to the device and can trigger malformed packet handling downstream.

Set the Windows IP interface MTU from the requested TUN MTU immediately after adapter creation. IPv6 MTU setup is required because Nylon routes IPv6 overlay traffic; IPv4 is set best-effort when available.
Copilot AI review requested due to automatic review settings July 6, 2026 20:40
@tionis

tionis commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

This PR replaces the previous tiny ones (#132 and #130)

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes several issues encountered when running Nylon natively on Windows, improving correctness of interface configuration and robustness of TUN packet handling.

Changes:

  • Configure IPv6 aliases using the netsh interface ipv6 context.
  • Force the Wintun adapter MTU to Nylon’s configured TUN MTU via iphlpapi interface APIs.
  • Harden packet parsing/validation to drop malformed packets where the advertised length exceeds the bytes read, with new unit tests.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
polyamide/tun/tun_windows.go Adds Windows IP Helper calls to set per-family interface MTU during TUN creation.
polyamide/device/traffic_manip.go Makes packet parsing return success/failure and rejects oversized/truncated packets.
polyamide/device/traffic_manip_test.go Adds tests ensuring oversized packets are rejected and valid packets are trimmed correctly.
polyamide/device/traffic_control.go Drops packets when parsing or validation fails.
polyamide/device/send.go Ensures TCElement.Packet is sliced to the exact bytes read from TUN before TC processing.
core/sys_windows.go Uses netsh interface ipv6 ... for IPv6 alias add/delete.

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

Comment on lines +81 to +85
if err := setInterfaceMTU(wt.LUID(), windows.AF_INET6, forcedMTU); err != nil {
wt.Close()
return nil, fmt.Errorf("Error setting IPv6 interface MTU: %w", err)
}
_ = setInterfaceMTU(wt.LUID(), windows.AF_INET, forcedMTU)
@encodeous

Copy link
Copy Markdown
Owner

Looks good!

@encodeous encodeous merged commit eb29da6 into encodeous:main Jul 7, 2026
3 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.

3 participants