OLD | NEW |
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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 if (time_wait_list_manager_->IsConnectionIdInTimeWait( | 318 if (time_wait_list_manager_->IsConnectionIdInTimeWait( |
319 header.public_header.connection_id)) { | 319 header.public_header.connection_id)) { |
320 // This connection ID is already in time-wait state. | 320 // This connection ID is already in time-wait state. |
321 time_wait_list_manager_->ProcessPacket( | 321 time_wait_list_manager_->ProcessPacket( |
322 current_server_address_, current_client_address_, | 322 current_server_address_, current_client_address_, |
323 header.public_header.connection_id, header.packet_number, | 323 header.public_header.connection_id, header.packet_number, |
324 *current_packet_); | 324 *current_packet_); |
325 return false; | 325 return false; |
326 } | 326 } |
327 | 327 |
328 // Packet's connection ID is unknown. | 328 // Packet's connection ID is unknown. Apply the validity checks. |
329 // Apply the validity checks. | |
330 QuicPacketFate fate = ValidityChecks(header); | 329 QuicPacketFate fate = ValidityChecks(header); |
331 if (fate == kFateProcess) { | 330 if (fate == kFateProcess) { |
332 fate = MaybeRejectStatelessly(connection_id, header); | 331 fate = MaybeRejectStatelessly(connection_id, header); |
333 } | 332 } |
| 333 |
| 334 // Perform whatever actions are needed on the current packet. |
| 335 ProcessUnauthenticatedHeaderFate(fate, connection_id, header.packet_number); |
| 336 return false; |
| 337 } |
| 338 |
| 339 void QuicDispatcher::ProcessUnauthenticatedHeaderFate( |
| 340 QuicPacketFate fate, |
| 341 QuicConnectionId connection_id, |
| 342 QuicPacketNumber packet_number) { |
334 switch (fate) { | 343 switch (fate) { |
335 case kFateProcess: { | 344 case kFateProcess: { |
336 ProcessChlo(); | 345 ProcessChlo(); |
337 break; | 346 break; |
338 } | 347 } |
339 case kFateTimeWait: | 348 case kFateTimeWait: |
340 // MaybeRejectStatelessly might have already added the connection to | 349 // MaybeRejectStatelessly might have already added the connection to |
341 // time wait, in which case it should not be added again. | 350 // time wait, in which case it should not be added again. |
342 if (!FLAGS_quic_use_cheap_stateless_rejects || | 351 if (!FLAGS_quic_use_cheap_stateless_rejects || |
343 !time_wait_list_manager_->IsConnectionIdInTimeWait( | 352 !time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) { |
344 header.public_header.connection_id)) { | |
345 // Add this connection_id to the time-wait state, to safely reject | 353 // Add this connection_id to the time-wait state, to safely reject |
346 // future packets. | 354 // future packets. |
347 DVLOG(1) << "Adding connection ID " << connection_id | 355 DVLOG(1) << "Adding connection ID " << connection_id |
348 << "to time-wait list."; | 356 << "to time-wait list."; |
349 time_wait_list_manager_->AddConnectionIdToTimeWait( | 357 time_wait_list_manager_->AddConnectionIdToTimeWait( |
350 connection_id, framer_.version(), | 358 connection_id, framer_.version(), |
351 /*connection_rejected_statelessly=*/false, nullptr); | 359 /*connection_rejected_statelessly=*/false, nullptr); |
352 } | 360 } |
353 DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait( | 361 DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); |
354 header.public_header.connection_id)); | |
355 time_wait_list_manager_->ProcessPacket( | 362 time_wait_list_manager_->ProcessPacket( |
356 current_server_address_, current_client_address_, | 363 current_server_address_, current_client_address_, connection_id, |
357 header.public_header.connection_id, header.packet_number, | 364 packet_number, *current_packet_); |
358 *current_packet_); | |
359 break; | 365 break; |
360 case kFateBuffer: | 366 case kFateBuffer: |
361 // This packet is a non-CHLO packet which has arrived out of order. | 367 // This packet is a non-CHLO packet which has arrived out of order. |
362 // Buffer it. | 368 // Buffer it. |
363 BufferEarlyPacket(connection_id); | 369 BufferEarlyPacket(connection_id); |
364 break; | 370 break; |
365 case kFateDrop: | 371 case kFateDrop: |
366 // Do nothing with the packet. | 372 // Do nothing with the packet. |
367 break; | 373 break; |
368 } | 374 } |
369 | |
370 return false; | |
371 } | 375 } |
372 | 376 |
373 QuicDispatcher::QuicPacketFate QuicDispatcher::ValidityChecks( | 377 QuicDispatcher::QuicPacketFate QuicDispatcher::ValidityChecks( |
374 const QuicPacketHeader& header) { | 378 const QuicPacketHeader& header) { |
375 // To have all the checks work properly without tears, insert any new check | 379 // To have all the checks work properly without tears, insert any new check |
376 // into the framework of this method in the section for checks that return the | 380 // into the framework of this method in the section for checks that return the |
377 // check's fate value. The sections for checks must be ordered with the | 381 // check's fate value. The sections for checks must be ordered with the |
378 // highest priority fate first. | 382 // highest priority fate first. |
379 | 383 |
380 // Checks that return kFateDrop. | 384 // Checks that return kFateDrop. |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 void QuicDispatcher::DeliverPacketsToSession( | 849 void QuicDispatcher::DeliverPacketsToSession( |
846 const std::list<BufferedPacket>& packets, | 850 const std::list<BufferedPacket>& packets, |
847 QuicServerSessionBase* session) { | 851 QuicServerSessionBase* session) { |
848 for (const BufferedPacket& packet : packets) { | 852 for (const BufferedPacket& packet : packets) { |
849 session->ProcessUdpPacket(packet.server_address, packet.client_address, | 853 session->ProcessUdpPacket(packet.server_address, packet.client_address, |
850 *(packet.packet)); | 854 *(packet.packet)); |
851 } | 855 } |
852 } | 856 } |
853 | 857 |
854 } // namespace net | 858 } // namespace net |
OLD | NEW |