You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2018/04/05 03:22:01 UTC

[trafficserver] 01/02: Start handshake over when qvc received VERSION NEGOTIATION packet

This is an automated email from the ASF dual-hosted git repository.

masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 5c7db9f3f6a9b68954798d07acb7a90eaff2dca5
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Thu Apr 5 11:08:26 2018 +0900

    Start handshake over when qvc received VERSION NEGOTIATION packet
---
 iocore/net/QUICNetVConnection.cc | 22 +++++++++++++++++++---
 iocore/net/quic/QUICHandshake.cc | 10 ++++++++++
 iocore/net/quic/QUICHandshake.h  |  1 +
 3 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 6ea5de4..e55e524 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -819,7 +819,16 @@ QUICNetVConnection::_state_handshake_process_version_negotiation_packet(QUICPack
   }
 
   error = this->_handshake_handler->negotiate_version(packet.get(), &this->_packet_factory);
-  // Initial packet will be retransmited with negotiated version
+
+  // discard all transport state except packet number
+  this->_stream_manager->reset_send_offset();
+  this->_stream_manager->reset_recv_offset();
+  this->_loss_detector->reset();
+
+  // start handshake over
+  this->_handshake_handler->reset();
+  this->_handshake_handler->handleEvent(VC_EVENT_WRITE_READY, nullptr);
+  this->_schedule_packet_write_ready();
 
   return error;
 }
@@ -1234,6 +1243,7 @@ QUICNetVConnection::_build_packet(ats_unique_buf buf, size_t len, bool retransmi
   // TODO: support NET_VCONNECTION_IN
   if (this->get_context() == NET_VCONNECTION_OUT && type == QUICPacketType::UNINITIALIZED) {
     if (this->_last_received_packet_type == QUICPacketType::UNINITIALIZED ||
+        this->_last_received_packet_type == QUICPacketType::VERSION_NEGOTIATION ||
         this->_last_received_packet_type == QUICPacketType::RETRY) {
       type = QUICPacketType::INITIAL;
     } else if (_last_received_packet_type == QUICPacketType::HANDSHAKE) {
@@ -1377,9 +1387,15 @@ QUICNetVConnection::_dequeue_recv_packet(QUICPacketCreationResult &result)
     QUICConDebug("Unsupported version");
     break;
   case QUICPacketCreationResult::SUCCESS:
-    QUICConDebug("Dequeue %s pkt_num=%" PRIu64 " size=%u", QUICDebugNames::packet_type(quic_packet->type()),
-                 quic_packet->packet_number(), quic_packet->size());
     this->_last_received_packet_type = quic_packet->type();
+
+    if (quic_packet->type() == QUICPacketType::VERSION_NEGOTIATION) {
+      QUICConDebug("Dequeue %s size=%u", QUICDebugNames::packet_type(quic_packet->type()), quic_packet->size());
+    } else {
+      QUICConDebug("Dequeue %s pkt_num=%" PRIu64 " size=%u", QUICDebugNames::packet_type(quic_packet->type()),
+                   quic_packet->packet_number(), quic_packet->size());
+    }
+
     break;
   default:
     QUICConDebug("Failed to decrypt the packet");
diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc
index 5d2484e..94b431e 100644
--- a/iocore/net/quic/QUICHandshake.cc
+++ b/iocore/net/quic/QUICHandshake.cc
@@ -374,6 +374,16 @@ QUICHandshake::msg_type() const
   }
 }
 
+/**
+ * reset states for starting over
+ */
+void
+QUICHandshake::reset()
+{
+  this->_initial = true;
+  SSL_clear(this->_ssl);
+}
+
 void
 QUICHandshake::_load_local_server_transport_parameters(QUICVersion negotiated_version)
 {
diff --git a/iocore/net/quic/QUICHandshake.h b/iocore/net/quic/QUICHandshake.h
index 37e316e..5274a66 100644
--- a/iocore/net/quic/QUICHandshake.h
+++ b/iocore/net/quic/QUICHandshake.h
@@ -54,6 +54,7 @@ public:
   // for client side
   QUICErrorUPtr start(QUICPacketFactory *packet_factory, bool vn_exercise_enabled);
   QUICErrorUPtr negotiate_version(const QUICPacket *packet, QUICPacketFactory *packet_factory);
+  void reset();
 
   // for server side
   QUICErrorUPtr start(const QUICPacket *initial_packet, QUICPacketFactory *packet_factory);

-- 
To stop receiving notification emails like this one, please contact
masaori@apache.org.