Skip to content

Commit

Permalink
Revert "Grab a UDP Port Reservation (#2017)" (#2065)
Browse files Browse the repository at this point in the history
This reverts commit 8d14aba.
  • Loading branch information
thhous-msft authored Oct 7, 2021
1 parent 8b52f9e commit a0bed40
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 183 deletions.
72 changes: 0 additions & 72 deletions src/generated/linux/datapath_winuser.c.clog.h
Original file line number Diff line number Diff line change
Expand Up @@ -867,54 +867,6 @@ tracepoint(CLOG_DATAPATH_WINUSER_C, DatapathErrorStatus , arg2, arg3, arg4);\



#ifndef _clog_5_ARGS_TRACE_DatapathErrorStatus



/*----------------------------------------------------------
// Decoder Ring for DatapathErrorStatus
// [data][%p] ERROR, %u, %s.
// QuicTraceEvent(
DatapathErrorStatus,
"[data][%p] ERROR, %u, %s.",
Socket,
WsaError,
"SIO_ACQUIRE_PORT_RESERVATION");
// arg2 = arg2 = Socket
// arg3 = arg3 = WsaError
// arg4 = arg4 = "SIO_ACQUIRE_PORT_RESERVATION"
----------------------------------------------------------*/
#define _clog_5_ARGS_TRACE_DatapathErrorStatus(uniqueId, encoded_arg_string, arg2, arg3, arg4)\

#endif




#ifndef _clog_5_ARGS_TRACE_DatapathErrorStatus



/*----------------------------------------------------------
// Decoder Ring for DatapathErrorStatus
// [data][%p] ERROR, %u, %s.
// QuicTraceEvent(
DatapathErrorStatus,
"[data][%p] ERROR, %u, %s.",
Socket,
WsaError,
"WSASocketW");
// arg2 = arg2 = Socket
// arg3 = arg3 = WsaError
// arg4 = arg4 = "WSASocketW"
----------------------------------------------------------*/
#define _clog_5_ARGS_TRACE_DatapathErrorStatus(uniqueId, encoded_arg_string, arg2, arg3, arg4)\

#endif




#ifndef _clog_5_ARGS_TRACE_DatapathErrorStatus


Expand Down Expand Up @@ -1251,30 +1203,6 @@ tracepoint(CLOG_DATAPATH_WINUSER_C, DatapathErrorStatus , arg2, arg3, arg4);\



#ifndef _clog_5_ARGS_TRACE_DatapathErrorStatus



/*----------------------------------------------------------
// Decoder Ring for DatapathErrorStatus
// [data][%p] ERROR, %u, %s.
// QuicTraceEvent(
DatapathErrorStatus,
"[data][%p] ERROR, %u, %s.",
Socket,
WsaError,
"SIO_ASSOCIATE_PORT_RESERVATION");
// arg2 = arg2 = Socket
// arg3 = arg3 = WsaError
// arg4 = arg4 = "SIO_ASSOCIATE_PORT_RESERVATION"
----------------------------------------------------------*/
#define _clog_5_ARGS_TRACE_DatapathErrorStatus(uniqueId, encoded_arg_string, arg2, arg3, arg4)\

#endif




#ifndef _clog_5_ARGS_TRACE_DatapathErrorStatus


Expand Down
106 changes: 1 addition & 105 deletions src/platform/datapath_winuser.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,6 @@ typedef struct CXPLAT_SOCKET {
//
void *ClientContext;

//
// Socket to contain the port reservation.
//
SOCKET PortReservationSocket;

//
// Per-processor socket contexts.
//
Expand Down Expand Up @@ -1415,8 +1410,6 @@ CxPlatSocketCreateUdp(
int Option;
BOOLEAN IsServerSocket = Config->RemoteAddress == NULL;
uint16_t SocketCount = IsServerSocket ? Datapath->ProcCount : 1;
INET_PORT_RESERVATION_INSTANCE PortReservation;
DWORD BytesReturned;

CXPLAT_DBG_ASSERT(Datapath->UdpHandlers.Receive != NULL || Config->Flags & CXPLAT_SOCKET_FLAG_PCP);

Expand Down Expand Up @@ -1452,7 +1445,6 @@ CxPlatSocketCreateUdp(
Socket->LocalAddress.si_family = QUIC_ADDRESS_FAMILY_INET6;
}
Socket->Mtu = CXPLAT_MAX_MTU;
Socket->PortReservationSocket = INVALID_SOCKET;
CxPlatRundownAcquire(&Datapath->SocketsRundown);
if (Config->Flags & CXPLAT_SOCKET_FLAG_PCP) {
Socket->PcpBinding = TRUE;
Expand All @@ -1468,65 +1460,11 @@ CxPlatSocketCreateUdp(
CxPlatRundownInitialize(&Socket->Processors[i].UpcallRundown);
}

if (Config->LocalAddress && Config->LocalAddress->Ipv4.sin_port != 0) {
//
// Create a socket for port reservation for the local port.
//
Socket->PortReservationSocket =
WSASocketW(
AF_INET6,
SOCK_DGRAM,
IPPROTO_UDP,
NULL,
0,
WSA_FLAG_OVERLAPPED);
if (Socket->PortReservationSocket == INVALID_SOCKET) {
int WsaError = WSAGetLastError();
QuicTraceEvent(
DatapathErrorStatus,
"[data][%p] ERROR, %u, %s.",
Socket,
WsaError,
"WSASocketW");
Status = HRESULT_FROM_WIN32(WsaError);
goto Error;
}

//
// Create a port reservation for the local port.
//
INET_PORT_RANGE PortRange;
PortRange.StartPort = Config->LocalAddress->Ipv4.sin_port;
PortRange.NumberOfPorts = 1;

Result =
WSAIoctl(
Socket->PortReservationSocket,
SIO_ACQUIRE_PORT_RESERVATION,
&PortRange,
sizeof(PortRange),
&PortReservation,
sizeof(PortReservation),
&BytesReturned,
NULL,
NULL);
if (Result == SOCKET_ERROR) {
int WsaError = WSAGetLastError();
QuicTraceEvent(
DatapathErrorStatus,
"[data][%p] ERROR, %u, %s.",
Socket,
WsaError,
"SIO_ACQUIRE_PORT_RESERVATION");
Status = HRESULT_FROM_WIN32(WsaError);
goto Error;
}
}

for (uint16_t i = 0; i < SocketCount; i++) {

CXPLAT_SOCKET_PROC* SocketProc = &Socket->Processors[i];
uint16_t AffinitizedProcessor = (uint16_t)i;
DWORD BytesReturned;

SocketProc->Socket =
WSASocketW(
Expand Down Expand Up @@ -1851,35 +1789,6 @@ QUIC_DISABLED_BY_FUZZER_START;
}
}

if (Config->LocalAddress &&
Config->LocalAddress->Ipv4.sin_port != 0) {
//
// Associate the port reservation with the socket.
//
Result =
WSAIoctl(
SocketProc->Socket,
SIO_ASSOCIATE_PORT_RESERVATION,
&PortReservation.Token,
sizeof(PortReservation.Token),
NULL,
0,
&BytesReturned,
NULL,
NULL);
if (Result == SOCKET_ERROR) {
int WsaError = WSAGetLastError();
QuicTraceEvent(
DatapathErrorStatus,
"[data][%p] ERROR, %u, %s.",
Socket,
WsaError,
"SIO_ASSOCIATE_PORT_RESERVATION");
Status = HRESULT_FROM_WIN32(WsaError);
goto Error;
}
}

Result =
bind(
SocketProc->Socket,
Expand Down Expand Up @@ -2009,9 +1918,6 @@ QUIC_DISABLED_BY_FUZZER_END;

CxPlatRundownUninitialize(&SocketProc->UpcallRundown);
}
if (Socket->PortReservationSocket != INVALID_SOCKET) {
closesocket(Socket->PortReservationSocket);
}
CxPlatRundownRelease(&Datapath->SocketsRundown);
CXPLAT_FREE(Socket, QUIC_POOL_SOCKET);
}
Expand Down Expand Up @@ -2075,7 +1981,6 @@ CxPlatSocketCreateTcpInternal(
((uint16_t)CxPlatProcCurrentNumber()) % Datapath->ProcCount;
}
Socket->Mtu = CXPLAT_MAX_MTU;
Socket->PortReservationSocket = INVALID_SOCKET;
CxPlatRundownAcquire(&Datapath->SocketsRundown);

SocketProc = &Socket->Processors[0];
Expand Down Expand Up @@ -2376,7 +2281,6 @@ CxPlatSocketCreateTcpListener(
Socket->LocalAddress.si_family = QUIC_ADDRESS_FAMILY_INET6;
}
Socket->Mtu = CXPLAT_MAX_MTU;
Socket->PortReservationSocket = INVALID_SOCKET;
CxPlatRundownAcquire(&Datapath->SocketsRundown);

SocketProc = &Socket->Processors[0];
Expand Down Expand Up @@ -2721,14 +2625,6 @@ CxPlatDataPathSocketContextShutdown(
//
// Last socket context cleaned up, so now the binding can be freed.
//

//
// Close the port reservation socket. TCP does not create it, so
// we must check for invalid value.
//
if (SocketProc->Parent->PortReservationSocket != INVALID_SOCKET) {
closesocket(SocketProc->Parent->PortReservationSocket);
}
CxPlatRundownRelease(&SocketProc->Parent->Datapath->SocketsRundown);
QuicTraceLogVerbose(
DatapathShutDownComplete,
Expand Down
6 changes: 0 additions & 6 deletions src/test/lib/HandshakeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2642,13 +2642,7 @@ QuicTestLoadBalancedHandshake(
// Sometimes the local port might be used already. Just ignore this
// failure and continue on.
//
#ifdef WSAEACCES
TEST_TRUE(
Connection.TransportShutdownStatus == QUIC_STATUS_ADDRESS_IN_USE ||
Connection.TransportShutdownStatus == HRESULT_FROM_WIN32(WSAEACCES));
#else
TEST_TRUE(Connection.TransportShutdownStatus == QUIC_STATUS_ADDRESS_IN_USE);
#endif

} else {
if (SchannelMode) {
Expand Down

0 comments on commit a0bed40

Please sign in to comment.