diff --git a/src/platform/datapath_raw_win.c b/src/platform/datapath_raw_win.c index cece83bca1..bda2d6c3fd 100644 --- a/src/platform/datapath_raw_win.c +++ b/src/platform/datapath_raw_win.c @@ -123,28 +123,33 @@ RawSocketCreateUdp( memcpy(Socket->CibirId, Config->CibirId, Config->CibirIdLength); } + // + // The socket addresses have been set in the SocketCreateUdp call earlier, + // either form the config or assigned by the OS (for unspecified ports). + // Do no override them from the config here: we need to keep the same OS assigned ports if the + // config doesn't specify them. + // + CXPLAT_DBG_ASSERT( + Config->RemoteAddress == NULL || + QuicAddrCompare(&Socket->RemoteAddress, Config->RemoteAddress)); + CXPLAT_DBG_ASSERT( + Config->LocalAddress == NULL || + QuicAddrGetPort(Config->LocalAddress) == 0 || + QuicAddrGetPort(&Socket->LocalAddress) == QuicAddrGetPort(Config->LocalAddress)); + if (Config->RemoteAddress) { // // This CxPlatSocket is part of a client connection. // CXPLAT_FRE_ASSERT(!QuicAddrIsWildCard(Config->RemoteAddress)); // No wildcard remote addresses allowed. - if (Socket->ReserveAuxTcpSock) { - Socket->RemoteAddress = *Config->RemoteAddress; - if (Config->LocalAddress != NULL) { - Socket->LocalAddress = *Config->LocalAddress; - } else { - QuicAddrSetFamily(&Socket->LocalAddress, QUIC_ADDRESS_FAMILY_INET6); - } - } + Socket->Connected = TRUE; } else { // // This CxPlatSocket is part of a server listener. // CXPLAT_FRE_ASSERT(Config->LocalAddress != NULL); - if (Socket->ReserveAuxTcpSock) { - Socket->LocalAddress = *Config->LocalAddress; - } + if (!QuicAddrIsWildCard(Config->LocalAddress)) { // For server listeners, the local address MUST be a wildcard address. Status = QUIC_STATUS_INVALID_STATE; goto Error;