Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: net/tools/quic/quic_dispatcher.cc

Issue 2611613003: Add quic_logging (Closed)
Patch Set: fix for win Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/debug/stack_trace.h" 9 #include "base/debug/stack_trace.h"
10 #include "base/logging.h"
11 #include "base/macros.h" 10 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
13 #include "net/quic/core/crypto/quic_random.h" 12 #include "net/quic/core/crypto/quic_random.h"
14 #include "net/quic/core/quic_bug_tracker.h" 13 #include "net/quic/core/quic_bug_tracker.h"
15 #include "net/quic/core/quic_flags.h" 14 #include "net/quic/core/quic_flags.h"
16 #include "net/quic/core/quic_utils.h" 15 #include "net/quic/core/quic_utils.h"
17 16 #include "net/quic/platform/api/quic_logging.h"
18 #include "net/tools/quic/chlo_extractor.h" 17 #include "net/tools/quic/chlo_extractor.h"
19 #include "net/tools/quic/quic_per_connection_packet_writer.h" 18 #include "net/tools/quic/quic_per_connection_packet_writer.h"
20 #include "net/tools/quic/quic_simple_server_session.h" 19 #include "net/tools/quic/quic_simple_server_session.h"
21 #include "net/tools/quic/quic_simple_server_session.h" 20 #include "net/tools/quic/quic_simple_server_session.h"
22 #include "net/tools/quic/quic_time_wait_list_manager.h" 21 #include "net/tools/quic/quic_time_wait_list_manager.h"
23 #include "net/tools/quic/stateless_rejector.h" 22 #include "net/tools/quic/stateless_rejector.h"
24 23
25 using base::StringPiece; 24 using base::StringPiece;
26 using std::string; 25 using std::string;
27 26
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 ProcessChlo(); 369 ProcessChlo();
371 break; 370 break;
372 } 371 }
373 case kFateTimeWait: 372 case kFateTimeWait:
374 // MaybeRejectStatelessly or OnExpiredPackets might have already added the 373 // MaybeRejectStatelessly or OnExpiredPackets might have already added the
375 // connection to time wait, in which case it should not be added again. 374 // connection to time wait, in which case it should not be added again.
376 if (!FLAGS_quic_reloadable_flag_quic_use_cheap_stateless_rejects || 375 if (!FLAGS_quic_reloadable_flag_quic_use_cheap_stateless_rejects ||
377 !time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) { 376 !time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) {
378 // Add this connection_id to the time-wait state, to safely reject 377 // Add this connection_id to the time-wait state, to safely reject
379 // future packets. 378 // future packets.
380 DVLOG(1) << "Adding connection ID " << connection_id 379 QUIC_DLOG(INFO) << "Adding connection ID " << connection_id
381 << "to time-wait list."; 380 << "to time-wait list.";
382 time_wait_list_manager_->AddConnectionIdToTimeWait( 381 time_wait_list_manager_->AddConnectionIdToTimeWait(
383 connection_id, framer_.version(), 382 connection_id, framer_.version(),
384 /*connection_rejected_statelessly=*/false, nullptr); 383 /*connection_rejected_statelessly=*/false, nullptr);
385 } 384 }
386 DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); 385 DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id));
387 time_wait_list_manager_->ProcessPacket( 386 time_wait_list_manager_->ProcessPacket(
388 current_server_address_, current_client_address_, connection_id, 387 current_server_address_, current_client_address_, connection_id,
389 packet_number, *current_packet_); 388 packet_number, *current_packet_);
390 389
391 if (FLAGS_quic_reloadable_flag_enable_async_get_proof) { 390 if (FLAGS_quic_reloadable_flag_enable_async_get_proof) {
(...skipping 26 matching lines...) Expand all
418 417
419 // Checks that return kFateDrop. 418 // Checks that return kFateDrop.
420 419
421 // Checks that return kFateTimeWait. 420 // Checks that return kFateTimeWait.
422 421
423 // All packets within a connection sent by a client before receiving a 422 // All packets within a connection sent by a client before receiving a
424 // response from the server are required to have the version negotiation flag 423 // response from the server are required to have the version negotiation flag
425 // set. Since this may be a client continuing a connection we lost track of 424 // set. Since this may be a client continuing a connection we lost track of
426 // via server restart, send a rejection to fast-fail the connection. 425 // via server restart, send a rejection to fast-fail the connection.
427 if (!header.public_header.version_flag) { 426 if (!header.public_header.version_flag) {
428 DVLOG(1) << "Packet without version arrived for unknown connection ID " 427 QUIC_DLOG(INFO)
429 << header.public_header.connection_id; 428 << "Packet without version arrived for unknown connection ID "
429 << header.public_header.connection_id;
430 return kFateTimeWait; 430 return kFateTimeWait;
431 } 431 }
432 432
433 // Check that the sequence number is within the range that the client is 433 // Check that the sequence number is within the range that the client is
434 // expected to send before receiving a response from the server. 434 // expected to send before receiving a response from the server.
435 const int kInvalidPacketNumber = 0; 435 const int kInvalidPacketNumber = 0;
436 if (header.packet_number == kInvalidPacketNumber || 436 if (header.packet_number == kInvalidPacketNumber ||
437 header.packet_number > kMaxReasonableInitialPacketNumber) { 437 header.packet_number > kMaxReasonableInitialPacketNumber) {
438 return kFateTimeWait; 438 return kFateTimeWait;
439 } 439 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 "not blocked."; 525 "not blocked.";
526 // Return without adding the connection to the blocked list, to avoid 526 // Return without adding the connection to the blocked list, to avoid
527 // infinite loops in OnCanWrite. 527 // infinite loops in OnCanWrite.
528 return; 528 return;
529 } 529 }
530 write_blocked_list_.insert(std::make_pair(blocked_writer, true)); 530 write_blocked_list_.insert(std::make_pair(blocked_writer, true));
531 } 531 }
532 532
533 void QuicDispatcher::OnConnectionAddedToTimeWaitList( 533 void QuicDispatcher::OnConnectionAddedToTimeWaitList(
534 QuicConnectionId connection_id) { 534 QuicConnectionId connection_id) {
535 DVLOG(1) << "Connection " << connection_id << " added to time wait list."; 535 QUIC_DLOG(INFO) << "Connection " << connection_id
536 << " added to time wait list.";
536 } 537 }
537 538
538 void QuicDispatcher::OnPacket() {} 539 void QuicDispatcher::OnPacket() {}
539 540
540 void QuicDispatcher::OnError(QuicFramer* framer) { 541 void QuicDispatcher::OnError(QuicFramer* framer) {
541 QuicErrorCode error = framer->error(); 542 QuicErrorCode error = framer->error();
542 SetLastError(error); 543 SetLastError(error);
543 DVLOG(1) << QuicErrorCodeToString(error); 544 QUIC_DLOG(INFO) << QuicErrorCodeToString(error);
544 } 545 }
545 546
546 bool QuicDispatcher::ShouldCreateSessionForUnknownVersion(QuicTag version_tag) { 547 bool QuicDispatcher::ShouldCreateSessionForUnknownVersion(QuicTag version_tag) {
547 return false; 548 return false;
548 } 549 }
549 550
550 bool QuicDispatcher::OnProtocolVersionMismatch( 551 bool QuicDispatcher::OnProtocolVersionMismatch(
551 QuicVersion /*received_version*/) { 552 QuicVersion /*received_version*/) {
552 QUIC_BUG_IF(!time_wait_list_manager_->IsConnectionIdInTimeWait( 553 QUIC_BUG_IF(!time_wait_list_manager_->IsConnectionIdInTimeWait(
553 current_connection_id_) && 554 current_connection_id_) &&
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 for (; new_sessions_allowed_per_event_loop_ > 0; 654 for (; new_sessions_allowed_per_event_loop_ > 0;
654 --new_sessions_allowed_per_event_loop_) { 655 --new_sessions_allowed_per_event_loop_) {
655 QuicConnectionId connection_id; 656 QuicConnectionId connection_id;
656 std::list<BufferedPacket> packets = 657 std::list<BufferedPacket> packets =
657 buffered_packets_.DeliverPacketsForNextConnection(&connection_id); 658 buffered_packets_.DeliverPacketsForNextConnection(&connection_id);
658 if (packets.empty()) { 659 if (packets.empty()) {
659 return; 660 return;
660 } 661 }
661 QuicSession* session = 662 QuicSession* session =
662 CreateQuicSession(connection_id, packets.front().client_address); 663 CreateQuicSession(connection_id, packets.front().client_address);
663 DVLOG(1) << "Created new session for " << connection_id; 664 QUIC_DLOG(INFO) << "Created new session for " << connection_id;
664 session_map_.insert( 665 session_map_.insert(
665 std::make_pair(connection_id, base::WrapUnique(session))); 666 std::make_pair(connection_id, base::WrapUnique(session)));
666 DeliverPacketsToSession(packets, session); 667 DeliverPacketsToSession(packets, session);
667 } 668 }
668 } 669 }
669 670
670 bool QuicDispatcher::HasChlosBuffered() const { 671 bool QuicDispatcher::HasChlosBuffered() const {
671 return buffered_packets_.HasChlosBuffered(); 672 return buffered_packets_.HasChlosBuffered();
672 } 673 }
673 674
674 bool QuicDispatcher::ShouldCreateOrBufferPacketForConnection( 675 bool QuicDispatcher::ShouldCreateOrBufferPacketForConnection(
675 QuicConnectionId connection_id) { 676 QuicConnectionId connection_id) {
676 VLOG(1) << "Received packet from new connection " << connection_id; 677 VLOG(1) << "Received packet from new connection " << connection_id;
677 return true; 678 return true;
678 } 679 }
679 680
680 // Return true if there is any packet buffered in the store. 681 // Return true if there is any packet buffered in the store.
681 bool QuicDispatcher::HasBufferedPackets(QuicConnectionId connection_id) { 682 bool QuicDispatcher::HasBufferedPackets(QuicConnectionId connection_id) {
682 return buffered_packets_.HasBufferedPackets(connection_id); 683 return buffered_packets_.HasBufferedPackets(connection_id);
683 } 684 }
684 685
685 void QuicDispatcher::OnBufferPacketFailure(EnqueuePacketResult result, 686 void QuicDispatcher::OnBufferPacketFailure(EnqueuePacketResult result,
686 QuicConnectionId connection_id) { 687 QuicConnectionId connection_id) {
687 DVLOG(1) << "Fail to buffer packet on connection " << connection_id 688 QUIC_DLOG(INFO) << "Fail to buffer packet on connection " << connection_id
688 << " because of " << result; 689 << " because of " << result;
689 } 690 }
690 691
691 void QuicDispatcher::OnConnectionRejectedStatelessly() {} 692 void QuicDispatcher::OnConnectionRejectedStatelessly() {}
692 693
693 void QuicDispatcher::OnConnectionClosedStatelessly(QuicErrorCode error) {} 694 void QuicDispatcher::OnConnectionClosedStatelessly(QuicErrorCode error) {}
694 695
695 bool QuicDispatcher::ShouldAttemptCheapStatelessRejection() { 696 bool QuicDispatcher::ShouldAttemptCheapStatelessRejection() {
696 return true; 697 return true;
697 } 698 }
698 699
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 !FLAGS_quic_reloadable_flag_quic_create_session_after_insertion && 746 !FLAGS_quic_reloadable_flag_quic_create_session_after_insertion &&
746 is_new_connection) { 747 is_new_connection) {
747 ShouldCreateOrBufferPacketForConnection(current_connection_id_); 748 ShouldCreateOrBufferPacketForConnection(current_connection_id_);
748 } 749 }
749 } 750 }
750 return; 751 return;
751 } 752 }
752 // Creates a new session and process all buffered packets for this connection. 753 // Creates a new session and process all buffered packets for this connection.
753 QuicSession* session = 754 QuicSession* session =
754 CreateQuicSession(current_connection_id_, current_client_address_); 755 CreateQuicSession(current_connection_id_, current_client_address_);
755 DVLOG(1) << "Created new session for " << current_connection_id_; 756 QUIC_DLOG(INFO) << "Created new session for " << current_connection_id_;
756 session_map_.insert( 757 session_map_.insert(
757 std::make_pair(current_connection_id_, base::WrapUnique(session))); 758 std::make_pair(current_connection_id_, base::WrapUnique(session)));
758 std::list<BufferedPacket> packets = 759 std::list<BufferedPacket> packets =
759 buffered_packets_.DeliverPackets(current_connection_id_); 760 buffered_packets_.DeliverPackets(current_connection_id_);
760 // Check if CHLO is the first packet arrived on this connection. 761 // Check if CHLO is the first packet arrived on this connection.
761 if (!FLAGS_quic_reloadable_flag_quic_create_session_after_insertion && 762 if (!FLAGS_quic_reloadable_flag_quic_create_session_after_insertion &&
762 packets.empty()) { 763 packets.empty()) {
763 ShouldCreateOrBufferPacketForConnection(current_connection_id_); 764 ShouldCreateOrBufferPacketForConnection(current_connection_id_);
764 } 765 }
765 // Process CHLO at first. 766 // Process CHLO at first.
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 void QuicDispatcher::DeliverPacketsToSession( 996 void QuicDispatcher::DeliverPacketsToSession(
996 const std::list<BufferedPacket>& packets, 997 const std::list<BufferedPacket>& packets,
997 QuicSession* session) { 998 QuicSession* session) {
998 for (const BufferedPacket& packet : packets) { 999 for (const BufferedPacket& packet : packets) {
999 session->ProcessUdpPacket(packet.server_address, packet.client_address, 1000 session->ProcessUdpPacket(packet.server_address, packet.client_address,
1000 *(packet.packet)); 1001 *(packet.packet));
1001 } 1002 }
1002 } 1003 }
1003 1004
1004 } // namespace net 1005 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698