| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/tools/quic/quic_dispatcher.h" | 5 #include "net/tools/quic/quic_dispatcher.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "net/quic/core/crypto/quic_random.h" | 10 #include "net/quic/core/crypto/quic_random.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 return false; | 269 return false; |
| 270 } | 270 } |
| 271 | 271 |
| 272 if (FLAGS_quic_reloadable_flag_quic_buffer_packets_after_chlo && | 272 if (FLAGS_quic_reloadable_flag_quic_buffer_packets_after_chlo && |
| 273 buffered_packets_.HasChloForConnection(connection_id)) { | 273 buffered_packets_.HasChloForConnection(connection_id)) { |
| 274 BufferEarlyPacket(connection_id); | 274 BufferEarlyPacket(connection_id); |
| 275 return false; | 275 return false; |
| 276 } | 276 } |
| 277 | 277 |
| 278 // Check if we are buffering packets for this connection ID | 278 // Check if we are buffering packets for this connection ID |
| 279 if (FLAGS_quic_reloadable_flag_enable_async_get_proof && | 279 if (temporarily_buffered_connections_.find(connection_id) != |
| 280 (temporarily_buffered_connections_.find(connection_id) != | 280 temporarily_buffered_connections_.end()) { |
| 281 temporarily_buffered_connections_.end())) { | |
| 282 // This packet was received while the a CHLO for the same connection ID was | 281 // This packet was received while the a CHLO for the same connection ID was |
| 283 // being processed. Buffer it. | 282 // being processed. Buffer it. |
| 284 BufferEarlyPacket(connection_id); | 283 BufferEarlyPacket(connection_id); |
| 285 return false; | 284 return false; |
| 286 } | 285 } |
| 287 | 286 |
| 288 if (!OnUnauthenticatedUnknownPublicHeader(header)) { | 287 if (!OnUnauthenticatedUnknownPublicHeader(header)) { |
| 289 return false; | 288 return false; |
| 290 } | 289 } |
| 291 | 290 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 << "to time-wait list."; | 378 << "to time-wait list."; |
| 380 time_wait_list_manager_->AddConnectionIdToTimeWait( | 379 time_wait_list_manager_->AddConnectionIdToTimeWait( |
| 381 connection_id, framer_.version(), | 380 connection_id, framer_.version(), |
| 382 /*connection_rejected_statelessly=*/false, nullptr); | 381 /*connection_rejected_statelessly=*/false, nullptr); |
| 383 } | 382 } |
| 384 DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); | 383 DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); |
| 385 time_wait_list_manager_->ProcessPacket( | 384 time_wait_list_manager_->ProcessPacket( |
| 386 current_server_address_, current_client_address_, connection_id, | 385 current_server_address_, current_client_address_, connection_id, |
| 387 packet_number, *current_packet_); | 386 packet_number, *current_packet_); |
| 388 | 387 |
| 389 if (FLAGS_quic_reloadable_flag_enable_async_get_proof) { | 388 // Any packets which were buffered while the stateless rejector logic was |
| 390 // Any packets which were buffered while the stateless rejector logic | 389 // running should be discarded. Do not inform the time wait list manager, |
| 391 // was running should be discarded. Do not inform the time wait list | 390 // which should already have a made a decision about sending a reject |
| 392 // manager, which should already have a made a decision about sending a | 391 // based on the CHLO alone. |
| 393 // reject based on the CHLO alone. | 392 buffered_packets_.DiscardPackets(connection_id); |
| 394 buffered_packets_.DiscardPackets(connection_id); | |
| 395 } | |
| 396 | |
| 397 break; | 393 break; |
| 398 case kFateBuffer: | 394 case kFateBuffer: |
| 399 // This packet is a non-CHLO packet which has arrived before the | 395 // This packet is a non-CHLO packet which has arrived before the |
| 400 // corresponding CHLO, *or* this packet was received while the | 396 // corresponding CHLO, *or* this packet was received while the |
| 401 // corresponding CHLO was being processed. Buffer it. | 397 // corresponding CHLO was being processed. Buffer it. |
| 402 BufferEarlyPacket(connection_id); | 398 BufferEarlyPacket(connection_id); |
| 403 break; | 399 break; |
| 404 case kFateDrop: | 400 case kFateDrop: |
| 405 // Do nothing with the packet. | 401 // Do nothing with the packet. |
| 406 break; | 402 break; |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 | 877 |
| 882 // If we were able to make a decision about this CHLO based purely on the | 878 // If we were able to make a decision about this CHLO based purely on the |
| 883 // information available in OnChlo, just invoke the done callback immediately. | 879 // information available in OnChlo, just invoke the done callback immediately. |
| 884 if (rejector->state() != StatelessRejector::UNKNOWN) { | 880 if (rejector->state() != StatelessRejector::UNKNOWN) { |
| 885 ProcessStatelessRejectorState(std::move(rejector), header.packet_number, | 881 ProcessStatelessRejectorState(std::move(rejector), header.packet_number, |
| 886 header.public_header.versions.front()); | 882 header.public_header.versions.front()); |
| 887 return; | 883 return; |
| 888 } | 884 } |
| 889 | 885 |
| 890 // Insert into set of connection IDs to buffer | 886 // Insert into set of connection IDs to buffer |
| 891 if (FLAGS_quic_reloadable_flag_enable_async_get_proof) { | 887 const bool ok = |
| 892 const bool ok = | 888 temporarily_buffered_connections_.insert(connection_id).second; |
| 893 temporarily_buffered_connections_.insert(connection_id).second; | 889 QUIC_BUG_IF(!ok) |
| 894 QUIC_BUG_IF(!ok) | 890 << "Processing multiple stateless rejections for connection ID " |
| 895 << "Processing multiple stateless rejections for connection ID " | 891 << connection_id; |
| 896 << connection_id; | |
| 897 } | |
| 898 | 892 |
| 899 // Continue stateless rejector processing | 893 // Continue stateless rejector processing |
| 900 std::unique_ptr<StatelessRejectorProcessDoneCallback> cb( | 894 std::unique_ptr<StatelessRejectorProcessDoneCallback> cb( |
| 901 new StatelessRejectorProcessDoneCallback( | 895 new StatelessRejectorProcessDoneCallback( |
| 902 this, header.packet_number, header.public_header.versions.front())); | 896 this, header.packet_number, header.public_header.versions.front())); |
| 903 StatelessRejector::Process(std::move(rejector), std::move(cb)); | 897 StatelessRejector::Process(std::move(rejector), std::move(cb)); |
| 904 } | 898 } |
| 905 | 899 |
| 906 void QuicDispatcher::OnStatelessRejectorProcessDone( | 900 void QuicDispatcher::OnStatelessRejectorProcessDone( |
| 907 std::unique_ptr<StatelessRejector> rejector, | 901 std::unique_ptr<StatelessRejector> rejector, |
| 908 const QuicSocketAddress& current_client_address, | 902 const QuicSocketAddress& current_client_address, |
| 909 const QuicSocketAddress& current_server_address, | 903 const QuicSocketAddress& current_server_address, |
| 910 std::unique_ptr<QuicReceivedPacket> current_packet, | 904 std::unique_ptr<QuicReceivedPacket> current_packet, |
| 911 QuicPacketNumber packet_number, | 905 QuicPacketNumber packet_number, |
| 912 QuicVersion first_version) { | 906 QuicVersion first_version) { |
| 913 if (FLAGS_quic_reloadable_flag_enable_async_get_proof) { | 907 // Stop buffering packets on this connection |
| 914 // Stop buffering packets on this connection | 908 const auto num_erased = |
| 915 const auto num_erased = | 909 temporarily_buffered_connections_.erase(rejector->connection_id()); |
| 916 temporarily_buffered_connections_.erase(rejector->connection_id()); | 910 QUIC_BUG_IF(num_erased != 1) << "Completing stateless rejection logic for " |
| 917 QUIC_BUG_IF(num_erased != 1) << "Completing stateless rejection logic for " | 911 "non-buffered connection ID " |
| 918 "non-buffered connection ID " | 912 << rejector->connection_id(); |
| 919 << rejector->connection_id(); | |
| 920 | 913 |
| 921 // If this connection has gone into time-wait during the async processing, | 914 // If this connection has gone into time-wait during the async processing, |
| 922 // don't proceed. | 915 // don't proceed. |
| 923 if (time_wait_list_manager_->IsConnectionIdInTimeWait( | 916 if (time_wait_list_manager_->IsConnectionIdInTimeWait( |
| 924 rejector->connection_id())) { | 917 rejector->connection_id())) { |
| 925 time_wait_list_manager_->ProcessPacket( | 918 time_wait_list_manager_->ProcessPacket( |
| 926 current_server_address, current_client_address, | 919 current_server_address, current_client_address, |
| 927 rejector->connection_id(), packet_number, *current_packet); | 920 rejector->connection_id(), packet_number, *current_packet); |
| 928 return; | 921 return; |
| 929 } | |
| 930 } | 922 } |
| 931 | 923 |
| 932 // Reset current_* to correspond to the packet which initiated the stateless | 924 // Reset current_* to correspond to the packet which initiated the stateless |
| 933 // reject logic. | 925 // reject logic. |
| 934 current_client_address_ = current_client_address; | 926 current_client_address_ = current_client_address; |
| 935 current_server_address_ = current_server_address; | 927 current_server_address_ = current_server_address; |
| 936 current_packet_ = current_packet.get(); | 928 current_packet_ = current_packet.get(); |
| 937 current_connection_id_ = rejector->connection_id(); | 929 current_connection_id_ = rejector->connection_id(); |
| 938 | 930 |
| 939 ProcessStatelessRejectorState(std::move(rejector), packet_number, | 931 ProcessStatelessRejectorState(std::move(rejector), packet_number, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 void QuicDispatcher::DeliverPacketsToSession( | 986 void QuicDispatcher::DeliverPacketsToSession( |
| 995 const std::list<BufferedPacket>& packets, | 987 const std::list<BufferedPacket>& packets, |
| 996 QuicSession* session) { | 988 QuicSession* session) { |
| 997 for (const BufferedPacket& packet : packets) { | 989 for (const BufferedPacket& packet : packets) { |
| 998 session->ProcessUdpPacket(packet.server_address, packet.client_address, | 990 session->ProcessUdpPacket(packet.server_address, packet.client_address, |
| 999 *(packet.packet)); | 991 *(packet.packet)); |
| 1000 } | 992 } |
| 1001 } | 993 } |
| 1002 | 994 |
| 1003 } // namespace net | 995 } // namespace net |
| OLD | NEW |