Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/core/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -5769,21 +5769,14 @@ QuicConnRecvDatagrams(
CXPLAT_DBG_ASSERT(Packet->ReleaseDeferred == IsDeferred);
Packet->ReleaseDeferred = FALSE;

QUIC_PATH* DatagramPath = QuicConnGetPathForPacket(Connection, Packet);
if (DatagramPath == NULL) {
QuicPacketLogDrop(Connection, Packet, "Max paths already tracked");
goto Drop;
}

CxPlatUpdateRoute(&DatagramPath->Route, Packet->Route);

if (DatagramPath != CurrentPath) {
if (CurrentPath == NULL) {
CurrentPath = QuicConnGetPathForPacket(Connection, Packet);
} else if (!QuicPathMatchPacket(CurrentPath, Packet)) {
if (BatchCount != 0) {
//
// This datagram is from a different path than the current
// batch. Flush the current batch before continuing.
//
CXPLAT_DBG_ASSERT(CurrentPath != NULL);
QuicConnRecvDatagramBatch(
Connection,
CurrentPath,
Expand All @@ -5793,9 +5786,20 @@ QuicConnRecvDatagrams(
&RecvState);
BatchCount = 0;
}
CurrentPath = DatagramPath;
//
// Path lookup can modify the path array, so only do it after the
// current batch no longer holds a path pointer.
//
CurrentPath = QuicConnGetPathForPacket(Connection, Packet);
}

if (CurrentPath == NULL) {
QuicPacketLogDrop(Connection, Packet, "Max paths already tracked");
goto Drop;
}

CxPlatUpdateRoute(&CurrentPath->Route, Packet->Route);

if (!IsDeferred) {
Connection->Stats.Recv.TotalBytes += Packet->BufferLength;
if (Connection->Stats.Handshake.HandshakeHopLimitTTL == 0) {
Expand Down
23 changes: 17 additions & 6 deletions src/core/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,22 @@ QuicConnGetPathByID(
return NULL;
}

_IRQL_requires_max_(PASSIVE_LEVEL)
BOOLEAN
QuicPathMatchPacket(
_In_ const QUIC_PATH* Path,
_In_ const QUIC_RX_PACKET* Packet
)
{
return
QuicAddrCompare(
&Packet->Route->LocalAddress,
&Path->Route.LocalAddress) &&
QuicAddrCompare(
&Packet->Route->RemoteAddress,
&Path->Route.RemoteAddress);
}

_IRQL_requires_max_(PASSIVE_LEVEL)
_Ret_maybenull_
QUIC_PATH*
Expand All @@ -267,12 +283,7 @@ QuicConnGetPathForPacket(
{
QUIC_PATH_SET* PathSet = &Connection->Paths;
for (uint8_t i = 0; i < PathSet->Count; ++i) {
if (!QuicAddrCompare(
&Packet->Route->LocalAddress,
&PathSet->Paths[i].Route.LocalAddress) ||
!QuicAddrCompare(
&Packet->Route->RemoteAddress,
&PathSet->Paths[i].Route.RemoteAddress)) {
if (!QuicPathMatchPacket(&PathSet->Paths[i], Packet)) {
if (!Connection->State.HandshakeConfirmed) {
//
// Ignore packets on any other paths until connected/confirmed.
Expand Down
7 changes: 7 additions & 0 deletions src/core/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,13 @@ QuicConnGetPathByID(
_Out_ uint8_t* Index
);

_IRQL_requires_max_(PASSIVE_LEVEL)
BOOLEAN
QuicPathMatchPacket(
_In_ const QUIC_PATH* Path,
_In_ const QUIC_RX_PACKET* Packet
);

_IRQL_requires_max_(PASSIVE_LEVEL)
_Ret_maybenull_
QUIC_PATH*
Expand Down
Loading