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

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


The following commit(s) were added to refs/heads/quic-latest by this push:
     new 20e97be  Set new endpoint to QNetVC when connection migration happens
20e97be is described below

commit 20e97be78d145efbf8eca927add0684332767a81
Author: Masakazu Kitajo <mas...@apache.org>
AuthorDate: Mon Apr 9 12:11:58 2018 +0900

    Set new endpoint to QNetVC when connection migration happens
---
 iocore/net/QUICNetVConnection.cc               |  6 +++++-
 iocore/net/quic/QUICPacket.cc                  | 23 ++++++++++++++++++-----
 iocore/net/quic/QUICPacket.h                   | 25 +++++++++++++++++++------
 iocore/net/quic/test/test_QUICPacket.cc        |  6 +++---
 iocore/net/quic/test/test_QUICPacketFactory.cc |  2 +-
 5 files changed, 46 insertions(+), 16 deletions(-)

diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 58f368d..4ad106c 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -922,6 +922,9 @@ QUICNetVConnection::_state_common_receive_packet()
           // TODO Address Validation
           // TODO Adjust expected packet number with a gap computed based on 
info.seq_num
           this->_quic_connection_id = p->connection_id();
+          Connection con;
+          con.setRemote(&p->from().sa);
+          this->con.move(con);
         } else {
           // TODO Send some error?
         }
@@ -1392,7 +1395,8 @@ 
QUICNetVConnection::_dequeue_recv_packet(QUICPacketCreationResult &result)
   }
   udp_packet->free();
 
-  quic_packet = this->_packet_factory.create(std::move(pkt), written, 
this->largest_received_packet_number(), result);
+  quic_packet =
+    this->_packet_factory.create(udp_packet->from, std::move(pkt), written, 
this->largest_received_packet_number(), result);
   switch (result) {
   case QUICPacketCreationResult::NOT_READY:
     QUICConDebug("Not ready to decrypt the packet");
diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index 380cbe8..9f3f588 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -56,6 +56,12 @@ QUICPacketHeader::buf()
   }
 }
 
+const IpEndpoint &
+QUICPacketHeader::from() const
+{
+  return this->_from;
+}
+
 uint16_t
 QUICPacketHeader::packet_size() const
 {
@@ -63,16 +69,16 @@ QUICPacketHeader::packet_size() const
 }
 
 QUICPacketHeaderUPtr
-QUICPacketHeader::load(ats_unique_buf buf, size_t len, QUICPacketNumber base)
+QUICPacketHeader::load(const IpEndpoint from, ats_unique_buf buf, size_t len, 
QUICPacketNumber base)
 {
   QUICPacketHeaderUPtr header = QUICPacketHeaderUPtr(nullptr, 
&QUICPacketHeaderDeleter::delete_null_header);
   if (QUICTypeUtil::has_long_header(buf.get())) {
     QUICPacketLongHeader *long_header = quicPacketLongHeaderAllocator.alloc();
-    new (long_header) QUICPacketLongHeader(std::move(buf), len, base);
+    new (long_header) QUICPacketLongHeader(from, std::move(buf), len, base);
     header = QUICPacketHeaderUPtr(long_header, 
&QUICPacketHeaderDeleter::delete_long_header);
   } else {
     QUICPacketShortHeader *short_header = 
quicPacketShortHeaderAllocator.alloc();
-    new (short_header) QUICPacketShortHeader(std::move(buf), len, base);
+    new (short_header) QUICPacketShortHeader(from, std::move(buf), len, base);
     header = QUICPacketHeaderUPtr(short_header, 
&QUICPacketHeaderDeleter::delete_short_header);
   }
   return header;
@@ -507,6 +513,12 @@ QUICPacket::~QUICPacket()
   this->_header = nullptr;
 }
 
+const IpEndpoint &
+QUICPacket::from() const
+{
+  return this->_header->from();
+}
+
 /**
  * When packet is "Short Header Packet", QUICPacket::type() will return 1-RTT 
Protected (key phase 0)
  * or 1-RTT Protected (key phase 1)
@@ -665,13 +677,14 @@ QUICPacketFactory::create_null_packet()
 }
 
 QUICPacketUPtr
-QUICPacketFactory::create(ats_unique_buf buf, size_t len, QUICPacketNumber 
base_packet_number, QUICPacketCreationResult &result)
+QUICPacketFactory::create(IpEndpoint from, ats_unique_buf buf, size_t len, 
QUICPacketNumber base_packet_number,
+                          QUICPacketCreationResult &result)
 {
   size_t max_plain_txt_len = 2048;
   ats_unique_buf plain_txt = ats_unique_malloc(max_plain_txt_len);
   size_t plain_txt_len     = 0;
 
-  QUICPacketHeaderUPtr header = QUICPacketHeader::load(std::move(buf), len, 
base_packet_number);
+  QUICPacketHeaderUPtr header = QUICPacketHeader::load(from, std::move(buf), 
len, base_packet_number);
 
   if (header->has_version() && 
!QUICTypeUtil::is_supported_version(header->version())) {
     if (header->type() == QUICPacketType::VERSION_NEGOTIATION) {
diff --git a/iocore/net/quic/QUICPacket.h b/iocore/net/quic/QUICPacket.h
index 6a87d1e..8ec0845 100644
--- a/iocore/net/quic/QUICPacket.h
+++ b/iocore/net/quic/QUICPacket.h
@@ -52,12 +52,15 @@ using QUICPacketHeaderUPtr        = 
std::unique_ptr<QUICPacketHeader, QUICPacket
 class QUICPacketHeader
 {
 public:
-  QUICPacketHeader(ats_unique_buf buf, size_t len, QUICPacketNumber base)
-    : _buf(std::move(buf)), _buf_len(len), _base_packet_number(base)
+  QUICPacketHeader(const IpEndpoint from, ats_unique_buf buf, size_t len, 
QUICPacketNumber base)
+    : _from(from), _buf(std::move(buf)), _buf_len(len), 
_base_packet_number(base)
   {
   }
   ~QUICPacketHeader() {}
   const uint8_t *buf();
+
+  const IpEndpoint &from() const;
+
   virtual QUICPacketType type() const            = 0;
   virtual QUICConnectionId connection_id() const = 0;
   virtual QUICPacketNumber packet_number() const = 0;
@@ -108,7 +111,7 @@ public:
    *
    * This creates either a QUICPacketShortHeader or a QUICPacketLongHeader.
    */
-  static QUICPacketHeaderUPtr load(ats_unique_buf buf, size_t len, 
QUICPacketNumber base);
+  static QUICPacketHeaderUPtr load(const IpEndpoint from, ats_unique_buf buf, 
size_t len, QUICPacketNumber base);
 
   /*
    * Build a QUICPacketHeader
@@ -138,6 +141,8 @@ public:
 protected:
   QUICPacketHeader(){};
 
+  const IpEndpoint _from = {};
+
   // These two are used only if the instance was created with a buffer
   ats_unique_buf _buf = {nullptr, [](void *p) { ats_free(p); }};
   size_t _buf_len     = 0;
@@ -162,7 +167,10 @@ class QUICPacketLongHeader : public QUICPacketHeader
 public:
   QUICPacketLongHeader() : QUICPacketHeader(){};
   virtual ~QUICPacketLongHeader(){};
-  QUICPacketLongHeader(ats_unique_buf buf, size_t len, QUICPacketNumber base) 
: QUICPacketHeader(std::move(buf), len, base) {}
+  QUICPacketLongHeader(const IpEndpoint from, ats_unique_buf buf, size_t len, 
QUICPacketNumber base)
+    : QUICPacketHeader(from, std::move(buf), len, base)
+  {
+  }
   QUICPacketLongHeader(QUICPacketType type, QUICConnectionId connection_id, 
QUICPacketNumber packet_number,
                        QUICPacketNumber base_packet_number, QUICVersion 
version, ats_unique_buf buf, size_t len);
   QUICPacketType type() const;
@@ -183,7 +191,10 @@ class QUICPacketShortHeader : public QUICPacketHeader
 public:
   QUICPacketShortHeader() : QUICPacketHeader(){};
   virtual ~QUICPacketShortHeader(){};
-  QUICPacketShortHeader(ats_unique_buf buf, size_t len, QUICPacketNumber base) 
: QUICPacketHeader(std::move(buf), len, base) {}
+  QUICPacketShortHeader(const IpEndpoint from, ats_unique_buf buf, size_t len, 
QUICPacketNumber base)
+    : QUICPacketHeader(from, std::move(buf), len, base)
+  {
+  }
   QUICPacketShortHeader(QUICPacketType type, QUICKeyPhase key_phase, 
QUICPacketNumber packet_number,
                         QUICPacketNumber base_packet_number, ats_unique_buf 
buf, size_t len);
   QUICPacketShortHeader(QUICPacketType type, QUICKeyPhase key_phase, 
QUICConnectionId connection_id, QUICPacketNumber packet_number,
@@ -258,6 +269,7 @@ public:
 
   ~QUICPacket();
 
+  const IpEndpoint &from() const;
   QUICPacketType type() const;
   QUICConnectionId connection_id() const;
   QUICPacketNumber packet_number() const;
@@ -338,7 +350,8 @@ class QUICPacketFactory
 public:
   static QUICPacketUPtr create_null_packet();
 
-  QUICPacketUPtr create(ats_unique_buf buf, size_t len, QUICPacketNumber 
base_packet_number, QUICPacketCreationResult &result);
+  QUICPacketUPtr create(IpEndpoint from, ats_unique_buf buf, size_t len, 
QUICPacketNumber base_packet_number,
+                        QUICPacketCreationResult &result);
   QUICPacketUPtr create_version_negotiation_packet(const QUICPacket 
*packet_sent_by_client);
   QUICPacketUPtr create_initial_packet(QUICConnectionId connection_id, 
QUICPacketNumber base_packet_number, ats_unique_buf payload,
                                        size_t len);
diff --git a/iocore/net/quic/test/test_QUICPacket.cc 
b/iocore/net/quic/test/test_QUICPacket.cc
index 3b95181..019bb21 100644
--- a/iocore/net/quic/test/test_QUICPacket.cc
+++ b/iocore/net/quic/test/test_QUICPacket.cc
@@ -37,7 +37,7 @@ TEST_CASE("QUICPacketHeader - Long", "[quic]")
       0x00, 0x00, 0x00, 0x09,                         // Supported Version 1
     };
 
-    QUICPacketHeaderUPtr header = QUICPacketHeader::load({const_cast<uint8_t 
*>(input), [](void *p) {}}, sizeof(input), 0);
+    QUICPacketHeaderUPtr header = QUICPacketHeader::load({}, 
{const_cast<uint8_t *>(input), [](void *p) {}}, sizeof(input), 0);
     CHECK(header->size() == 13);
     CHECK(header->packet_size() == 21);
     CHECK(header->type() == QUICPacketType::VERSION_NEGOTIATION);
@@ -58,7 +58,7 @@ TEST_CASE("QUICPacketHeader - Long", "[quic]")
       0xff, 0xff,                                     // Payload (dummy)
     };
 
-    QUICPacketHeaderUPtr header = QUICPacketHeader::load({const_cast<uint8_t 
*>(input), [](void *p) {}}, sizeof(input), 0);
+    QUICPacketHeaderUPtr header = QUICPacketHeader::load({}, 
{const_cast<uint8_t *>(input), [](void *p) {}}, sizeof(input), 0);
     CHECK(header->size() == 17);
     CHECK(header->packet_size() == 19);
     CHECK(header->type() == QUICPacketType::INITIAL);
@@ -115,7 +115,7 @@ TEST_CASE("QUICPacketHeader - Short", "[quic]")
       0xff, 0xff,                                     // Payload (dummy)
     };
 
-    QUICPacketHeaderUPtr header = QUICPacketHeader::load({const_cast<uint8_t 
*>(input), [](void *p) {}}, sizeof(input), 0);
+    QUICPacketHeaderUPtr header = QUICPacketHeader::load({}, 
{const_cast<uint8_t *>(input), [](void *p) {}}, sizeof(input), 0);
     CHECK(header->size() == 13);
     CHECK(header->packet_size() == 15);
     CHECK(header->has_key_phase() == true);
diff --git a/iocore/net/quic/test/test_QUICPacketFactory.cc 
b/iocore/net/quic/test/test_QUICPacketFactory.cc
index e0be9f1..8fcb9d8 100644
--- a/iocore/net/quic/test/test_QUICPacketFactory.cc
+++ b/iocore/net/quic/test/test_QUICPacketFactory.cc
@@ -42,7 +42,7 @@ 
TEST_CASE("QUICPacketFactory_Create_VersionNegotiationPacket", "[quic]")
     0x00 // Payload
   };
 
-  QUICPacketHeaderUPtr header = QUICPacketHeader::load({initial_packet_header, 
[](void *) {}}, sizeof(initial_packet_header), 0);
+  QUICPacketHeaderUPtr header = QUICPacketHeader::load({}, 
{initial_packet_header, [](void *) {}}, sizeof(initial_packet_header), 0);
   QUICPacket initial_packet(std::move(header), 
ats_unique_buf(initial_packet_payload, [](void *) {}),
                             sizeof(initial_packet_payload), 0);
 

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

Reply via email to