Skip to content
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

Grab a UDP Port Reservation #2017

Merged
merged 11 commits into from
Oct 5, 2021
35 changes: 35 additions & 0 deletions src/platform/datapath_winuser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,41 @@ QUIC_DISABLED_BY_FUZZER_START;
}
}

if (i == 0 &&
Config->LocalAddress &&
Config->LocalAddress->Ipv4.sin_port != 0) {
//
// Create a port reservation for the local port.
//
INET_PORT_RESERVATION_INSTANCE PortReservation;
INET_PORT_RANGE PortRange;
PortRange.StartPort = htons(Config->LocalAddress->Ipv4.sin_port);
nibanks marked this conversation as resolved.
Show resolved Hide resolved
PortRange.NumberOfPorts = 1;

Result =
WSAIoctl(
SocketProc->Socket,
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;
}
}

Result =
bind(
SocketProc->Socket,
Expand Down