Skip to content

Linux Port Selection Logic Aggressively Shares Ports #2610

Open
@nibanks

Description

@nibanks

Describe the bug

It seems that the Linux port selection logic will (too) aggressively share local ports between both connected and unconnected sockets. The following happened in a recent test (causing a failure):

quic.log

  1. Server (unbound) socket is started with no specified local port. Linux stack assigns port X as local port.
  2. Client (unbound) socket is created and then connected to port X. Linux stack also assigns port X as the local port.
  3. Client socket sends packet to Server.
  4. Client socket receives packet.
 [0][3846.3846][07:15:39.400854][data][0x55ff8e028000] Created, local=[::]:0, remote=None
 [0][3846.3846][07:15:39.401113][list][0x55ff8e026860] Started, Binding=0x55ff8e024a50, LocalAddr=*:41012, ALPN=MsQuicTest

 [1][3846.384d][07:15:39.401545][data][0x7fe56c001e30] Created, local=None, remote=127.0.0.1:41012
 [1][3846.384d][07:15:39.401642][conn][0x55ff8e0506a0] New Local IP: 127.0.0.1:41012

 [1][3846.384d][07:15:39.401925][data][0x7fe56c001e30] Send 1220 bytes in 1 buffers (segment=1220) Dst=127.0.0.1:41012, Src=127.0.0.1:41012
 [1][3846.384c][07:15:39.402035][data][0x7fe56c001e30] Recv 1220 bytes (segment=1220) Src=127.0.0.1:41012 Dst=127.0.0.1:41012
 [1][3846.384c][07:15:39.402039][bind][0x7fe56c001470] DROP packet Dst=127.0.0.1:41012 Src=127.0.0.1:41012 Reason=No listeners registered to accept new connection..

Somehow we need to detect and prevent this from happening.

Affected OS

  • All
  • Windows Server 2022
  • Windows 11
  • Windows Insider Preview (specify affected build below)
  • Ubuntu
  • Debian
  • Other (specify below)

MsQuic version

main / ALL

Steps taken to reproduce bug

  1. Run test on Linux

Expected behavior

The tests should pass

Actual outcome

Occasionally the tests fail because of shared ports assigned by the Linux stack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    Should be written

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions