Remove QuicPerPacketContext from QUICHE. QuicPerPacketContext was only used by UDP proxy, which has been deprecated. GFE currently doesn't create QuicPerPacketContext instances. PiperOrigin-RevId: 836355177
diff --git a/quiche/quic/core/quic_dispatcher.cc b/quiche/quic/core/quic_dispatcher.cc index ac49e68..acbda23 100644 --- a/quiche/quic/core/quic_dispatcher.cc +++ b/quiche/quic/core/quic_dispatcher.cc
@@ -498,7 +498,7 @@ time_wait_list_manager_->ProcessPacket( packet_info.self_address, packet_info.peer_address, packet_info.destination_connection_id, packet_info.form, - packet_info.packet.length(), GetPerPacketContext()); + packet_info.packet.length()); return true; } @@ -520,7 +520,7 @@ time_wait_list_manager()->ProcessPacket( packet_info.self_address, packet_info.peer_address, packet_info.destination_connection_id, packet_info.form, - packet_info.packet.length(), GetPerPacketContext()); + packet_info.packet.length()); OnNewConnectionRejected(); return true; } @@ -633,8 +633,8 @@ server_connection_id)); time_wait_list_manager_->ProcessPacket( packet_info->self_address, packet_info->peer_address, - server_connection_id, packet_info->form, packet_info->packet.length(), - GetPerPacketContext()); + server_connection_id, packet_info->form, + packet_info->packet.length()); buffered_packets_.DiscardPackets(server_connection_id); } break; @@ -892,11 +892,6 @@ return snapshot; } -std::unique_ptr<QuicPerPacketContext> QuicDispatcher::GetPerPacketContext() - const { - return nullptr; -} - void QuicDispatcher::DeleteSessions() { if (!write_blocked_list_.Empty()) { for (const auto& session : closed_session_list_) { @@ -1540,8 +1535,7 @@ time_wait_list_manager()->SendPublicReset( packet_info.self_address, packet_info.peer_address, packet_info.destination_connection_id, - packet_info.form != GOOGLE_QUIC_Q043_PACKET, packet_info.packet.length(), - GetPerPacketContext()); + packet_info.form != GOOGLE_QUIC_Q043_PACKET, packet_info.packet.length()); } bool QuicDispatcher::MaybeSendVersionNegotiationPacket( @@ -1558,8 +1552,7 @@ packet_info.destination_connection_id, packet_info.source_connection_id, packet_info.form != GOOGLE_QUIC_Q043_PACKET, packet_info.use_length_prefix, GetSupportedVersions(), - packet_info.self_address, packet_info.peer_address, - GetPerPacketContext()); + packet_info.self_address, packet_info.peer_address); return true; }
diff --git a/quiche/quic/core/quic_dispatcher.h b/quiche/quic/core/quic_dispatcher.h index 960300c..594c08b 100644 --- a/quiche/quic/core/quic_dispatcher.h +++ b/quiche/quic/core/quic_dispatcher.h
@@ -322,11 +322,6 @@ const std::optional<QuicConnectionId>& replaced_connection_id, QuicPacketNumber last_sent_packet_number); - // Save/Restore per packet context. - virtual std::unique_ptr<QuicPerPacketContext> GetPerPacketContext() const; - virtual void RestorePerPacketContext( - std::unique_ptr<QuicPerPacketContext> /*context*/) {} - // Called if a packet from an unseen connection is reset or rejected. virtual void OnNewConnectionRejected() {}
diff --git a/quiche/quic/core/quic_dispatcher_test.cc b/quiche/quic/core/quic_dispatcher_test.cc index 0ae5f39..635587c 100644 --- a/quiche/quic/core/quic_dispatcher_test.cc +++ b/quiche/quic/core/quic_dispatcher_test.cc
@@ -162,25 +162,6 @@ MOCK_METHOD(ConnectionIdGeneratorInterface&, ConnectionIdGenerator, (), (override)); - struct TestQuicPerPacketContext : public QuicPerPacketContext { - std::string custom_packet_context; - }; - - std::unique_ptr<QuicPerPacketContext> GetPerPacketContext() const override { - auto test_context = std::make_unique<TestQuicPerPacketContext>(); - test_context->custom_packet_context = custom_packet_context_; - return std::move(test_context); - } - - void RestorePerPacketContext( - std::unique_ptr<QuicPerPacketContext> context) override { - TestQuicPerPacketContext* test_context = - static_cast<TestQuicPerPacketContext*>(context.get()); - custom_packet_context_ = test_context->custom_packet_context; - } - - std::string custom_packet_context_; - using QuicDispatcher::ConnectionIdGenerator; using QuicDispatcher::MaybeDispatchPacket; using QuicDispatcher::writer; @@ -899,7 +880,7 @@ EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); EXPECT_CALL( *time_wait_list_manager_, - SendVersionNegotiationPacket(TestConnectionId(1), _, _, _, _, _, _, _)) + SendVersionNegotiationPacket(TestConnectionId(1), _, _, _, _, _, _)) .Times(1); expect_generator_is_called_ = false; ProcessFirstFlight(QuicVersionReservedForNegotiation(), client_address, @@ -914,7 +895,7 @@ EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, - SendVersionNegotiationPacket(connection_id, _, _, _, _, _, _, _)) + SendVersionNegotiationPacket(connection_id, _, _, _, _, _, _)) .Times(1); expect_generator_is_called_ = false; ProcessFirstFlight(QuicVersionReservedForNegotiation(), client_address, @@ -928,8 +909,8 @@ EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, - SendVersionNegotiationPacket( - TestConnectionId(1), TestConnectionId(2), _, _, _, _, _, _)) + SendVersionNegotiationPacket(TestConnectionId(1), + TestConnectionId(2), _, _, _, _, _)) .Times(1); expect_generator_is_called_ = false; ProcessFirstFlight(QuicVersionReservedForNegotiation(), client_address, @@ -942,7 +923,7 @@ EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, - SendVersionNegotiationPacket(_, _, _, _, _, _, _, _)) + SendVersionNegotiationPacket(_, _, _, _, _, _, _)) .Times(0); std::string chlo = SerializeCHLO() + std::string(1200, 'a'); // Truncate to 1100 bytes of payload which results in a packet just @@ -976,7 +957,7 @@ EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, - SendVersionNegotiationPacket(_, _, _, _, _, _, _, _)) + SendVersionNegotiationPacket(_, _, _, _, _, _, _)) .Times(0); dispatcher_->ProcessPacket( @@ -996,7 +977,7 @@ EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, - SendVersionNegotiationPacket(_, _, _, _, _, _, _, _)) + SendVersionNegotiationPacket(_, _, _, _, _, _, _)) .Times(1); std::string chlo = SerializeCHLO() + std::string(1200, 'a'); // Truncate to 1100 bytes of payload which results in a packet just @@ -1062,7 +1043,7 @@ // Dispatcher forwards subsequent packets for this connection_id to the time // wait list manager. EXPECT_CALL(*time_wait_list_manager_, - ProcessPacket(_, _, connection_id, _, _, _)) + ProcessPacket(_, _, connection_id, _, _)) .Times(1); EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _)) .Times(0); @@ -1078,11 +1059,11 @@ // list manager. EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, - ProcessPacket(_, _, connection_id, _, _, _)) + ProcessPacket(_, _, connection_id, _, _)) .Times(0); EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _)) .Times(0); - EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) .Times(1); ProcessPacket(client_address, connection_id, /*has_version_flag=*/false, "data"); @@ -1101,19 +1082,18 @@ QuicReceivedPacket packet2(reinterpret_cast<char*>(valid_size_packet), short_packet_len + 1, QuicTime::Zero()); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _, _)) - .Times(0); + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _)) .Times(0); // Verify small packet is silently dropped. EXPECT_CALL(connection_id_generator_, ConnectionIdLength(0xa7)) .WillOnce(Return(kQuicDefaultConnectionIdLength)); - EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) .Times(0); dispatcher_->ProcessPacket(server_address_, client_address, packet); EXPECT_CALL(connection_id_generator_, ConnectionIdLength(0xa7)) .WillOnce(Return(kQuicDefaultConnectionIdLength)); - EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, packet2); } @@ -1125,11 +1105,10 @@ QuicReceivedPacket packet(reinterpret_cast<char*>(all_zero_packet), sizeof(all_zero_packet), QuicTime::Zero()); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _, _)) - .Times(0); + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _)) .Times(0); - EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) .Times(0); EXPECT_CALL(connection_id_generator_, ConnectionIdLength(_)) .WillOnce(Return(kQuicDefaultConnectionIdLength)); @@ -1146,7 +1125,7 @@ // Verify only one reset is sent to the address, although multiple packets // are received. - EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) .Times(1); ProcessPacket(client_address, connection_id, /*has_version_flag=*/false, "data"); @@ -1155,7 +1134,7 @@ ProcessPacket(client_address, connection_id, /*has_version_flag=*/false, "data3"); - EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) .Times(2); ProcessPacket(client_address2, connection_id, /*has_version_flag=*/false, "data"); @@ -1176,7 +1155,7 @@ QuicSocketAddress client_address3(QuicIpAddress::Loopback6(), 1); QuicConnectionId connection_id = TestConnectionId(1); - EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) .Times(2); EXPECT_FALSE(GetClearResetAddressesAlarm()->IsSet()); ProcessPacket(client_address, connection_id, /*has_version_flag=*/false, @@ -1194,14 +1173,14 @@ // Verify deadline does not change. EXPECT_EQ(expected_deadline, GetClearResetAddressesAlarm()->deadline()); // Verify reset gets throttled since there are too many recent addresses. - EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) .Times(0); ProcessPacket(client_address3, connection_id, /*has_version_flag=*/false, "data"); mock_helper_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); GetClearResetAddressesAlarm()->Fire(); - EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, SendPublicReset(_, _, _, _, _)) .Times(2); ProcessPacket(client_address, connection_id, /*has_version_flag=*/false, "data"); @@ -1297,8 +1276,7 @@ EXPECT_CALL(*dispatcher_, CreateQuicSession(TestConnectionId(1), _, client_address, _, _, _, _)) .Times(0); - EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _, _)) - .Times(0); + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _)) .Times(0); ProcessPacket(client_address, TestConnectionId(1), /*has_version_flag=*/true, @@ -1314,8 +1292,7 @@ EXPECT_CALL(*dispatcher_, CreateQuicSession(TestConnectionId(1), _, client_address, _, _, _, _)) .Times(0); - EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _, _)) - .Times(0); + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _)) .Times(0); ProcessPacket(client_address, TestConnectionId(1), /*has_version_flag=*/true, @@ -1354,8 +1331,7 @@ EXPECT_CALL(connection_id_generator_, ConnectionIdLength(0x00)) .WillOnce(Return(10)); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _, _)) - .Times(0); + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _)) .Times(0); expect_generator_is_called_ = false; @@ -1371,8 +1347,7 @@ // dispatcher_ should drop this packet with invalid connection ID. EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _, _)) - .Times(0); + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _)) .Times(0); absl::string_view cid_str = "123456789abcdefg123456789abcdefg"; @@ -1399,7 +1374,7 @@ SendVersionNegotiationPacket( server_connection_id, client_connection_id, /*ietf_quic=*/true, - /*use_length_prefix=*/true, _, _, client_address, _)) + /*use_length_prefix=*/true, _, _, client_address)) .Times(1); expect_generator_is_called_ = false; EXPECT_CALL(connection_id_generator_, ConnectionIdLength(_)).Times(0); @@ -1452,10 +1427,9 @@ QuicReceivedPacket received_packet(reinterpret_cast<char*>(packet), ABSL_ARRAYSIZE(packet), QuicTime::Zero()); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL( - *time_wait_list_manager_, - SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, - /*use_length_prefix=*/true, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, + SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, + /*use_length_prefix=*/true, _, _, _)) .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, received_packet); } @@ -1469,10 +1443,9 @@ QuicReceivedPacket received_packet(reinterpret_cast<char*>(packet), ABSL_ARRAYSIZE(packet), QuicTime::Zero()); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL( - *time_wait_list_manager_, - SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, - /*use_length_prefix=*/true, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, + SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, + /*use_length_prefix=*/true, _, _, _)) .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, received_packet); } @@ -1486,10 +1459,9 @@ QuicReceivedPacket received_packet(reinterpret_cast<char*>(packet), ABSL_ARRAYSIZE(packet), QuicTime::Zero()); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL( - *time_wait_list_manager_, - SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, - /*use_length_prefix=*/true, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, + SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, + /*use_length_prefix=*/true, _, _, _)) .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, received_packet); } @@ -1503,10 +1475,9 @@ QuicReceivedPacket received_packet(reinterpret_cast<char*>(packet), ABSL_ARRAYSIZE(packet), QuicTime::Zero()); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL( - *time_wait_list_manager_, - SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, - /*use_length_prefix=*/true, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, + SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, + /*use_length_prefix=*/true, _, _, _)) .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, received_packet); } @@ -1520,10 +1491,9 @@ QuicReceivedPacket received_packet(reinterpret_cast<char*>(packet), ABSL_ARRAYSIZE(packet), QuicTime::Zero()); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL( - *time_wait_list_manager_, - SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, - /*use_length_prefix=*/true, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, + SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, + /*use_length_prefix=*/true, _, _, _)) .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, received_packet); } @@ -1540,7 +1510,7 @@ EXPECT_CALL( *time_wait_list_manager_, SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, - /*use_length_prefix=*/false, _, _, _, _)) + /*use_length_prefix=*/false, _, _, _)) .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, received_packet); } @@ -1557,7 +1527,7 @@ EXPECT_CALL( *time_wait_list_manager_, SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, - /*use_length_prefix=*/false, _, _, _, _)) + /*use_length_prefix=*/false, _, _, _)) .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, received_packet); } @@ -1574,7 +1544,7 @@ EXPECT_CALL( *time_wait_list_manager_, SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, - /*use_length_prefix=*/false, _, _, _, _)) + /*use_length_prefix=*/false, _, _, _)) .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, received_packet); } @@ -1592,7 +1562,7 @@ EXPECT_CALL( *time_wait_list_manager_, SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, - /*use_length_prefix=*/false, _, _, _, _)) + /*use_length_prefix=*/false, _, _, _)) .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, received_packet44); @@ -1608,10 +1578,9 @@ kMinPacketSizeForVersionNegotiation, QuicTime::Zero()); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL( - *time_wait_list_manager_, - SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, - /*use_length_prefix=*/true, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, + SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, + /*use_length_prefix=*/true, _, _, _)) .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, received_packet); } @@ -1626,10 +1595,9 @@ kMinPacketSizeForVersionNegotiation, QuicTime::Zero()); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL( - *time_wait_list_manager_, - SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, - /*use_length_prefix=*/true, _, _, _, _)) + EXPECT_CALL(*time_wait_list_manager_, + SendVersionNegotiationPacket(_, _, /*ietf_quic=*/true, + /*use_length_prefix=*/true, _, _, _)) .Times(1); dispatcher_->ProcessPacket(server_address_, client_address, received_packet); } @@ -1656,7 +1624,7 @@ EXPECT_CALL(*time_wait_list_manager_, SendVersionNegotiationPacket( server_connection_id, client_connection_id, - /*ietf_quic=*/true, /*use_length_prefix=*/true, _, _, _, _)) + /*ietf_quic=*/true, /*use_length_prefix=*/true, _, _, _)) .Times(1); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); @@ -1921,7 +1889,7 @@ EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); EXPECT_CALL( *time_wait_list_manager_, - SendVersionNegotiationPacket(TestConnectionId(1), _, _, _, _, _, _, _)) + SendVersionNegotiationPacket(TestConnectionId(1), _, _, _, _, _, _)) .Times(1); expect_generator_is_called_ = false; ProcessFirstFlight(QuicVersionReservedForNegotiation(), client_address, @@ -1935,7 +1903,7 @@ EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); EXPECT_CALL( *time_wait_list_manager_, - SendVersionNegotiationPacket(TestConnectionId(1), _, _, _, _, _, _, _)) + SendVersionNegotiationPacket(TestConnectionId(1), _, _, _, _, _, _)) .Times(1); expect_generator_is_called_ = false; ProcessFirstFlight(version_, client_address, TestConnectionId(1)); @@ -1959,8 +1927,7 @@ QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); QuicConnectionId connection_id = TestConnectionId(1); EXPECT_CALL(*dispatcher_, CreateQuicSession(_, _, _, _, _, _, _)).Times(0); - EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _, _)) - .Times(0); + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, _, _, _)).Times(0); EXPECT_CALL(*time_wait_list_manager_, AddConnectionIdToTimeWait(_, _)) .Times(0); @@ -2662,8 +2629,7 @@ if (GetQuicRestartFlag(quic_dispatcher_close_connection_on_invalid_ack)) { // As this packet contains an invalid ack, the dispatcher should add // the connection to time-wait list. - EXPECT_CALL(*time_wait_list_manager_, - ProcessPacket(_, _, conn_id, _, _, _)); + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, conn_id, _, _)); ProcessReceivedPacket(std::move(received_packet_with_invalid_ack), client_addr_, version_, conn_id); EXPECT_TRUE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); @@ -2760,8 +2726,7 @@ // Processing the packet with invalid ack should not create a new // session and the connection should be added to time-wait list. The // dispatcher should close the connection. - EXPECT_CALL(*time_wait_list_manager_, - ProcessPacket(_, _, conn_id, _, _, _)); + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, conn_id, _, _)); ProcessReceivedPacket(std::move(received_packet_with_invalid_ack), client_addr_, version_, conn_id); EXPECT_TRUE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); @@ -2804,8 +2769,7 @@ // Processing the packet with invalid ack should not create a new // session and the connection should be added to time-wait list. The // dispatcher should close the connection. - EXPECT_CALL(*time_wait_list_manager_, - ProcessPacket(_, _, conn_id, _, _, _)); + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, conn_id, _, _)); ProcessReceivedPacket(std::move(received_packet_with_invalid_ack), client_addr_, version_, conn_id); EXPECT_TRUE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); @@ -2981,7 +2945,7 @@ // New arrived CHLO will be dropped because this connection is in time wait // list. ASSERT_TRUE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); - EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, conn_id, _, _, _)); + EXPECT_CALL(*time_wait_list_manager_, ProcessPacket(_, _, conn_id, _, _)); expect_generator_is_called_ = false; ProcessFirstFlight(conn_id); }
diff --git a/quiche/quic/core/quic_packets.h b/quiche/quic/core/quic_packets.h index df121b1..a73184e 100644 --- a/quiche/quic/core/quic_packets.h +++ b/quiche/quic/core/quic_packets.h
@@ -451,11 +451,6 @@ QUICHE_EXPORT char* CopyBuffer(const char* encrypted_buffer, QuicPacketLength encrypted_length); -// Context for an incoming packet. -struct QUICHE_EXPORT QuicPerPacketContext { - virtual ~QuicPerPacketContext() {} -}; - // ReceivedPacketInfo comprises information obtained by parsing the unencrypted // bytes of a received packet. struct QUICHE_EXPORT ReceivedPacketInfo {
diff --git a/quiche/quic/core/quic_time_wait_list_manager.cc b/quiche/quic/core/quic_time_wait_list_manager.cc index 45be2df..872a7ae 100644 --- a/quiche/quic/core/quic_time_wait_list_manager.cc +++ b/quiche/quic/core/quic_time_wait_list_manager.cc
@@ -150,8 +150,7 @@ void QuicTimeWaitListManager::ProcessPacket( const QuicSocketAddress& self_address, const QuicSocketAddress& peer_address, QuicConnectionId connection_id, - PacketHeaderFormat header_format, size_t received_packet_length, - std::unique_ptr<QuicPerPacketContext> packet_context) { + PacketHeaderFormat header_format, size_t received_packet_length) { QUICHE_DCHECK(IsConnectionIdInTimeWait(connection_id)); // TODO(satyamshekhar): Think about handling packets from different peer // addresses. @@ -203,7 +202,7 @@ // Send stateless reset in response to short header packets. SendPublicReset(self_address, peer_address, connection_id, connection_data->info.ietf_quic, - received_packet_length, std::move(packet_context)); + received_packet_length); return; case GOOGLE_QUIC_Q043_PACKET: if (connection_data->info.ietf_quic) { @@ -214,8 +213,7 @@ for (const auto& packet : connection_data->info.termination_packets) { SendOrQueuePacket(std::make_unique<QueuedPacket>( - self_address, peer_address, packet->Clone()), - packet_context.get()); + self_address, peer_address, packet->Clone())); } return; @@ -226,8 +224,7 @@ } for (const auto& packet : connection_data->info.termination_packets) { SendOrQueuePacket(std::make_unique<QueuedPacket>( - self_address, peer_address, packet->Clone()), - packet_context.get()); + self_address, peer_address, packet->Clone())); } return; @@ -236,8 +233,7 @@ QUIC_CODE_COUNT(quic_stateless_reset_long_header_packet); } SendPublicReset(self_address, peer_address, connection_id, - connection_data->info.ietf_quic, received_packet_length, - std::move(packet_context)); + connection_data->info.ietf_quic, received_packet_length); return; case DO_NOTHING: QUIC_CODE_COUNT(quic_time_wait_list_do_nothing); @@ -250,8 +246,7 @@ QuicConnectionId client_connection_id, bool ietf_quic, bool use_length_prefix, const ParsedQuicVersionVector& supported_versions, const QuicSocketAddress& self_address, - const QuicSocketAddress& peer_address, - std::unique_ptr<QuicPerPacketContext> packet_context) { + const QuicSocketAddress& peer_address) { std::unique_ptr<QuicEncryptedPacket> version_packet = QuicFramer::BuildVersionNegotiationPacket( server_connection_id, client_connection_id, ietf_quic, @@ -264,8 +259,7 @@ << quiche::QuicheTextUtils::HexDump(absl::string_view( version_packet->data(), version_packet->length())); SendOrQueuePacket(std::make_unique<QueuedPacket>(self_address, peer_address, - std::move(version_packet)), - packet_context.get()); + std::move(version_packet))); } // Returns true if the number of packets received for this connection_id is a @@ -277,8 +271,7 @@ void QuicTimeWaitListManager::SendPublicReset( const QuicSocketAddress& self_address, const QuicSocketAddress& peer_address, QuicConnectionId connection_id, - bool ietf_quic, size_t received_packet_length, - std::unique_ptr<QuicPerPacketContext> packet_context) { + bool ietf_quic, size_t received_packet_length) { if (ietf_quic) { std::unique_ptr<QuicEncryptedPacket> ietf_reset_packet = BuildIetfStatelessResetPacket(connection_id, received_packet_length); @@ -293,10 +286,8 @@ << quiche::QuicheTextUtils::HexDump( absl::string_view(ietf_reset_packet->data(), ietf_reset_packet->length())); - SendOrQueuePacket( - std::make_unique<QueuedPacket>(self_address, peer_address, - std::move(ietf_reset_packet)), - packet_context.get()); + SendOrQueuePacket(std::make_unique<QueuedPacket>( + self_address, peer_address, std::move(ietf_reset_packet))); return; } // Google QUIC public resets donot elicit resets in response. @@ -304,7 +295,6 @@ packet.connection_id = connection_id; // TODO(satyamshekhar): generate a valid nonce for this connection_id. packet.nonce_proof = 1010101; - // TODO(wub): This is wrong for proxied sessions. Fix it. packet.client_address = peer_address; GetEndpointId(&packet.endpoint_id); // Takes ownership of the packet. @@ -314,16 +304,14 @@ << quiche::QuicheTextUtils::HexDump(absl::string_view( reset_packet->data(), reset_packet->length())); SendOrQueuePacket(std::make_unique<QueuedPacket>(self_address, peer_address, - std::move(reset_packet)), - packet_context.get()); + std::move(reset_packet))); } void QuicTimeWaitListManager::SendPacket(const QuicSocketAddress& self_address, const QuicSocketAddress& peer_address, const QuicEncryptedPacket& packet) { SendOrQueuePacket(std::make_unique<QueuedPacket>(self_address, peer_address, - packet.Clone()), - nullptr); + packet.Clone())); } std::unique_ptr<QuicEncryptedPacket> QuicTimeWaitListManager::BuildPublicReset( @@ -342,8 +330,7 @@ // Either sends the packet and deletes it or makes pending queue the // owner of the packet. bool QuicTimeWaitListManager::SendOrQueuePacket( - std::unique_ptr<QueuedPacket> packet, - const QuicPerPacketContext* /*packet_context*/) { + std::unique_ptr<QueuedPacket> packet) { if (packet == nullptr) { QUIC_LOG(ERROR) << "Tried to send or queue a null packet"; return true;
diff --git a/quiche/quic/core/quic_time_wait_list_manager.h b/quiche/quic/core/quic_time_wait_list_manager.h index 2e19a55..3592e14 100644 --- a/quiche/quic/core/quic_time_wait_list_manager.h +++ b/quiche/quic/core/quic_time_wait_list_manager.h
@@ -131,11 +131,11 @@ // wait state. virtual to override in tests. // TODO(fayang): change ProcessPacket and SendPublicReset to take // ReceivedPacketInfo. - virtual void ProcessPacket( - const QuicSocketAddress& self_address, - const QuicSocketAddress& peer_address, QuicConnectionId connection_id, - PacketHeaderFormat header_format, size_t received_packet_length, - std::unique_ptr<QuicPerPacketContext> packet_context); + virtual void ProcessPacket(const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + QuicConnectionId connection_id, + PacketHeaderFormat header_format, + size_t received_packet_length); // Called by the dispatcher when the underlying socket becomes writable again, // since we might need to send pending public reset packets which we didn't @@ -165,15 +165,13 @@ QuicConnectionId client_connection_id, bool ietf_quic, bool use_length_prefix, const ParsedQuicVersionVector& supported_versions, const QuicSocketAddress& self_address, - const QuicSocketAddress& peer_address, - std::unique_ptr<QuicPerPacketContext> packet_context); + const QuicSocketAddress& peer_address); // Creates a public reset packet and sends it or queues it to be sent later. - virtual void SendPublicReset( - const QuicSocketAddress& self_address, - const QuicSocketAddress& peer_address, QuicConnectionId connection_id, - bool ietf_quic, size_t received_packet_length, - std::unique_ptr<QuicPerPacketContext> packet_context); + virtual void SendPublicReset(const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + QuicConnectionId connection_id, bool ietf_quic, + size_t received_packet_length); // Called to send |packet|. virtual void SendPacket(const QuicSocketAddress& self_address, @@ -225,8 +223,7 @@ // Subclasses overriding this method should call this class's base // implementation at the end of the override. // Return true if |packet| is sent, false if it is queued. - virtual bool SendOrQueuePacket(std::unique_ptr<QueuedPacket> packet, - const QuicPerPacketContext* packet_context); + virtual bool SendOrQueuePacket(std::unique_ptr<QueuedPacket> packet); const quiche::QuicheCircularDeque<std::unique_ptr<QueuedPacket>>& pending_packets_queue() const {
diff --git a/quiche/quic/core/quic_time_wait_list_manager_test.cc b/quiche/quic/core/quic_time_wait_list_manager_test.cc index e3abd0d..c20f1b2 100644 --- a/quiche/quic/core/quic_time_wait_list_manager_test.cc +++ b/quiche/quic/core/quic_time_wait_list_manager_test.cc
@@ -158,7 +158,7 @@ void ProcessPacket(QuicConnectionId connection_id) { time_wait_list_manager_.ProcessPacket( self_address_, peer_address_, connection_id, GOOGLE_QUIC_Q043_PACKET, - kTestPacketSize, std::make_unique<QuicPerPacketContext>()); + kTestPacketSize); } QuicEncryptedPacket* ConstructEncryptedPacket( @@ -235,7 +235,7 @@ time_wait_list_manager_.SendVersionNegotiationPacket( connection_id_, EmptyQuicConnectionId(), /*ietf_quic=*/false, /*use_length_prefix=*/false, AllSupportedVersions(), self_address_, - peer_address_, std::make_unique<QuicPerPacketContext>()); + peer_address_); EXPECT_EQ(0u, time_wait_list_manager_.num_connections()); } @@ -252,7 +252,7 @@ time_wait_list_manager_.SendVersionNegotiationPacket( connection_id_, EmptyQuicConnectionId(), /*ietf_quic=*/true, /*use_length_prefix=*/false, AllSupportedVersions(), self_address_, - peer_address_, std::make_unique<QuicPerPacketContext>()); + peer_address_); EXPECT_EQ(0u, time_wait_list_manager_.num_connections()); } @@ -268,7 +268,7 @@ time_wait_list_manager_.SendVersionNegotiationPacket( connection_id_, EmptyQuicConnectionId(), /*ietf_quic=*/true, /*use_length_prefix=*/true, AllSupportedVersions(), self_address_, - peer_address_, std::make_unique<QuicPerPacketContext>()); + peer_address_); EXPECT_EQ(0u, time_wait_list_manager_.num_connections()); } @@ -285,7 +285,7 @@ time_wait_list_manager_.SendVersionNegotiationPacket( connection_id_, TestConnectionId(0x33), /*ietf_quic=*/true, /*use_length_prefix=*/true, AllSupportedVersions(), self_address_, - peer_address_, std::make_unique<QuicPerPacketContext>()); + peer_address_); EXPECT_EQ(0u, time_wait_list_manager_.num_connections()); } @@ -649,8 +649,7 @@ // Processes IETF short header packet. time_wait_list_manager_.ProcessPacket( self_address_, peer_address_, connection_id_, - IETF_QUIC_SHORT_HEADER_PACKET, kTestPacketSize, - std::make_unique<QuicPerPacketContext>()); + IETF_QUIC_SHORT_HEADER_PACKET, kTestPacketSize); } TEST_F(QuicTimeWaitListManagerTest, @@ -672,8 +671,7 @@ // Processes IETF short header packet. time_wait_list_manager_.ProcessPacket( self_address_, peer_address_, connection_id_, - IETF_QUIC_SHORT_HEADER_PACKET, kTestPacketSize, - std::make_unique<QuicPerPacketContext>()); + IETF_QUIC_SHORT_HEADER_PACKET, kTestPacketSize); } TEST_F(QuicTimeWaitListManagerTest, @@ -699,9 +697,9 @@ .WillRepeatedly(Return(WriteResult(WRITE_STATUS_OK, 1))); // Processes IETF short header packet. for (auto const& cid : active_connection_ids) { - time_wait_list_manager_.ProcessPacket( - self_address_, peer_address_, cid, IETF_QUIC_SHORT_HEADER_PACKET, - kTestPacketSize, std::make_unique<QuicPerPacketContext>()); + time_wait_list_manager_.ProcessPacket(self_address_, peer_address_, cid, + IETF_QUIC_SHORT_HEADER_PACKET, + kTestPacketSize); } } @@ -714,13 +712,12 @@ self_address_, peer_address_, TestConnectionId(1), /*ietf_quic=*/true, /*received_packet_length=*/ - QuicFramer::GetMinStatelessResetPacketLength() - 1, - /*packet_context=*/nullptr); + QuicFramer::GetMinStatelessResetPacketLength() - 1); } TEST_F(QuicTimeWaitListManagerTest, SendOrQueueNullPacket) { QuicTimeWaitListManagerPeer::SendOrQueuePacket(&time_wait_list_manager_, - nullptr, nullptr); + nullptr); } TEST_F(QuicTimeWaitListManagerTest, TooManyPendingPackets) { @@ -739,8 +736,7 @@ self_address_, peer_address_, TestConnectionId(1), /*ietf_quic=*/true, /*received_packet_length=*/ - QuicFramer::GetMinStatelessResetPacketLength() + 1, - /*packet_context=*/nullptr); + QuicFramer::GetMinStatelessResetPacketLength() + 1); } // Verify pending packet queue size is limited. EXPECT_EQ(5u, QuicTimeWaitListManagerPeer::PendingPacketsQueueSize(
diff --git a/quiche/quic/test_tools/mock_quic_time_wait_list_manager.h b/quiche/quic/test_tools/mock_quic_time_wait_list_manager.h index 5218f2f..da9a650 100644 --- a/quiche/quic/test_tools/mock_quic_time_wait_list_manager.h +++ b/quiche/quic/test_tools/mock_quic_time_wait_list_manager.h
@@ -31,8 +31,7 @@ MOCK_METHOD(void, ProcessPacket, (const QuicSocketAddress&, const QuicSocketAddress&, - QuicConnectionId, PacketHeaderFormat, size_t, - std::unique_ptr<QuicPerPacketContext>), + QuicConnectionId, PacketHeaderFormat, size_t), (override)); MOCK_METHOD(void, SendVersionNegotiationPacket, @@ -41,14 +40,12 @@ bool has_length_prefix, const ParsedQuicVersionVector& supported_versions, const QuicSocketAddress& server_address, - const QuicSocketAddress& client_address, - std::unique_ptr<QuicPerPacketContext> packet_context), + const QuicSocketAddress& client_address), (override)); MOCK_METHOD(void, SendPublicReset, (const QuicSocketAddress&, const QuicSocketAddress&, - QuicConnectionId, bool, size_t, - std::unique_ptr<QuicPerPacketContext>), + QuicConnectionId, bool, size_t), (override)); MOCK_METHOD(void, SendPacket,
diff --git a/quiche/quic/test_tools/quic_dispatcher_peer.cc b/quiche/quic/test_tools/quic_dispatcher_peer.cc index d4d7c07..12e3f01 100644 --- a/quiche/quic/test_tools/quic_dispatcher_peer.cc +++ b/quiche/quic/test_tools/quic_dispatcher_peer.cc
@@ -85,26 +85,15 @@ } // static -void QuicDispatcherPeer::SendPublicReset( - QuicDispatcher* dispatcher, const QuicSocketAddress& self_address, - const QuicSocketAddress& peer_address, QuicConnectionId connection_id, - bool ietf_quic, size_t received_packet_length, - std::unique_ptr<QuicPerPacketContext> packet_context) { +void QuicDispatcherPeer::SendPublicReset(QuicDispatcher* dispatcher, + const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + QuicConnectionId connection_id, + bool ietf_quic, + size_t received_packet_length) { dispatcher->time_wait_list_manager()->SendPublicReset( self_address, peer_address, connection_id, ietf_quic, - received_packet_length, std::move(packet_context)); -} - -// static -std::unique_ptr<QuicPerPacketContext> QuicDispatcherPeer::GetPerPacketContext( - QuicDispatcher* dispatcher) { - return dispatcher->GetPerPacketContext(); -} - -// static -void QuicDispatcherPeer::RestorePerPacketContext( - QuicDispatcher* dispatcher, std::unique_ptr<QuicPerPacketContext> context) { - dispatcher->RestorePerPacketContext(std::move(context)); + received_packet_length); } // static
diff --git a/quiche/quic/test_tools/quic_dispatcher_peer.h b/quiche/quic/test_tools/quic_dispatcher_peer.h index 985dc67..8d23b5b 100644 --- a/quiche/quic/test_tools/quic_dispatcher_peer.h +++ b/quiche/quic/test_tools/quic_dispatcher_peer.h
@@ -49,17 +49,11 @@ static void set_new_sessions_allowed_per_event_loop( QuicDispatcher* dispatcher, size_t num_session_allowed); - static void SendPublicReset( - QuicDispatcher* dispatcher, const QuicSocketAddress& self_address, - const QuicSocketAddress& peer_address, QuicConnectionId connection_id, - bool ietf_quic, size_t received_packet_length, - std::unique_ptr<QuicPerPacketContext> packet_context); - - static std::unique_ptr<QuicPerPacketContext> GetPerPacketContext( - QuicDispatcher* dispatcher); - - static void RestorePerPacketContext(QuicDispatcher* dispatcher, - std::unique_ptr<QuicPerPacketContext>); + static void SendPublicReset(QuicDispatcher* dispatcher, + const QuicSocketAddress& self_address, + const QuicSocketAddress& peer_address, + QuicConnectionId connection_id, bool ietf_quic, + size_t received_packet_length); static std::string SelectAlpn(QuicDispatcher* dispatcher, const std::vector<std::string>& alpns);
diff --git a/quiche/quic/test_tools/quic_time_wait_list_manager_peer.cc b/quiche/quic/test_tools/quic_time_wait_list_manager_peer.cc index 9c39add..b7f0cfc 100644 --- a/quiche/quic/test_tools/quic_time_wait_list_manager_peer.cc +++ b/quiche/quic/test_tools/quic_time_wait_list_manager_peer.cc
@@ -33,9 +33,8 @@ // static bool QuicTimeWaitListManagerPeer::SendOrQueuePacket( QuicTimeWaitListManager* manager, - std::unique_ptr<QuicTimeWaitListManager::QueuedPacket> packet, - const QuicPerPacketContext* packet_context) { - return manager->SendOrQueuePacket(std::move(packet), packet_context); + std::unique_ptr<QuicTimeWaitListManager::QueuedPacket> packet) { + return manager->SendOrQueuePacket(std::move(packet)); } // static
diff --git a/quiche/quic/test_tools/quic_time_wait_list_manager_peer.h b/quiche/quic/test_tools/quic_time_wait_list_manager_peer.h index a7aed47..ca1b663 100644 --- a/quiche/quic/test_tools/quic_time_wait_list_manager_peer.h +++ b/quiche/quic/test_tools/quic_time_wait_list_manager_peer.h
@@ -24,8 +24,7 @@ static bool SendOrQueuePacket( QuicTimeWaitListManager* manager, - std::unique_ptr<QuicTimeWaitListManager::QueuedPacket> packet, - const QuicPerPacketContext* packet_context); + std::unique_ptr<QuicTimeWaitListManager::QueuedPacket> packet); static size_t PendingPacketsQueueSize(QuicTimeWaitListManager* manager); };