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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 framer_.set_version(version); | 329 framer_.set_version(version); |
330 return true; | 330 return true; |
331 } | 331 } |
332 | 332 |
333 bool QuicDispatcher::OnUnauthenticatedHeader(const QuicPacketHeader& header) { | 333 bool QuicDispatcher::OnUnauthenticatedHeader(const QuicPacketHeader& header) { |
334 QuicConnectionId connection_id = header.public_header.connection_id; | 334 QuicConnectionId connection_id = header.public_header.connection_id; |
335 | 335 |
336 if (time_wait_list_manager_->IsConnectionIdInTimeWait( | 336 if (time_wait_list_manager_->IsConnectionIdInTimeWait( |
337 header.public_header.connection_id)) { | 337 header.public_header.connection_id)) { |
338 // This connection ID is already in time-wait state. | 338 // This connection ID is already in time-wait state. |
339 time_wait_list_manager_->ProcessPacket( | 339 time_wait_list_manager_->ProcessPacket(current_server_address_, |
340 current_server_address_, current_client_address_, | 340 current_client_address_, |
341 header.public_header.connection_id, *current_packet_); | 341 header.public_header.connection_id); |
342 return false; | 342 return false; |
343 } | 343 } |
344 | 344 |
345 // Packet's connection ID is unknown. Apply the validity checks. | 345 // Packet's connection ID is unknown. Apply the validity checks. |
346 QuicPacketFate fate = ValidityChecks(header); | 346 QuicPacketFate fate = ValidityChecks(header); |
347 if (fate == kFateProcess) { | 347 if (fate == kFateProcess) { |
348 // Execute stateless rejection logic to determine the packet fate, then | 348 // Execute stateless rejection logic to determine the packet fate, then |
349 // invoke ProcessUnauthenticatedHeaderFate. | 349 // invoke ProcessUnauthenticatedHeaderFate. |
350 MaybeRejectStatelessly(connection_id, | 350 MaybeRejectStatelessly(connection_id, |
351 header.public_header.versions.front()); | 351 header.public_header.versions.front()); |
(...skipping 21 matching lines...) Expand all Loading... |
373 !time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) { | 373 !time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) { |
374 // Add this connection_id to the time-wait state, to safely reject | 374 // Add this connection_id to the time-wait state, to safely reject |
375 // future packets. | 375 // future packets. |
376 QUIC_DLOG(INFO) << "Adding connection ID " << connection_id | 376 QUIC_DLOG(INFO) << "Adding connection ID " << connection_id |
377 << "to time-wait list."; | 377 << "to time-wait list."; |
378 time_wait_list_manager_->AddConnectionIdToTimeWait( | 378 time_wait_list_manager_->AddConnectionIdToTimeWait( |
379 connection_id, framer_.version(), | 379 connection_id, framer_.version(), |
380 /*connection_rejected_statelessly=*/false, nullptr); | 380 /*connection_rejected_statelessly=*/false, nullptr); |
381 } | 381 } |
382 DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); | 382 DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); |
383 time_wait_list_manager_->ProcessPacket(current_server_address_, | 383 time_wait_list_manager_->ProcessPacket( |
384 current_client_address_, | 384 current_server_address_, current_client_address_, connection_id); |
385 connection_id, *current_packet_); | |
386 | 385 |
387 // Any packets which were buffered while the stateless rejector logic was | 386 // Any packets which were buffered while the stateless rejector logic was |
388 // running should be discarded. Do not inform the time wait list manager, | 387 // running should be discarded. Do not inform the time wait list manager, |
389 // which should already have a made a decision about sending a reject | 388 // which should already have a made a decision about sending a reject |
390 // based on the CHLO alone. | 389 // based on the CHLO alone. |
391 buffered_packets_.DiscardPackets(connection_id); | 390 buffered_packets_.DiscardPackets(connection_id); |
392 break; | 391 break; |
393 case kFateBuffer: | 392 case kFateBuffer: |
394 // This packet is a non-CHLO packet which has arrived before the | 393 // This packet is a non-CHLO packet which has arrived before the |
395 // corresponding CHLO, *or* this packet was received while the | 394 // corresponding CHLO, *or* this packet was received while the |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 } | 716 } |
718 | 717 |
719 void QuicDispatcher::ProcessChlo() { | 718 void QuicDispatcher::ProcessChlo() { |
720 if (!accept_new_connections_) { | 719 if (!accept_new_connections_) { |
721 // Don't any create new connection. | 720 // Don't any create new connection. |
722 time_wait_list_manager()->AddConnectionIdToTimeWait( | 721 time_wait_list_manager()->AddConnectionIdToTimeWait( |
723 current_connection_id(), framer()->version(), | 722 current_connection_id(), framer()->version(), |
724 /*connection_rejected_statelessly=*/false, | 723 /*connection_rejected_statelessly=*/false, |
725 /*termination_packets=*/nullptr); | 724 /*termination_packets=*/nullptr); |
726 // This will trigger sending Public Reset packet. | 725 // This will trigger sending Public Reset packet. |
727 time_wait_list_manager()->ProcessPacket( | 726 time_wait_list_manager()->ProcessPacket(current_server_address(), |
728 current_server_address(), current_client_address(), | 727 current_client_address(), |
729 current_connection_id(), current_packet()); | 728 current_connection_id()); |
730 return; | 729 return; |
731 } | 730 } |
732 if (FLAGS_quic_reloadable_flag_quic_create_session_after_insertion && | 731 if (FLAGS_quic_reloadable_flag_quic_create_session_after_insertion && |
733 !buffered_packets_.HasBufferedPackets(current_connection_id_) && | 732 !buffered_packets_.HasBufferedPackets(current_connection_id_) && |
734 !ShouldCreateOrBufferPacketForConnection(current_connection_id_)) { | 733 !ShouldCreateOrBufferPacketForConnection(current_connection_id_)) { |
735 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_create_session_after_insertion, | 734 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_create_session_after_insertion, |
736 2, 5); | 735 2, 5); |
737 return; | 736 return; |
738 } | 737 } |
739 if (FLAGS_quic_allow_chlo_buffering && | 738 if (FLAGS_quic_allow_chlo_buffering && |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 const auto num_erased = | 908 const auto num_erased = |
910 temporarily_buffered_connections_.erase(rejector->connection_id()); | 909 temporarily_buffered_connections_.erase(rejector->connection_id()); |
911 QUIC_BUG_IF(num_erased != 1) << "Completing stateless rejection logic for " | 910 QUIC_BUG_IF(num_erased != 1) << "Completing stateless rejection logic for " |
912 "non-buffered connection ID " | 911 "non-buffered connection ID " |
913 << rejector->connection_id(); | 912 << rejector->connection_id(); |
914 | 913 |
915 // 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, |
916 // don't proceed. | 915 // don't proceed. |
917 if (time_wait_list_manager_->IsConnectionIdInTimeWait( | 916 if (time_wait_list_manager_->IsConnectionIdInTimeWait( |
918 rejector->connection_id())) { | 917 rejector->connection_id())) { |
919 time_wait_list_manager_->ProcessPacket( | 918 time_wait_list_manager_->ProcessPacket(current_server_address, |
920 current_server_address, current_client_address, | 919 current_client_address, |
921 rejector->connection_id(), *current_packet); | 920 rejector->connection_id()); |
922 return; | 921 return; |
923 } | 922 } |
924 | 923 |
925 // Reset current_* to correspond to the packet which initiated the stateless | 924 // Reset current_* to correspond to the packet which initiated the stateless |
926 // reject logic. | 925 // reject logic. |
927 current_client_address_ = current_client_address; | 926 current_client_address_ = current_client_address; |
928 current_server_address_ = current_server_address; | 927 current_server_address_ = current_server_address; |
929 current_packet_ = current_packet.get(); | 928 current_packet_ = current_packet.get(); |
930 current_connection_id_ = rejector->connection_id(); | 929 current_connection_id_ = rejector->connection_id(); |
931 | 930 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 void QuicDispatcher::DeliverPacketsToSession( | 984 void QuicDispatcher::DeliverPacketsToSession( |
986 const std::list<BufferedPacket>& packets, | 985 const std::list<BufferedPacket>& packets, |
987 QuicSession* session) { | 986 QuicSession* session) { |
988 for (const BufferedPacket& packet : packets) { | 987 for (const BufferedPacket& packet : packets) { |
989 session->ProcessUdpPacket(packet.server_address, packet.client_address, | 988 session->ProcessUdpPacket(packet.server_address, packet.client_address, |
990 *(packet.packet)); | 989 *(packet.packet)); |
991 } | 990 } |
992 } | 991 } |
993 | 992 |
994 } // namespace net | 993 } // namespace net |
OLD | NEW |