Skip to content

Commit

Permalink
Do not try to rotate peer CIDs if the original CID is zero length
Browse files Browse the repository at this point in the history
Reviewed By: lnicco

Differential Revision: D61052814

fbshipit-source-id: 1baabc0d5db9b371bb3901a74b51895998c6de54
  • Loading branch information
kvtsoy authored and facebook-github-bot committed Aug 16, 2024
1 parent 23275bd commit 355c664
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions quic/server/test/QuicServerTransportTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,19 @@ TEST_F(QuicServerTransportTest, SwitchServerCidsMultipleCids) {
EXPECT_EQ(secondCid.connId, *replacedCid);
}

TEST_F(
QuicServerTransportTest,
TestRetireAndSwitchPeerConnectionIdsEmptyPeerCid) {
auto& conn = server->getNonConstConn();

conn.clientConnectionId = ConnectionId(std::vector<uint8_t>{});
EXPECT_EQ(conn.peerConnectionIds.size(), 1);

EXPECT_EQ(conn.retireAndSwitchPeerConnectionIds(), true);
EXPECT_EQ(conn.pendingEvents.frames.size(), 0);
EXPECT_EQ(conn.peerConnectionIds.size(), 1);
}

TEST_F(QuicServerTransportTest, ShortHeaderPacketWithNoFrames) {
auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Server);
server->getNonConstConn().qLogger = qLogger;
Expand Down
5 changes: 5 additions & 0 deletions quic/state/StateData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ bool QuicConnectionStateBase::retireAndSwitchPeerConnectionIds() {
TransportErrorCode::INTERNAL_ERROR);
}

if (mainPeerId->size() == 0) {
// No need to rotate CIDs if peer's CID is 0 length.
return true;
}

// Retrieve the sequence number of the current cId, and find an unused
// ConnectionIdData.
for (auto it = peerConnectionIds.begin(); it != end; it++) {
Expand Down

0 comments on commit 355c664

Please sign in to comment.