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

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

Issue 2850573002: Landing Recent QUIC changes until 3:35 PM, Apr 26, 2017 UTC-4 (Closed)
Patch Set: Remove Disconnect from ~QuicTestClient Created 3 years, 7 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
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_time_wait_list_manager.h" 5 #include "net/tools/quic/quic_time_wait_list_manager.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 if (!WriteToWire(queued_packet)) { 140 if (!WriteToWire(queued_packet)) {
141 return; 141 return;
142 } 142 }
143 pending_packets_queue_.pop_front(); 143 pending_packets_queue_.pop_front();
144 } 144 }
145 } 145 }
146 146
147 void QuicTimeWaitListManager::ProcessPacket( 147 void QuicTimeWaitListManager::ProcessPacket(
148 const QuicSocketAddress& server_address, 148 const QuicSocketAddress& server_address,
149 const QuicSocketAddress& client_address, 149 const QuicSocketAddress& client_address,
150 QuicConnectionId connection_id, 150 QuicConnectionId connection_id) {
151 QuicPacketNumber packet_number,
152 const QuicEncryptedPacket& /*packet*/) {
153 DCHECK(IsConnectionIdInTimeWait(connection_id)); 151 DCHECK(IsConnectionIdInTimeWait(connection_id));
154 QUIC_DLOG(INFO) << "Processing " << connection_id << " in time wait state."; 152 QUIC_DLOG(INFO) << "Processing " << connection_id << " in time wait state.";
155 // TODO(satyamshekhar): Think about handling packets from different client 153 // TODO(satyamshekhar): Think about handling packets from different client
156 // addresses. 154 // addresses.
157 ConnectionIdMap::iterator it = connection_id_map_.find(connection_id); 155 ConnectionIdMap::iterator it = connection_id_map_.find(connection_id);
158 DCHECK(it != connection_id_map_.end()); 156 DCHECK(it != connection_id_map_.end());
159 // Increment the received packet count. 157 // Increment the received packet count.
160 ConnectionIdData* connection_data = &it->second; 158 ConnectionIdData* connection_data = &it->second;
161 ++(connection_data->num_packets); 159 ++(connection_data->num_packets);
162 160
163 if (!ShouldSendResponse(connection_data->num_packets)) { 161 if (!ShouldSendResponse(connection_data->num_packets)) {
164 return; 162 return;
165 } 163 }
166 164
167 if (!connection_data->termination_packets.empty()) { 165 if (!connection_data->termination_packets.empty()) {
168 if (connection_data->connection_rejected_statelessly) { 166 if (connection_data->connection_rejected_statelessly) {
169 QUIC_DVLOG(3) 167 QUIC_DVLOG(3)
170 << "Time wait list sending previous stateless reject response " 168 << "Time wait list sending previous stateless reject response "
171 << "for connection " << connection_id; 169 << "for connection " << connection_id;
172 } 170 }
173 for (const auto& packet : connection_data->termination_packets) { 171 for (const auto& packet : connection_data->termination_packets) {
174 SendOrQueuePacket(QuicMakeUnique<QueuedPacket>( 172 SendOrQueuePacket(QuicMakeUnique<QueuedPacket>(
175 server_address, client_address, packet->Clone())); 173 server_address, client_address, packet->Clone()));
176 } 174 }
177 return; 175 return;
178 } 176 }
179 177
180 SendPublicReset(server_address, client_address, connection_id, packet_number); 178 SendPublicReset(server_address, client_address, connection_id);
181 } 179 }
182 180
183 void QuicTimeWaitListManager::SendVersionNegotiationPacket( 181 void QuicTimeWaitListManager::SendVersionNegotiationPacket(
184 QuicConnectionId connection_id, 182 QuicConnectionId connection_id,
185 const QuicVersionVector& supported_versions, 183 const QuicVersionVector& supported_versions,
186 const QuicSocketAddress& server_address, 184 const QuicSocketAddress& server_address,
187 const QuicSocketAddress& client_address) { 185 const QuicSocketAddress& client_address) {
188 SendOrQueuePacket(QuicMakeUnique<QueuedPacket>( 186 SendOrQueuePacket(QuicMakeUnique<QueuedPacket>(
189 server_address, client_address, QuicFramer::BuildVersionNegotiationPacket( 187 server_address, client_address, QuicFramer::BuildVersionNegotiationPacket(
190 connection_id, supported_versions))); 188 connection_id, supported_versions)));
191 } 189 }
192 190
193 // Returns true if the number of packets received for this connection_id is a 191 // Returns true if the number of packets received for this connection_id is a
194 // power of 2 to throttle the number of public reset packets we send to a 192 // power of 2 to throttle the number of public reset packets we send to a
195 // client. 193 // client.
196 bool QuicTimeWaitListManager::ShouldSendResponse(int received_packet_count) { 194 bool QuicTimeWaitListManager::ShouldSendResponse(int received_packet_count) {
197 return (received_packet_count & (received_packet_count - 1)) == 0; 195 return (received_packet_count & (received_packet_count - 1)) == 0;
198 } 196 }
199 197
200 void QuicTimeWaitListManager::SendPublicReset( 198 void QuicTimeWaitListManager::SendPublicReset(
201 const QuicSocketAddress& server_address, 199 const QuicSocketAddress& server_address,
202 const QuicSocketAddress& client_address, 200 const QuicSocketAddress& client_address,
203 QuicConnectionId connection_id, 201 QuicConnectionId connection_id) {
204 QuicPacketNumber rejected_packet_number) {
205 QuicPublicResetPacket packet; 202 QuicPublicResetPacket packet;
206 packet.public_header.connection_id = connection_id; 203 packet.public_header.connection_id = connection_id;
207 packet.public_header.reset_flag = true; 204 packet.public_header.reset_flag = true;
208 packet.public_header.version_flag = false; 205 packet.public_header.version_flag = false;
209 packet.rejected_packet_number = rejected_packet_number;
210 // TODO(satyamshekhar): generate a valid nonce for this connection_id. 206 // TODO(satyamshekhar): generate a valid nonce for this connection_id.
211 packet.nonce_proof = 1010101; 207 packet.nonce_proof = 1010101;
212 packet.client_address = client_address; 208 packet.client_address = client_address;
213 // Takes ownership of the packet. 209 // Takes ownership of the packet.
214 SendOrQueuePacket(QuicMakeUnique<QueuedPacket>(server_address, client_address, 210 SendOrQueuePacket(QuicMakeUnique<QueuedPacket>(server_address, client_address,
215 BuildPublicReset(packet))); 211 BuildPublicReset(packet)));
216 } 212 }
217 213
218 std::unique_ptr<QuicEncryptedPacket> QuicTimeWaitListManager::BuildPublicReset( 214 std::unique_ptr<QuicEncryptedPacket> QuicTimeWaitListManager::BuildPublicReset(
219 const QuicPublicResetPacket& packet) { 215 const QuicPublicResetPacket& packet) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 version(version_), 316 version(version_),
321 time_added(time_added_), 317 time_added(time_added_),
322 connection_rejected_statelessly(connection_rejected_statelessly) {} 318 connection_rejected_statelessly(connection_rejected_statelessly) {}
323 319
324 QuicTimeWaitListManager::ConnectionIdData::ConnectionIdData( 320 QuicTimeWaitListManager::ConnectionIdData::ConnectionIdData(
325 ConnectionIdData&& other) = default; 321 ConnectionIdData&& other) = default;
326 322
327 QuicTimeWaitListManager::ConnectionIdData::~ConnectionIdData() {} 323 QuicTimeWaitListManager::ConnectionIdData::~ConnectionIdData() {}
328 324
329 } // namespace net 325 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_time_wait_list_manager.h ('k') | net/tools/quic/quic_time_wait_list_manager_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698