Skip to content

Conversation

@benhillis
Copy link
Member

Removes this warning from dmesg log:

ip_local_port_range: prefer different parity for start/end values.

Copilot AI review requested due to automatic review settings December 23, 2025 23:00
@benhillis benhillis requested a review from a team as a code owner December 23, 2025 23:00
Copy link
Contributor

Copilot AI left a 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);
Copy link

Copilot AI Dec 23, 2025

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.

Suggested change
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 uses AI. Check for mistakes.
@benhillis
Copy link
Member Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Dec 24, 2025

@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]>
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