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

Side by Side Diff: net/quic/quic_connection.cc

Issue 1548783002: Adding details to most quic connection close calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@110540464
Patch Set: Created 5 years 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
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_crypto_client_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/quic/quic_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 679
680 bool QuicConnection::OnStreamFrame(const QuicStreamFrame& frame) { 680 bool QuicConnection::OnStreamFrame(const QuicStreamFrame& frame) {
681 DCHECK(connected_); 681 DCHECK(connected_);
682 if (debug_visitor_ != nullptr) { 682 if (debug_visitor_ != nullptr) {
683 debug_visitor_->OnStreamFrame(frame); 683 debug_visitor_->OnStreamFrame(frame);
684 } 684 }
685 if (frame.stream_id != kCryptoStreamId && 685 if (frame.stream_id != kCryptoStreamId &&
686 last_decrypted_packet_level_ == ENCRYPTION_NONE) { 686 last_decrypted_packet_level_ == ENCRYPTION_NONE) {
687 DLOG(WARNING) << ENDPOINT 687 DLOG(WARNING) << ENDPOINT
688 << "Received an unencrypted data frame: closing connection"; 688 << "Received an unencrypted data frame: closing connection";
689 SendConnectionClose(QUIC_UNENCRYPTED_STREAM_DATA); 689 SendConnectionCloseWithDetails(QUIC_UNENCRYPTED_STREAM_DATA,
690 "Unencrypted stream data seen");
690 return false; 691 return false;
691 } 692 }
692 visitor_->OnStreamFrame(frame); 693 visitor_->OnStreamFrame(frame);
693 stats_.stream_bytes_received += frame.frame_length; 694 stats_.stream_bytes_received += frame.frame_length;
694 should_last_packet_instigate_acks_ = true; 695 should_last_packet_instigate_acks_ = true;
695 return connected_; 696 return connected_;
696 } 697 }
697 698
698 bool QuicConnection::OnAckFrame(const QuicAckFrame& incoming_ack) { 699 bool QuicConnection::OnAckFrame(const QuicAckFrame& incoming_ack) {
699 DCHECK(connected_); 700 DCHECK(connected_);
700 if (debug_visitor_ != nullptr) { 701 if (debug_visitor_ != nullptr) {
701 debug_visitor_->OnAckFrame(incoming_ack); 702 debug_visitor_->OnAckFrame(incoming_ack);
702 } 703 }
703 DVLOG(1) << ENDPOINT << "OnAckFrame: " << incoming_ack; 704 DVLOG(1) << ENDPOINT << "OnAckFrame: " << incoming_ack;
704 705
705 if (last_header_.packet_number <= largest_seen_packet_with_ack_) { 706 if (last_header_.packet_number <= largest_seen_packet_with_ack_) {
706 DVLOG(1) << ENDPOINT << "Received an old ack frame: ignoring"; 707 DVLOG(1) << ENDPOINT << "Received an old ack frame: ignoring";
707 return true; 708 return true;
708 } 709 }
709 710
710 if (!ValidateAckFrame(incoming_ack)) { 711 const char* error = ValidateAckFrame(incoming_ack);
711 SendConnectionClose(QUIC_INVALID_ACK_DATA); 712 if (error != nullptr) {
713 SendConnectionCloseWithDetails(QUIC_INVALID_ACK_DATA, error);
712 return false; 714 return false;
713 } 715 }
714 716
715 if (FLAGS_quic_respect_send_alarm2 && send_alarm_->IsSet()) { 717 if (FLAGS_quic_respect_send_alarm2 && send_alarm_->IsSet()) {
716 send_alarm_->Cancel(); 718 send_alarm_->Cancel();
717 } 719 }
718 ProcessAckFrame(incoming_ack); 720 ProcessAckFrame(incoming_ack);
719 if (incoming_ack.is_truncated) { 721 if (incoming_ack.is_truncated) {
720 should_last_packet_instigate_acks_ = true; 722 should_last_packet_instigate_acks_ = true;
721 } 723 }
(...skipping 30 matching lines...) Expand all
752 } 754 }
753 755
754 bool QuicConnection::OnStopWaitingFrame(const QuicStopWaitingFrame& frame) { 756 bool QuicConnection::OnStopWaitingFrame(const QuicStopWaitingFrame& frame) {
755 DCHECK(connected_); 757 DCHECK(connected_);
756 758
757 if (last_header_.packet_number <= largest_seen_packet_with_stop_waiting_) { 759 if (last_header_.packet_number <= largest_seen_packet_with_stop_waiting_) {
758 DVLOG(1) << ENDPOINT << "Received an old stop waiting frame: ignoring"; 760 DVLOG(1) << ENDPOINT << "Received an old stop waiting frame: ignoring";
759 return true; 761 return true;
760 } 762 }
761 763
762 if (!ValidateStopWaitingFrame(frame)) { 764 const char* error = ValidateStopWaitingFrame(frame);
763 SendConnectionClose(QUIC_INVALID_STOP_WAITING_DATA); 765 if (error != nullptr) {
766 SendConnectionCloseWithDetails(QUIC_INVALID_STOP_WAITING_DATA, error);
764 return false; 767 return false;
765 } 768 }
766 769
767 if (debug_visitor_ != nullptr) { 770 if (debug_visitor_ != nullptr) {
768 debug_visitor_->OnStopWaitingFrame(frame); 771 debug_visitor_->OnStopWaitingFrame(frame);
769 } 772 }
770 773
771 last_stop_waiting_frame_ = frame; 774 last_stop_waiting_frame_ = frame;
772 return connected_; 775 return connected_;
773 } 776 }
774 777
775 bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) { 778 bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) {
776 DCHECK(connected_); 779 DCHECK(connected_);
777 if (debug_visitor_ != nullptr) { 780 if (debug_visitor_ != nullptr) {
778 debug_visitor_->OnPingFrame(frame); 781 debug_visitor_->OnPingFrame(frame);
779 } 782 }
780 should_last_packet_instigate_acks_ = true; 783 should_last_packet_instigate_acks_ = true;
781 return true; 784 return true;
782 } 785 }
783 786
784 bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { 787 const char* QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) {
785 if (incoming_ack.largest_observed > packet_generator_.packet_number()) { 788 if (incoming_ack.largest_observed > packet_generator_.packet_number()) {
786 LOG(WARNING) << ENDPOINT << "Peer's observed unsent packet:" 789 LOG(WARNING) << ENDPOINT << "Peer's observed unsent packet:"
787 << incoming_ack.largest_observed << " vs " 790 << incoming_ack.largest_observed << " vs "
788 << packet_generator_.packet_number(); 791 << packet_generator_.packet_number();
789 // We got an error for data we have not sent. Error out. 792 // We got an error for data we have not sent. Error out.
790 return false; 793 return "Largest observed too high";
791 } 794 }
792 795
793 if (incoming_ack.largest_observed < sent_packet_manager_.largest_observed()) { 796 if (incoming_ack.largest_observed < sent_packet_manager_.largest_observed()) {
794 LOG(WARNING) << ENDPOINT << "Peer's largest_observed packet decreased:" 797 LOG(WARNING) << ENDPOINT << "Peer's largest_observed packet decreased:"
795 << incoming_ack.largest_observed << " vs " 798 << incoming_ack.largest_observed << " vs "
796 << sent_packet_manager_.largest_observed(); 799 << sent_packet_manager_.largest_observed();
797 // A new ack has a diminished largest_observed value. Error out. 800 // A new ack has a diminished largest_observed value. Error out.
798 // If this was an old packet, we wouldn't even have checked. 801 // If this was an old packet, we wouldn't even have checked.
799 return false; 802 return "Largest observed too low";
800 } 803 }
801 804
802 if (!incoming_ack.missing_packets.Empty() && 805 if (!incoming_ack.missing_packets.Empty() &&
803 incoming_ack.missing_packets.Max() > incoming_ack.largest_observed) { 806 incoming_ack.missing_packets.Max() > incoming_ack.largest_observed) {
804 LOG(WARNING) << ENDPOINT << "Peer sent missing packet: " 807 LOG(WARNING) << ENDPOINT << "Peer sent missing packet: "
805 << incoming_ack.missing_packets.Max() 808 << incoming_ack.missing_packets.Max()
806 << " which is greater than largest observed: " 809 << " which is greater than largest observed: "
807 << incoming_ack.largest_observed; 810 << incoming_ack.largest_observed;
808 return false; 811 return "Missing packet higher than largest observed";
809 } 812 }
810 813
811 if (!incoming_ack.missing_packets.Empty() && 814 if (!incoming_ack.missing_packets.Empty() &&
812 incoming_ack.missing_packets.Min() < 815 incoming_ack.missing_packets.Min() <
813 sent_packet_manager_.least_packet_awaited_by_peer()) { 816 sent_packet_manager_.least_packet_awaited_by_peer()) {
814 LOG(WARNING) << ENDPOINT << "Peer sent missing packet: " 817 LOG(WARNING) << ENDPOINT << "Peer sent missing packet: "
815 << incoming_ack.missing_packets.Min() 818 << incoming_ack.missing_packets.Min()
816 << " which is smaller than least_packet_awaited_by_peer_: " 819 << " which is smaller than least_packet_awaited_by_peer_: "
817 << sent_packet_manager_.least_packet_awaited_by_peer(); 820 << sent_packet_manager_.least_packet_awaited_by_peer();
818 return false; 821 return "Missing packet smaller than least awaited";
819 } 822 }
820 823
821 if (!sent_entropy_manager_.IsValidEntropy(incoming_ack.largest_observed, 824 if (!sent_entropy_manager_.IsValidEntropy(incoming_ack.largest_observed,
822 incoming_ack.missing_packets, 825 incoming_ack.missing_packets,
823 incoming_ack.entropy_hash)) { 826 incoming_ack.entropy_hash)) {
824 LOG(WARNING) << ENDPOINT << "Peer sent invalid entropy."; 827 LOG(WARNING) << ENDPOINT << "Peer sent invalid entropy.";
825 return false; 828 return "Invalid entropy";
826 } 829 }
827 830
828 if (incoming_ack.latest_revived_packet != 0 && 831 if (incoming_ack.latest_revived_packet != 0 &&
829 !incoming_ack.missing_packets.Contains( 832 !incoming_ack.missing_packets.Contains(
830 incoming_ack.latest_revived_packet)) { 833 incoming_ack.latest_revived_packet)) {
831 LOG(WARNING) << ENDPOINT 834 LOG(WARNING) << ENDPOINT
832 << "Peer specified revived packet which was not missing."; 835 << "Peer specified revived packet which was not missing.";
833 return false; 836 return "Invalid revived packet";
834 } 837 }
835 return true; 838 return nullptr;
836 } 839 }
837 840
838 bool QuicConnection::ValidateStopWaitingFrame( 841 const char* QuicConnection::ValidateStopWaitingFrame(
839 const QuicStopWaitingFrame& stop_waiting) { 842 const QuicStopWaitingFrame& stop_waiting) {
840 if (stop_waiting.least_unacked < 843 if (stop_waiting.least_unacked <
841 received_packet_manager_.peer_least_packet_awaiting_ack()) { 844 received_packet_manager_.peer_least_packet_awaiting_ack()) {
842 DLOG(ERROR) << ENDPOINT << "Peer's sent low least_unacked: " 845 DLOG(ERROR) << ENDPOINT << "Peer's sent low least_unacked: "
843 << stop_waiting.least_unacked << " vs " 846 << stop_waiting.least_unacked << " vs "
844 << received_packet_manager_.peer_least_packet_awaiting_ack(); 847 << received_packet_manager_.peer_least_packet_awaiting_ack();
845 // We never process old ack frames, so this number should only increase. 848 // We never process old ack frames, so this number should only increase.
846 return false; 849 return "Least unacked too small";
847 } 850 }
848 851
849 if (stop_waiting.least_unacked > last_header_.packet_number) { 852 if (stop_waiting.least_unacked > last_header_.packet_number) {
850 DLOG(ERROR) << ENDPOINT 853 DLOG(ERROR) << ENDPOINT
851 << "Peer sent least_unacked:" << stop_waiting.least_unacked 854 << "Peer sent least_unacked:" << stop_waiting.least_unacked
852 << " greater than the enclosing packet number:" 855 << " greater than the enclosing packet number:"
853 << last_header_.packet_number; 856 << last_header_.packet_number;
854 return false; 857 return "Least unacked too large";
855 } 858 }
856 859
857 return true; 860 return nullptr;
858 } 861 }
859 862
860 void QuicConnection::OnFecData(StringPiece redundancy) { 863 void QuicConnection::OnFecData(StringPiece redundancy) {
861 DCHECK_EQ(IN_FEC_GROUP, last_header_.is_in_fec_group); 864 DCHECK_EQ(IN_FEC_GROUP, last_header_.is_in_fec_group);
862 DCHECK_NE(0u, last_header_.fec_group); 865 DCHECK_NE(0u, last_header_.fec_group);
863 QuicFecGroup* group = GetFecGroup(); 866 QuicFecGroup* group = GetFecGroup();
864 if (group != nullptr) { 867 if (group != nullptr) {
865 group->UpdateFec(last_decrypted_packet_level_, last_header_, redundancy); 868 group->UpdateFec(last_decrypted_packet_level_, last_header_, redundancy);
866 } 869 }
867 } 870 }
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 // timeout handling. 2176 // timeout handling.
2174 QuicTime::Delta idle_duration = now.Subtract(time_of_last_packet); 2177 QuicTime::Delta idle_duration = now.Subtract(time_of_last_packet);
2175 DVLOG(1) << ENDPOINT << "last packet " 2178 DVLOG(1) << ENDPOINT << "last packet "
2176 << time_of_last_packet.ToDebuggingValue() 2179 << time_of_last_packet.ToDebuggingValue()
2177 << " now:" << now.ToDebuggingValue() 2180 << " now:" << now.ToDebuggingValue()
2178 << " idle_duration:" << idle_duration.ToMicroseconds() 2181 << " idle_duration:" << idle_duration.ToMicroseconds()
2179 << " idle_network_timeout: " 2182 << " idle_network_timeout: "
2180 << idle_network_timeout_.ToMicroseconds(); 2183 << idle_network_timeout_.ToMicroseconds();
2181 if (idle_duration >= idle_network_timeout_) { 2184 if (idle_duration >= idle_network_timeout_) {
2182 DVLOG(1) << ENDPOINT << "Connection timedout due to no network activity."; 2185 DVLOG(1) << ENDPOINT << "Connection timedout due to no network activity.";
2183 SendConnectionClose(QUIC_CONNECTION_TIMED_OUT); 2186 SendConnectionCloseWithDetails(QUIC_CONNECTION_TIMED_OUT,
2187 "No recent network activity");
2184 return; 2188 return;
2185 } 2189 }
2186 2190
2187 if (!overall_connection_timeout_.IsInfinite()) { 2191 if (!overall_connection_timeout_.IsInfinite()) {
2188 QuicTime::Delta connected_duration = 2192 QuicTime::Delta connected_duration =
2189 now.Subtract(stats_.connection_creation_time); 2193 now.Subtract(stats_.connection_creation_time);
2190 DVLOG(1) << ENDPOINT << "connection time: " 2194 DVLOG(1) << ENDPOINT << "connection time: "
2191 << connected_duration.ToMicroseconds() << " overall timeout: " 2195 << connected_duration.ToMicroseconds() << " overall timeout: "
2192 << overall_connection_timeout_.ToMicroseconds(); 2196 << overall_connection_timeout_.ToMicroseconds();
2193 if (connected_duration >= overall_connection_timeout_) { 2197 if (connected_duration >= overall_connection_timeout_) {
2194 DVLOG(1) << ENDPOINT << 2198 DVLOG(1) << ENDPOINT
2195 "Connection timedout due to overall connection timeout."; 2199 << "Connection timedout due to overall connection timeout.";
2196 SendConnectionClose(QUIC_CONNECTION_OVERALL_TIMED_OUT); 2200 SendConnectionCloseWithDetails(QUIC_CONNECTION_OVERALL_TIMED_OUT,
2201 "Overall timeout expired");
2197 return; 2202 return;
2198 } 2203 }
2199 } 2204 }
2200 2205
2201 SetTimeoutAlarm(); 2206 SetTimeoutAlarm();
2202 } 2207 }
2203 2208
2204 void QuicConnection::SetTimeoutAlarm() { 2209 void QuicConnection::SetTimeoutAlarm() {
2205 QuicTime time_of_last_packet = max(time_of_last_received_packet_, 2210 QuicTime time_of_last_packet = max(time_of_last_received_packet_,
2206 time_of_last_sent_new_packet_); 2211 time_of_last_sent_new_packet_);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 SendMtuDiscoveryPacket(mtu_discovery_target_); 2419 SendMtuDiscoveryPacket(mtu_discovery_target_);
2415 2420
2416 DCHECK(!mtu_discovery_alarm_->IsSet()); 2421 DCHECK(!mtu_discovery_alarm_->IsSet());
2417 } 2422 }
2418 2423
2419 bool QuicConnection::ack_frame_updated() const { 2424 bool QuicConnection::ack_frame_updated() const {
2420 return received_packet_manager_.ack_frame_updated(); 2425 return received_packet_manager_.ack_frame_updated();
2421 } 2426 }
2422 2427
2423 } // namespace net 2428 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_crypto_client_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698