-
Notifications
You must be signed in to change notification settings - Fork 1.6k
WSlA: Adjust default CONTAINER_PORT_RANGE to avoid dmesg warning around port range parity #13974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/wsl-for-apps
Are you sure you want to change the base?
WSlA: Adjust default CONTAINER_PORT_RANGE to avoid dmesg warning around port range parity #13974
Conversation
…nd port range parity
There was a problem hiding this comment.
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 attempts to fix a Linux kernel dmesg warning about port range parity by changing the CONTAINER_PORT_RANGE start value from 20001 to 20000. However, this change targets the wrong constant and introduces a critical compilation error.
Key issues:
- The change will cause a compilation failure due to a violated static_assert
- The fix targets a Windows-side constant that doesn't affect the Linux kernel's port range configuration
- The actual warning originates from a different port range (c_ephemeralPortRange) that is written to the Linux kernel
| constexpr auto SAVED_STATE_FILE_PREFIX = L"saved-state-"; | ||
| constexpr auto RECEIVE_TIMEOUT = 30 * 1000; | ||
| constexpr auto CONTAINER_PORT_RANGE = std::pair<uint16_t, uint16_t>(20001, 65535); | ||
| constexpr auto CONTAINER_PORT_RANGE = std::pair<uint16_t, uint16_t>(20000, 65535); |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change introduces a critical compilation error and does not fix the intended issue.
Compilation Error: The static_assert on line 37 will fail because c_ephemeralPortRange.second < CONTAINER_PORT_RANGE.first evaluates to 20000 < 20000, which is false. This creates an overlap where port 20000 is in both the ephemeral range (10000-20000) and the container range (20000-65535).
Incorrect Fix Location: The dmesg warning "ip_local_port_range: prefer different parity for start/end values" is generated by the Linux kernel when writing to /proc/sys/net/ipv4/ip_local_port_range. This is set in WSLAInit.cpp line 890-892 using c_ephemeralPortRange which is (10000, 20000) - both even numbers with the same parity. CONTAINER_PORT_RANGE is only used on the Windows side for port allocation tracking and is never written to the Linux kernel's ip_local_port_range.
Correct Fix: To fix the warning, change c_ephemeralPortRange in src/shared/inc/lxinitshared.h from (10000, 20000) to (10000, 20001) to achieve different parity (10000 is even, 20001 is odd), and leave CONTAINER_PORT_RANGE unchanged at (20001, 65535) to maintain the non-overlapping assertion.
| constexpr auto CONTAINER_PORT_RANGE = std::pair<uint16_t, uint16_t>(20000, 65535); | |
| constexpr auto CONTAINER_PORT_RANGE = std::pair<uint16_t, uint16_t>(20001, 65535); |
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@benhillis I've opened a new pull request, #13976, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Initial plan * Fix port range parity warning by adjusting ephemeral range - Changed c_ephemeralPortRange from (10000, 20000) to (10000, 20001) to fix parity - 10000 is even, 20001 is odd - different parity eliminates dmesg warning - Changed CONTAINER_PORT_RANGE from (20000, 65535) to (20002, 65535) - Ensures non-overlapping ranges and static_assert passes (20001 < 20002) - Reverts incorrect change from previous commit that set it to 20000 Co-authored-by: benhillis <[email protected]> * Final progress update Co-authored-by: benhillis <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: benhillis <[email protected]>
Removes this warning from dmesg log: