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

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

Issue 2132623002: Landing Recent QUIC changes until 2016-07-02 02:45 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing comment about RPCs Created 4 years, 5 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/tools/quic/quic_dispatcher.h ('k') | net/tools/quic/quic_dispatcher_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/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" 10 #include "base/logging.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 std::unique_ptr<QuicAlarmFactory> alarm_factory) 193 std::unique_ptr<QuicAlarmFactory> alarm_factory)
194 : config_(config), 194 : config_(config),
195 crypto_config_(crypto_config), 195 crypto_config_(crypto_config),
196 compressed_certs_cache_( 196 compressed_certs_cache_(
197 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), 197 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize),
198 helper_(std::move(helper)), 198 helper_(std::move(helper)),
199 session_helper_(std::move(session_helper)), 199 session_helper_(std::move(session_helper)),
200 alarm_factory_(std::move(alarm_factory)), 200 alarm_factory_(std::move(alarm_factory)),
201 delete_sessions_alarm_( 201 delete_sessions_alarm_(
202 alarm_factory_->CreateAlarm(new DeleteSessionsAlarm(this))), 202 alarm_factory_->CreateAlarm(new DeleteSessionsAlarm(this))),
203 buffered_packets_(this, helper_->GetClock(), alarm_factory_.get()),
203 supported_versions_(supported_versions), 204 supported_versions_(supported_versions),
204 disable_quic_pre_30_(FLAGS_quic_disable_pre_30), 205 disable_quic_pre_30_(FLAGS_quic_disable_pre_30),
205 allowed_supported_versions_(supported_versions), 206 allowed_supported_versions_(supported_versions),
206 current_packet_(nullptr), 207 current_packet_(nullptr),
207 framer_(supported_versions, 208 framer_(supported_versions,
208 /*unused*/ QuicTime::Zero(), 209 /*unused*/ QuicTime::Zero(),
209 Perspective::IS_SERVER), 210 Perspective::IS_SERVER),
210 last_error_(QUIC_NO_ERROR) { 211 last_error_(QUIC_NO_ERROR) {
211 framer_.set_visitor(this); 212 framer_.set_visitor(this);
212 } 213 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // connection ID. 254 // connection ID.
254 if (header.connection_id_length != PACKET_8BYTE_CONNECTION_ID) { 255 if (header.connection_id_length != PACKET_8BYTE_CONNECTION_ID) {
255 return false; 256 return false;
256 } 257 }
257 258
258 // Packets with connection IDs for active connections are processed 259 // Packets with connection IDs for active connections are processed
259 // immediately. 260 // immediately.
260 QuicConnectionId connection_id = header.connection_id; 261 QuicConnectionId connection_id = header.connection_id;
261 SessionMap::iterator it = session_map_.find(connection_id); 262 SessionMap::iterator it = session_map_.find(connection_id);
262 if (it != session_map_.end()) { 263 if (it != session_map_.end()) {
264 DCHECK(!buffered_packets_.HasBufferedPackets(connection_id));
263 it->second->ProcessUdpPacket(current_server_address_, 265 it->second->ProcessUdpPacket(current_server_address_,
264 current_client_address_, *current_packet_); 266 current_client_address_, *current_packet_);
265 return false; 267 return false;
266 } 268 }
267 269
268 if (!OnUnauthenticatedUnknownPublicHeader(header)) { 270 if (!OnUnauthenticatedUnknownPublicHeader(header)) {
269 return false; 271 return false;
270 } 272 }
271 273
272 // If the packet is a public reset for a connection ID that is not active, 274 // If the packet is a public reset for a connection ID that is not active,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 329 }
328 switch (fate) { 330 switch (fate) {
329 case kFateProcess: { 331 case kFateProcess: {
330 // Create a session and process the packet. 332 // Create a session and process the packet.
331 QuicServerSessionBase* session = 333 QuicServerSessionBase* session =
332 CreateQuicSession(connection_id, current_client_address_); 334 CreateQuicSession(connection_id, current_client_address_);
333 DVLOG(1) << "Created new session for " << connection_id; 335 DVLOG(1) << "Created new session for " << connection_id;
334 session_map_.insert(std::make_pair(connection_id, session)); 336 session_map_.insert(std::make_pair(connection_id, session));
335 session->ProcessUdpPacket(current_server_address_, 337 session->ProcessUdpPacket(current_server_address_,
336 current_client_address_, *current_packet_); 338 current_client_address_, *current_packet_);
339 std::list<QuicBufferedPacketStore::BufferedPacket> packets =
340 buffered_packets_.DeliverPackets(connection_id);
341 for (const auto& packet : packets) {
342 SessionMap::iterator it = session_map_.find(connection_id);
343 if (it == session_map_.end()) {
344 break;
345 }
346 it->second->ProcessUdpPacket(packet.server_address,
347 packet.client_address, *packet.packet);
348 }
337 break; 349 break;
338 } 350 }
339 case kFateTimeWait: 351 case kFateTimeWait:
340 // MaybeRejectStatelessly might have already added the connection to 352 // MaybeRejectStatelessly might have already added the connection to
341 // time wait, in which case it should not be added again. 353 // time wait, in which case it should not be added again.
342 if (!FLAGS_quic_use_cheap_stateless_rejects || 354 if (!FLAGS_quic_use_cheap_stateless_rejects ||
343 !time_wait_list_manager_->IsConnectionIdInTimeWait( 355 !time_wait_list_manager_->IsConnectionIdInTimeWait(
344 header.public_header.connection_id)) { 356 header.public_header.connection_id)) {
345 // Add this connection_id to the time-wait state, to safely reject 357 // Add this connection_id to the time-wait state, to safely reject
346 // future packets. 358 // future packets.
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 599
588 bool QuicDispatcher::OnPathCloseFrame(const QuicPathCloseFrame& frame) { 600 bool QuicDispatcher::OnPathCloseFrame(const QuicPathCloseFrame& frame) {
589 DCHECK(false); 601 DCHECK(false);
590 return false; 602 return false;
591 } 603 }
592 604
593 void QuicDispatcher::OnPacketComplete() { 605 void QuicDispatcher::OnPacketComplete() {
594 DCHECK(false); 606 DCHECK(false);
595 } 607 }
596 608
609 void QuicDispatcher::OnExpiredPackets(
610 QuicConnectionId connection_id,
611 QuicBufferedPacketStore::BufferedPacketList early_arrived_packets) {}
612
597 QuicServerSessionBase* QuicDispatcher::CreateQuicSession( 613 QuicServerSessionBase* QuicDispatcher::CreateQuicSession(
598 QuicConnectionId connection_id, 614 QuicConnectionId connection_id,
599 const IPEndPoint& client_address) { 615 const IPEndPoint& client_address) {
600 // The QuicServerSessionBase takes ownership of |connection| below. 616 // The QuicServerSessionBase takes ownership of |connection| below.
601 QuicConnection* connection = new QuicConnection( 617 QuicConnection* connection = new QuicConnection(
602 connection_id, client_address, helper_.get(), alarm_factory_.get(), 618 connection_id, client_address, helper_.get(), alarm_factory_.get(),
603 CreatePerConnectionWriter(), 619 CreatePerConnectionWriter(),
604 /* owns_writer= */ true, Perspective::IS_SERVER, GetSupportedVersions()); 620 /* owns_writer= */ true, Perspective::IS_SERVER, GetSupportedVersions());
605 621
606 QuicServerSessionBase* session = new QuicSimpleServerSession( 622 QuicServerSessionBase* session = new QuicSimpleServerSession(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 682
667 StatelessRejector rejector(header.public_header.versions.front(), 683 StatelessRejector rejector(header.public_header.versions.front(),
668 supported_versions_, crypto_config_, 684 supported_versions_, crypto_config_,
669 &compressed_certs_cache_, helper()->GetClock(), 685 &compressed_certs_cache_, helper()->GetClock(),
670 helper()->GetRandomGenerator(), 686 helper()->GetRandomGenerator(),
671 current_client_address_, current_server_address_); 687 current_client_address_, current_server_address_);
672 ChloValidator validator(session_helper_.get(), current_server_address_, 688 ChloValidator validator(session_helper_.get(), current_server_address_,
673 &rejector); 689 &rejector);
674 if (!ChloExtractor::Extract(*current_packet_, supported_versions_, 690 if (!ChloExtractor::Extract(*current_packet_, supported_versions_,
675 &validator)) { 691 &validator)) {
676 // TODO(rch): Since there was no CHLO in this packet, buffer it until one 692 DVLOG(1) << "Buffering undecryptable packet.";
677 // arrives. 693 buffered_packets_.EnqueuePacket(connection_id, *current_packet_,
678 DLOG(ERROR) << "Dropping undecryptable packet."; 694 current_server_address_,
695 current_client_address_);
679 return kFateDrop; 696 return kFateDrop;
680 } 697 }
681 698
682 if (!validator.can_accept()) { 699 if (!validator.can_accept()) {
683 // This CHLO is prohibited by policy. 700 // This CHLO is prohibited by policy.
684 StatelessConnectionTerminator terminator(connection_id, &framer_, helper(), 701 StatelessConnectionTerminator terminator(connection_id, &framer_, helper(),
685 time_wait_list_manager_.get()); 702 time_wait_list_manager_.get());
686 terminator.CloseConnection(QUIC_HANDSHAKE_FAILED, 703 terminator.CloseConnection(QUIC_HANDSHAKE_FAILED,
687 validator.error_details()); 704 validator.error_details());
688 OnConnectionClosedStatelessly(QUIC_HANDSHAKE_FAILED); 705 OnConnectionClosedStatelessly(QUIC_HANDSHAKE_FAILED);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 if (disable_quic_pre_30_ != FLAGS_quic_disable_pre_30) { 744 if (disable_quic_pre_30_ != FLAGS_quic_disable_pre_30) {
728 DCHECK_EQ(supported_versions_.capacity(), 745 DCHECK_EQ(supported_versions_.capacity(),
729 allowed_supported_versions_.capacity()); 746 allowed_supported_versions_.capacity());
730 disable_quic_pre_30_ = FLAGS_quic_disable_pre_30; 747 disable_quic_pre_30_ = FLAGS_quic_disable_pre_30;
731 supported_versions_ = FilterSupportedVersions(allowed_supported_versions_); 748 supported_versions_ = FilterSupportedVersions(allowed_supported_versions_);
732 } 749 }
733 return supported_versions_; 750 return supported_versions_;
734 } 751 }
735 752
736 } // namespace net 753 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_dispatcher.h ('k') | net/tools/quic/quic_dispatcher_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698