Index: net/tools/quic/quic_dispatcher.cc |
diff --git a/net/tools/quic/quic_dispatcher.cc b/net/tools/quic/quic_dispatcher.cc |
index bcfd92b4c8d66f3e79781270c8577e4781678056..a4d43cdd1cb9dcf86c2354585234f7a21466b40b 100644 |
--- a/net/tools/quic/quic_dispatcher.cc |
+++ b/net/tools/quic/quic_dispatcher.cc |
@@ -90,6 +90,8 @@ void QuicDispatcher::ProcessPacket(const IPEndPoint& server_address, |
bool QuicDispatcher::OnUnauthenticatedPublicHeader( |
const QuicPacketPublicHeader& header) { |
+ current_connection_id_ = header.connection_id; |
+ |
// Port zero is only allowed for unidirectional UDP, so is disallowed by QUIC. |
// Given that we can't even send a reply rejecting the packet, just drop the |
// packet. |
@@ -137,12 +139,22 @@ bool QuicDispatcher::OnUnauthenticatedPublicHeader( |
if (framer_.IsSupportedVersion(packet_version)) { |
version = packet_version; |
} else { |
- // Packets set to be processed but having an unsupported version will |
- // cause a connection to be created. The connection will handle |
- // sending a version negotiation packet. |
- // TODO(ianswett): This will malfunction if the full header of the packet |
- // causes a parsing error when parsed using the server's preferred |
- // version. |
+ if (FLAGS_quic_stateless_version_negotiation) { |
+ DVLOG(1) << "Version mismatch, connection ID " << connection_id; |
+ // Since the version is not supported, send a version negotiation |
+ // packet and stop processing the current packet. |
+ time_wait_list_manager()->SendVersionNegotiationPacket( |
+ connection_id, supported_versions_, current_server_address_, |
+ current_client_address_); |
+ return false; |
+ } else { |
+ // Packets set to be processed but having an unsupported version will |
+ // cause a connection to be created. The connection will handle |
+ // sending a version negotiation packet. |
+ // TODO(ianswett): This will malfunction if the full header of the |
+ // packet causes a parsing error when parsed using the server's |
+ // preferred version. |
+ } |
} |
} |
// Set the framer's version and continue processing. |
@@ -336,6 +348,11 @@ void QuicDispatcher::OnError(QuicFramer* framer) { |
bool QuicDispatcher::OnProtocolVersionMismatch( |
QuicVersion /*received_version*/) { |
+ if (FLAGS_quic_stateless_version_negotiation) { |
+ QUIC_BUG_IF(!time_wait_list_manager_->IsConnectionIdInTimeWait( |
+ current_connection_id_)); |
+ } |
+ |
// Keep processing after protocol mismatch - this will be dealt with by the |
// time wait list or connection that we will create. |
return true; |