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

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

Issue 1038293002: Move test for incoming packets with incorrect connection ID from (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Fix_flaky_QUIC_end_to_end_test_89220759
Patch Set: Created 5 years, 8 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
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 last_window_update_frames_.empty() && 384 last_window_update_frames_.empty() &&
385 last_blocked_frames_.empty() && 385 last_blocked_frames_.empty() &&
386 last_ping_frames_.empty() && 386 last_ping_frames_.empty() &&
387 last_close_frames_.empty()); 387 last_close_frames_.empty());
388 last_packet_decrypted_ = false; 388 last_packet_decrypted_ = false;
389 last_packet_revived_ = false; 389 last_packet_revived_ = false;
390 } 390 }
391 391
392 void QuicConnection::OnPublicResetPacket( 392 void QuicConnection::OnPublicResetPacket(
393 const QuicPublicResetPacket& packet) { 393 const QuicPublicResetPacket& packet) {
394 // Check that any public reset packet with a different connection ID that was
395 // routed to this QuicConnection has been redirected before control reaches
396 // here. (Check for a bug regression.)
397 DCHECK_EQ(connection_id_, packet.public_header.connection_id);
394 if (debug_visitor_ != nullptr) { 398 if (debug_visitor_ != nullptr) {
395 debug_visitor_->OnPublicResetPacket(packet); 399 debug_visitor_->OnPublicResetPacket(packet);
396 } 400 }
397 CloseConnection(QUIC_PUBLIC_RESET, true); 401 CloseConnection(QUIC_PUBLIC_RESET, true);
398 402
399 DVLOG(1) << ENDPOINT << "Connection " << connection_id() 403 DVLOG(1) << ENDPOINT << "Connection " << connection_id()
400 << " closed via QUIC_PUBLIC_RESET from peer."; 404 << " closed via QUIC_PUBLIC_RESET from peer.";
401 } 405 }
402 406
403 bool QuicConnection::OnProtocolVersionMismatch(QuicVersion received_version) { 407 bool QuicConnection::OnProtocolVersionMismatch(QuicVersion received_version) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 457
454 // TODO(satyamshekhar): Store the sequence number of this packet and close the 458 // TODO(satyamshekhar): Store the sequence number of this packet and close the
455 // connection if we ever received a packet with incorrect version and whose 459 // connection if we ever received a packet with incorrect version and whose
456 // sequence number is greater. 460 // sequence number is greater.
457 return true; 461 return true;
458 } 462 }
459 463
460 // Handles version negotiation for client connection. 464 // Handles version negotiation for client connection.
461 void QuicConnection::OnVersionNegotiationPacket( 465 void QuicConnection::OnVersionNegotiationPacket(
462 const QuicVersionNegotiationPacket& packet) { 466 const QuicVersionNegotiationPacket& packet) {
467 // Check that any public reset packet with a different connection ID that was
468 // routed to this QuicConnection has been redirected before control reaches
469 // here. (Check for a bug regression.)
470 DCHECK_EQ(connection_id_, packet.connection_id);
463 if (perspective_ == Perspective::IS_SERVER) { 471 if (perspective_ == Perspective::IS_SERVER) {
464 LOG(DFATAL) << ENDPOINT << "Framer parsed VersionNegotiationPacket." 472 LOG(DFATAL) << ENDPOINT << "Framer parsed VersionNegotiationPacket."
465 << " Closing connection."; 473 << " Closing connection.";
466 CloseConnection(QUIC_INTERNAL_ERROR, false); 474 CloseConnection(QUIC_INTERNAL_ERROR, false);
467 return; 475 return;
468 } 476 }
469 if (debug_visitor_ != nullptr) { 477 if (debug_visitor_ != nullptr) {
470 debug_visitor_->OnVersionNegotiationPacket(packet); 478 debug_visitor_->OnVersionNegotiationPacket(packet);
471 } 479 }
472 480
(...skipping 23 matching lines...) Expand all
496 server_supported_versions_ = packet.versions; 504 server_supported_versions_ = packet.versions;
497 version_negotiation_state_ = NEGOTIATION_IN_PROGRESS; 505 version_negotiation_state_ = NEGOTIATION_IN_PROGRESS;
498 RetransmitUnackedPackets(ALL_UNACKED_RETRANSMISSION); 506 RetransmitUnackedPackets(ALL_UNACKED_RETRANSMISSION);
499 } 507 }
500 508
501 void QuicConnection::OnRevivedPacket() { 509 void QuicConnection::OnRevivedPacket() {
502 } 510 }
503 511
504 bool QuicConnection::OnUnauthenticatedPublicHeader( 512 bool QuicConnection::OnUnauthenticatedPublicHeader(
505 const QuicPacketPublicHeader& header) { 513 const QuicPacketPublicHeader& header) {
514 if (header.connection_id == connection_id_) {
515 return true;
516 }
517
518 ++stats_.packets_dropped;
519 DVLOG(1) << ENDPOINT << "Ignoring packet from unexpected ConnectionId: "
520 << header.connection_id << " instead of " << connection_id_;
521 if (debug_visitor_ != nullptr) {
522 debug_visitor_->OnIncorrectConnectionId(header.connection_id);
523 }
524 // If this is a server, the dispatcher routes each packet to the
525 // QuicConnection responsible for the packet's connection ID. So if control
526 // arrives here and this is a server, the dispatcher must be malfunctioning.
527 DCHECK_NE(Perspective::IS_SERVER, perspective_);
528 return false;
529 }
530
531 bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) {
532 // Check that any public reset packet with a different connection ID that was
533 // routed to this QuicConnection has been redirected before control reaches
534 // here.
535 DCHECK_EQ(connection_id_, header.public_header.connection_id);
506 return true; 536 return true;
507 } 537 }
508 538
509 bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) {
510 return true;
511 }
512
513 void QuicConnection::OnDecryptedPacket(EncryptionLevel level) { 539 void QuicConnection::OnDecryptedPacket(EncryptionLevel level) {
514 last_decrypted_packet_level_ = level; 540 last_decrypted_packet_level_ = level;
515 last_packet_decrypted_ = true; 541 last_packet_decrypted_ = true;
516 // If this packet was foward-secure encrypted and the forward-secure encrypter 542 // If this packet was foward-secure encrypted and the forward-secure encrypter
517 // is not being used, start using it. 543 // is not being used, start using it.
518 if (encryption_level_ != ENCRYPTION_FORWARD_SECURE && 544 if (encryption_level_ != ENCRYPTION_FORWARD_SECURE &&
519 has_forward_secure_encrypter_ && level == ENCRYPTION_FORWARD_SECURE) { 545 has_forward_secure_encrypter_ && level == ENCRYPTION_FORWARD_SECURE) {
520 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); 546 SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
521 } 547 }
522 } 548 }
523 549
524 bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { 550 bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) {
525 if (debug_visitor_ != nullptr) { 551 if (debug_visitor_ != nullptr) {
526 debug_visitor_->OnPacketHeader(header); 552 debug_visitor_->OnPacketHeader(header);
527 } 553 }
528 554
529 if (!ProcessValidatedPacket()) { 555 if (!ProcessValidatedPacket()) {
530 return false; 556 return false;
531 } 557 }
532 558
533 // Will be decrement below if we fall through to return true; 559 // Will be decrement below if we fall through to return true;
534 ++stats_.packets_dropped; 560 ++stats_.packets_dropped;
535 561
536 if (header.public_header.connection_id != connection_id_) {
537 DVLOG(1) << ENDPOINT << "Ignoring packet from unexpected ConnectionId: "
538 << header.public_header.connection_id << " instead of "
539 << connection_id_;
540 if (debug_visitor_ != nullptr) {
541 debug_visitor_->OnIncorrectConnectionId(
542 header.public_header.connection_id);
543 }
544 return false;
545 }
546
547 if (!Near(header.packet_sequence_number, 562 if (!Near(header.packet_sequence_number,
548 last_header_.packet_sequence_number)) { 563 last_header_.packet_sequence_number)) {
549 DVLOG(1) << ENDPOINT << "Packet " << header.packet_sequence_number 564 DVLOG(1) << ENDPOINT << "Packet " << header.packet_sequence_number
550 << " out of bounds. Discarding"; 565 << " out of bounds. Discarding";
551 SendConnectionCloseWithDetails(QUIC_INVALID_PACKET_HEADER, 566 SendConnectionCloseWithDetails(QUIC_INVALID_PACKET_HEADER,
552 "Packet sequence number out of bounds"); 567 "Packet sequence number out of bounds");
553 return false; 568 return false;
554 } 569 }
555 570
556 // If this packet has already been seen, or that the sender 571 // If this packet has already been seen, or that the sender
(...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 } 2143 }
2129 for (const QuicFrame& frame : retransmittable_frames->frames()) { 2144 for (const QuicFrame& frame : retransmittable_frames->frames()) {
2130 if (frame.type == CONNECTION_CLOSE_FRAME) { 2145 if (frame.type == CONNECTION_CLOSE_FRAME) {
2131 return true; 2146 return true;
2132 } 2147 }
2133 } 2148 }
2134 return false; 2149 return false;
2135 } 2150 }
2136 2151
2137 } // namespace net 2152 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698