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

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

Issue 1761253002: Make QUIC version negotiation stateless. The QUIC dispatcher now detects version mismatch before cr… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@115591435
Patch Set: Update dependency Created 4 years, 9 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // ProcessPacket will cause the packet to be dispatched in 83 // ProcessPacket will cause the packet to be dispatched in
84 // OnUnauthenticatedPublicHeader, or sent to the time wait list manager 84 // OnUnauthenticatedPublicHeader, or sent to the time wait list manager
85 // in OnUnauthenticatedHeader. 85 // in OnUnauthenticatedHeader.
86 framer_.ProcessPacket(packet); 86 framer_.ProcessPacket(packet);
87 // TODO(rjshade): Return a status describing if/why a packet was dropped, 87 // TODO(rjshade): Return a status describing if/why a packet was dropped,
88 // and log somehow. Maybe expose as a varz. 88 // and log somehow. Maybe expose as a varz.
89 } 89 }
90 90
91 bool QuicDispatcher::OnUnauthenticatedPublicHeader( 91 bool QuicDispatcher::OnUnauthenticatedPublicHeader(
92 const QuicPacketPublicHeader& header) { 92 const QuicPacketPublicHeader& header) {
93 current_connection_id_ = header.connection_id;
94
93 // Port zero is only allowed for unidirectional UDP, so is disallowed by QUIC. 95 // Port zero is only allowed for unidirectional UDP, so is disallowed by QUIC.
94 // Given that we can't even send a reply rejecting the packet, just drop the 96 // Given that we can't even send a reply rejecting the packet, just drop the
95 // packet. 97 // packet.
96 if (current_client_address_.port() == 0) { 98 if (current_client_address_.port() == 0) {
97 return false; 99 return false;
98 } 100 }
99 101
100 // Stopgap test: The code does not construct full-length connection IDs 102 // Stopgap test: The code does not construct full-length connection IDs
101 // correctly from truncated connection ID fields. Prevent this from causing 103 // correctly from truncated connection ID fields. Prevent this from causing
102 // the connection ID lookup to error by dropping any packet with a short 104 // the connection ID lookup to error by dropping any packet with a short
(...skipping 27 matching lines...) Expand all
130 // The packet has an unknown connection ID. 132 // The packet has an unknown connection ID.
131 133
132 // Unless the packet provides a version, assume that we can continue 134 // Unless the packet provides a version, assume that we can continue
133 // processing using our preferred version. 135 // processing using our preferred version.
134 QuicVersion version = supported_versions_.front(); 136 QuicVersion version = supported_versions_.front();
135 if (header.version_flag) { 137 if (header.version_flag) {
136 QuicVersion packet_version = header.versions.front(); 138 QuicVersion packet_version = header.versions.front();
137 if (framer_.IsSupportedVersion(packet_version)) { 139 if (framer_.IsSupportedVersion(packet_version)) {
138 version = packet_version; 140 version = packet_version;
139 } else { 141 } else {
140 // Packets set to be processed but having an unsupported version will 142 if (FLAGS_quic_stateless_version_negotiation) {
141 // cause a connection to be created. The connection will handle 143 if (ShouldCreateSessionForUnknownVersion(framer_.last_version_tag())) {
142 // sending a version negotiation packet. 144 return true;
143 // TODO(ianswett): This will malfunction if the full header of the packet 145 }
144 // causes a parsing error when parsed using the server's preferred 146 // Since the version is not supported, send a version negotiation
145 // version. 147 // packet and stop processing the current packet.
148 time_wait_list_manager()->SendVersionNegotiationPacket(
149 connection_id, supported_versions_, current_server_address_,
150 current_client_address_);
151 return false;
152 } else {
153 // Packets set to be processed but having an unsupported version will
154 // cause a connection to be created. The connection will handle
155 // sending a version negotiation packet.
156 // TODO(ianswett): This will malfunction if the full header of the
157 // packet causes a parsing error when parsed using the server's
158 // preferred version.
159 }
146 } 160 }
147 } 161 }
148 // Set the framer's version and continue processing. 162 // Set the framer's version and continue processing.
149 framer_.set_version(version); 163 framer_.set_version(version);
150 return true; 164 return true;
151 } 165 }
152 166
153 bool QuicDispatcher::OnUnauthenticatedHeader(const QuicPacketHeader& header) { 167 bool QuicDispatcher::OnUnauthenticatedHeader(const QuicPacketHeader& header) {
154 QuicConnectionId connection_id = header.public_header.connection_id; 168 QuicConnectionId connection_id = header.public_header.connection_id;
155 169
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 341 }
328 342
329 void QuicDispatcher::OnPacket() {} 343 void QuicDispatcher::OnPacket() {}
330 344
331 void QuicDispatcher::OnError(QuicFramer* framer) { 345 void QuicDispatcher::OnError(QuicFramer* framer) {
332 QuicErrorCode error = framer->error(); 346 QuicErrorCode error = framer->error();
333 SetLastError(error); 347 SetLastError(error);
334 DVLOG(1) << QuicUtils::ErrorToString(error); 348 DVLOG(1) << QuicUtils::ErrorToString(error);
335 } 349 }
336 350
351 bool QuicDispatcher::ShouldCreateSessionForUnknownVersion(QuicTag version_tag) {
352 return false;
353 }
354
337 bool QuicDispatcher::OnProtocolVersionMismatch( 355 bool QuicDispatcher::OnProtocolVersionMismatch(
338 QuicVersion /*received_version*/) { 356 QuicVersion /*received_version*/) {
357 if (FLAGS_quic_stateless_version_negotiation) {
358 QUIC_BUG_IF(
359 !time_wait_list_manager_->IsConnectionIdInTimeWait(
360 current_connection_id_) &&
361 !ShouldCreateSessionForUnknownVersion(framer_.last_version_tag()))
362 << "Unexpected version mismatch: "
363 << QuicUtils::TagToString(framer_.last_version_tag());
364 }
365
339 // Keep processing after protocol mismatch - this will be dealt with by the 366 // Keep processing after protocol mismatch - this will be dealt with by the
340 // time wait list or connection that we will create. 367 // time wait list or connection that we will create.
341 return true; 368 return true;
342 } 369 }
343 370
344 void QuicDispatcher::OnPublicResetPacket( 371 void QuicDispatcher::OnPublicResetPacket(
345 const QuicPublicResetPacket& /*packet*/) { 372 const QuicPublicResetPacket& /*packet*/) {
346 DCHECK(false); 373 DCHECK(false);
347 } 374 }
348 375
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 492
466 QuicPacketWriter* QuicDispatcher::CreatePerConnectionWriter() { 493 QuicPacketWriter* QuicDispatcher::CreatePerConnectionWriter() {
467 return new QuicPerConnectionPacketWriter(writer_.get()); 494 return new QuicPerConnectionPacketWriter(writer_.get());
468 } 495 }
469 496
470 void QuicDispatcher::SetLastError(QuicErrorCode error) { 497 void QuicDispatcher::SetLastError(QuicErrorCode error) {
471 last_error_ = error; 498 last_error_ = error;
472 } 499 }
473 500
474 } // namespace net 501 } // 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