From 933f7b79949bc588945672396d70b661143bb8f0 Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Fri, 12 Jan 2024 15:11:49 -0500 Subject: [PATCH] Abandon Connections with Too Many Retired CIDs --- src/core/connection.c | 10 ++++++++++ src/core/connection.h | 5 +++++ src/core/loss_detection.c | 2 ++ 3 files changed, 17 insertions(+) diff --git a/src/core/connection.c b/src/core/connection.c index 3612abcf24..6f63cc0e56 100644 --- a/src/core/connection.c +++ b/src/core/connection.c @@ -990,6 +990,16 @@ QuicConnRetireCid( DestCid->CID.Retired = TRUE; DestCid->CID.NeedsToSend = TRUE; QuicSendSetSendFlag(&Connection->Send, QUIC_CONN_SEND_FLAG_RETIRE_CONNECTION_ID); + + Connection->RetiredDestCidCount++; + if (Connection->RetiredDestCidCount > 8 * QUIC_ACTIVE_CONNECTION_ID_LIMIT) { + QuicTraceEvent( + ConnError, + "[conn][%p] ERROR, %s.", + Connection, + "Peer exceeded retire CID limit"); + QuicConnSilentlyAbort(Connection); + } } _IRQL_requires_max_(PASSIVE_LEVEL) diff --git a/src/core/connection.h b/src/core/connection.h index b347b3c70c..7c1bcbe62f 100644 --- a/src/core/connection.h +++ b/src/core/connection.h @@ -392,6 +392,11 @@ typedef struct QUIC_CONNECTION { // uint8_t DestCidCount; + // + // Number of retired desintation CIDs we currently have cached. + // + uint8_t RetiredDestCidCount; + // // The maximum number of source CIDs to give the peer. This is a minimum of // what we're willing to support and what the peer is willing to accept. diff --git a/src/core/loss_detection.c b/src/core/loss_detection.c index e4356c202a..d8bce352ce 100644 --- a/src/core/loss_detection.c +++ b/src/core/loss_detection.c @@ -608,6 +608,8 @@ QuicLossDetectionOnPacketAcknowledged( CXPLAT_DBG_ASSERT(DestCid->CID.Retired); CXPLAT_DBG_ASSERT(Path == NULL || Path->DestCid != DestCid); QUIC_CID_VALIDATE_NULL(Connection, DestCid); + CXPLAT_DBG_ASSERT(Connection->RetiredDestCidCount > 0); + Connection->RetiredDestCidCount--; CXPLAT_FREE(DestCid, QUIC_POOL_CIDLIST); } break;