Fix native Windows TUN setup#133
Merged
Merged
Conversation
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.
Contributor
Author
There was a problem hiding this comment.
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 ipv6context. - Force the Wintun adapter MTU to Nylon’s configured TUN MTU via
iphlpapiinterface 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) |
Owner
|
Looks good! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a few issues found while running Nylon natively on Windows:
netsh interface ipv6context when configuring IPv6 aliases65535