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

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

Issue 1421853006: Landing Recent QUIC changes until: Fri Oct 30 22:23:58 2015 +0000 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 5 years, 1 month 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"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "net/quic/quic_flags.h" 12 #include "net/quic/quic_flags.h"
13 #include "net/quic/quic_utils.h" 13 #include "net/quic/quic_utils.h"
14 #include "net/tools/quic/quic_per_connection_packet_writer.h" 14 #include "net/tools/quic/quic_per_connection_packet_writer.h"
15 #include "net/tools/quic/quic_time_wait_list_manager.h" 15 #include "net/tools/quic/quic_time_wait_list_manager.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 namespace tools { 19 namespace tools {
20 20
21 using std::make_pair; 21 using std::make_pair;
22 using base::StringPiece; 22 using base::StringPiece;
23 23
24 // The threshold size for the session map, over which the dispatcher will start
25 // sending stateless rejects (SREJ), rather than stateful rejects (REJ) to
26 // clients who support them. If -1, stateless rejects will not be sent. If 0,
27 // the server will only send stateless rejects to clients who support them.
28 int32 FLAGS_quic_session_map_threshold_for_stateless_rejects = -1;
29
30 namespace { 24 namespace {
31 25
32 // An alarm that informs the QuicDispatcher to delete old sessions. 26 // An alarm that informs the QuicDispatcher to delete old sessions.
33 class DeleteSessionsAlarm : public QuicAlarm::Delegate { 27 class DeleteSessionsAlarm : public QuicAlarm::Delegate {
34 public: 28 public:
35 explicit DeleteSessionsAlarm(QuicDispatcher* dispatcher) 29 explicit DeleteSessionsAlarm(QuicDispatcher* dispatcher)
36 : dispatcher_(dispatcher) { 30 : dispatcher_(dispatcher) {
37 } 31 }
38 32
39 QuicTime OnAlarm() override { 33 QuicTime OnAlarm() override {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 196 }
203 197
204 void QuicDispatcher::ProcessPacket(const IPEndPoint& server_address, 198 void QuicDispatcher::ProcessPacket(const IPEndPoint& server_address,
205 const IPEndPoint& client_address, 199 const IPEndPoint& client_address,
206 const QuicEncryptedPacket& packet) { 200 const QuicEncryptedPacket& packet) {
207 current_server_address_ = server_address; 201 current_server_address_ = server_address;
208 current_client_address_ = client_address; 202 current_client_address_ = client_address;
209 current_packet_ = &packet; 203 current_packet_ = &packet;
210 // ProcessPacket will cause the packet to be dispatched in 204 // ProcessPacket will cause the packet to be dispatched in
211 // OnUnauthenticatedPublicHeader, or sent to the time wait list manager 205 // OnUnauthenticatedPublicHeader, or sent to the time wait list manager
212 // in OnAuthenticatedHeader. 206 // in OnUnauthenticatedHeader.
213 framer_.ProcessPacket(packet); 207 framer_.ProcessPacket(packet);
214 // TODO(rjshade): Return a status describing if/why a packet was dropped, 208 // TODO(rjshade): Return a status describing if/why a packet was dropped,
215 // and log somehow. Maybe expose as a varz. 209 // and log somehow. Maybe expose as a varz.
216 } 210 }
217 211
218 bool QuicDispatcher::OnUnauthenticatedPublicHeader( 212 bool QuicDispatcher::OnUnauthenticatedPublicHeader(
219 const QuicPacketPublicHeader& header) { 213 const QuicPacketPublicHeader& header) {
220 // Port zero is only allowed for unidirectional UDP, so is disallowed by QUIC. 214 // Port zero is only allowed for unidirectional UDP, so is disallowed by QUIC.
221 // Given that we can't even send a reply rejecting the packet, just drop the 215 // Given that we can't even send a reply rejecting the packet, just drop the
222 // packet. 216 // packet.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 header.packet_number > kMaxReasonableInitialPacketNumber) { 346 header.packet_number > kMaxReasonableInitialPacketNumber) {
353 return kFateTimeWait; 347 return kFateTimeWait;
354 } 348 }
355 349
356 return kFateProcess; 350 return kFateProcess;
357 } 351 }
358 352
359 void QuicDispatcher::CleanUpSession(SessionMap::iterator it, 353 void QuicDispatcher::CleanUpSession(SessionMap::iterator it,
360 bool should_close_statelessly) { 354 bool should_close_statelessly) {
361 QuicConnection* connection = it->second->connection(); 355 QuicConnection* connection = it->second->connection();
362 QuicEncryptedPacket* connection_close_packet = 356
363 connection->ReleaseConnectionClosePacket();
364 write_blocked_list_.erase(connection); 357 write_blocked_list_.erase(connection);
365 DCHECK(!should_close_statelessly || !connection_close_packet); 358 if (should_close_statelessly) {
359 DCHECK(connection->termination_packets() != nullptr &&
360 !connection->termination_packets()->empty());
361 }
366 time_wait_list_manager_->AddConnectionIdToTimeWait( 362 time_wait_list_manager_->AddConnectionIdToTimeWait(
367 it->first, connection->version(), should_close_statelessly, 363 it->first, connection->version(), should_close_statelessly,
368 connection_close_packet); 364 connection->termination_packets());
369 session_map_.erase(it); 365 session_map_.erase(it);
370 } 366 }
371 367
372 void QuicDispatcher::DeleteSessions() { 368 void QuicDispatcher::DeleteSessions() {
373 STLDeleteElements(&closed_session_list_); 369 STLDeleteElements(&closed_session_list_);
374 } 370 }
375 371
376 void QuicDispatcher::OnCanWrite() { 372 void QuicDispatcher::OnCanWrite() {
377 // The socket is now writable. 373 // The socket is now writable.
378 writer_->SetWritable(); 374 writer_->SetWritable();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 QuicConnectionId connection_id, 449 QuicConnectionId connection_id,
454 const IPEndPoint& client_address) { 450 const IPEndPoint& client_address) {
455 // The QuicServerSession takes ownership of |connection| below. 451 // The QuicServerSession takes ownership of |connection| below.
456 QuicConnection* connection = new QuicConnection( 452 QuicConnection* connection = new QuicConnection(
457 connection_id, client_address, helper_.get(), connection_writer_factory_, 453 connection_id, client_address, helper_.get(), connection_writer_factory_,
458 /* owns_writer= */ true, Perspective::IS_SERVER, supported_versions_); 454 /* owns_writer= */ true, Perspective::IS_SERVER, supported_versions_);
459 455
460 QuicServerSession* session = 456 QuicServerSession* session =
461 new QuicServerSession(config_, connection, this, crypto_config_); 457 new QuicServerSession(config_, connection, this, crypto_config_);
462 session->Initialize(); 458 session->Initialize();
463 if (FLAGS_quic_session_map_threshold_for_stateless_rejects != -1 &&
464 session_map_.size() >=
465 static_cast<size_t>(
466 FLAGS_quic_session_map_threshold_for_stateless_rejects)) {
467 session->set_use_stateless_rejects_if_peer_supported(true);
468 }
469 return session; 459 return session;
470 } 460 }
471 461
472 QuicTimeWaitListManager* QuicDispatcher::CreateQuicTimeWaitListManager() { 462 QuicTimeWaitListManager* QuicDispatcher::CreateQuicTimeWaitListManager() {
473 // TODO(rjshade): The QuicTimeWaitListManager should take ownership of the 463 // TODO(rjshade): The QuicTimeWaitListManager should take ownership of the
474 // per-connection packet writer. 464 // per-connection packet writer.
475 time_wait_list_writer_.reset( 465 time_wait_list_writer_.reset(
476 packet_writer_factory_->Create(writer_.get(), nullptr)); 466 packet_writer_factory_->Create(writer_.get(), nullptr));
477 return new QuicTimeWaitListManager(time_wait_list_writer_.get(), this, 467 return new QuicTimeWaitListManager(time_wait_list_writer_.get(), this,
478 helper_.get()); 468 helper_.get());
(...skipping 15 matching lines...) Expand all
494 // send it to the time wait manager in OnUnathenticatedHeader. 484 // send it to the time wait manager in OnUnathenticatedHeader.
495 return true; 485 return true;
496 } 486 }
497 487
498 void QuicDispatcher::SetLastError(QuicErrorCode error) { 488 void QuicDispatcher::SetLastError(QuicErrorCode error) {
499 last_error_ = error; 489 last_error_ = error;
500 } 490 }
501 491
502 } // namespace tools 492 } // namespace tools
503 } // namespace net 493 } // 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