trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mas...@apache.org
Subject [trafficserver] branch quic-latest updated: Add support for MAX_STREAM_ID frame and initial_max_stream_id transport parameter
Date Tue, 12 Sep 2017 08:37:19 GMT
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 27899d8  Add support for MAX_STREAM_ID frame and initial_max_stream_id transport
parameter
27899d8 is described below

commit 27899d856fef2cfedf62eb9deec0e7b8a41348df
Author: Masakazu Kitajo <maskit@apache.org>
AuthorDate: Tue Sep 12 17:36:08 2017 +0900

    Add support for MAX_STREAM_ID frame and initial_max_stream_id transport parameter
---
 iocore/net/quic/QUICStreamManager.cc           | 64 +++++++++++++++++++-------
 iocore/net/quic/QUICStreamManager.h            |  4 ++
 iocore/net/quic/test/test_QUICStreamManager.cc |  6 +++
 3 files changed, 57 insertions(+), 17 deletions(-)

diff --git a/iocore/net/quic/QUICStreamManager.cc b/iocore/net/quic/QUICStreamManager.cc
index ca789e5..24f8fb8 100644
--- a/iocore/net/quic/QUICStreamManager.cc
+++ b/iocore/net/quic/QUICStreamManager.cc
@@ -40,7 +40,7 @@ std::vector<QUICFrameType>
 QUICStreamManager::interests()
 {
   return {
-    QUICFrameType::STREAM, QUICFrameType::RST_STREAM, QUICFrameType::MAX_STREAM_DATA,
+    QUICFrameType::STREAM, QUICFrameType::RST_STREAM, QUICFrameType::MAX_STREAM_DATA, QUICFrameType::MAX_STREAM_ID,
   };
 }
 
@@ -64,6 +64,25 @@ QUICStreamManager::init_flow_control_params(const std::shared_ptr<const
QUICTran
     }
     stream->init_flow_control_params(local_initial_max_stream_data, remote_initial_max_stream_data);
   }
+
+  uint16_t len;
+  const uint8_t *tp_value;
+  if (this->_local_tp) {
+    tp_value                       = this->_local_tp->get(QUICTransportParameterId::INITIAL_MAX_STREAM_ID,
len);
+    this->_local_maximum_stream_id = QUICTypeUtil::read_QUICStreamId(tp_value, len);
+  }
+  if (this->_remote_tp) {
+    tp_value                        = this->_remote_tp->get(QUICTransportParameterId::INITIAL_MAX_STREAM_ID,
len);
+    this->_remote_maximum_stream_id = QUICTypeUtil::read_QUICStreamId(tp_value, len);
+  }
+}
+
+void
+QUICStreamManager::set_max_stream_id(QUICStreamId id)
+{
+  if (this->_local_maximum_stream_id <= id) {
+    this->_local_maximum_stream_id = id;
+  }
 }
 
 QUICError
@@ -72,20 +91,21 @@ QUICStreamManager::handle_frame(std::shared_ptr<const QUICFrame>
frame)
   QUICError error = QUICError(QUICErrorClass::NONE);
 
   switch (frame->type()) {
-  case QUICFrameType::MAX_STREAM_DATA: {
-    error = this->_handle_frame(std::dynamic_pointer_cast<const QUICMaxStreamDataFrame>(frame));
+  case QUICFrameType::MAX_STREAM_DATA:
+    error = this->_handle_frame(std::static_pointer_cast<const QUICMaxStreamDataFrame>(frame));
     break;
-  }
-  case QUICFrameType::STREAM_BLOCKED: {
+  case QUICFrameType::STREAM_BLOCKED:
     // STREAM_BLOCKED frame is for debugging. Just propagate to streams
-    error = this->_handle_frame(std::dynamic_pointer_cast<const QUICStreamBlockedFrame>(frame));
+    error = this->_handle_frame(std::static_pointer_cast<const QUICStreamBlockedFrame>(frame));
     break;
-  }
   case QUICFrameType::STREAM:
-    error = this->_handle_frame(std::dynamic_pointer_cast<const QUICStreamFrame>(frame));
+    error = this->_handle_frame(std::static_pointer_cast<const QUICStreamFrame>(frame));
     break;
   case QUICFrameType::RST_STREAM:
-    error = this->_handle_frame(std::dynamic_pointer_cast<const QUICRstStreamFrame>(frame));
+    error = this->_handle_frame(std::static_pointer_cast<const QUICRstStreamFrame>(frame));
+    break;
+  case QUICFrameType::MAX_STREAM_ID:
+    error = this->_handle_frame(std::static_pointer_cast<const QUICMaxStreamIdFrame>(frame));
     break;
   default:
     Debug(tag, "Unexpected frame type: %02x", static_cast<unsigned int>(frame->type()));
@@ -103,10 +123,8 @@ QUICStreamManager::_handle_frame(const std::shared_ptr<const QUICMaxStreamDataFr
   if (stream) {
     return stream->recv(frame);
   } else {
-    // TODO: connection error?
+    return QUICError(QUICErrorClass::QUIC_TRANSPORT, QUICErrorCode::STREAM_ID_ERROR);
   }
-
-  return QUICError(QUICErrorClass::NONE);
 }
 
 QUICError
@@ -116,16 +134,18 @@ QUICStreamManager::_handle_frame(const std::shared_ptr<const QUICStreamBlockedFr
   if (stream) {
     return stream->recv(frame);
   } else {
-    // TODO: connection error?
+    return QUICError(QUICErrorClass::QUIC_TRANSPORT, QUICErrorCode::STREAM_ID_ERROR);
   }
-
-  return QUICError(QUICErrorClass::NONE);
 }
 
 QUICError
 QUICStreamManager::_handle_frame(const std::shared_ptr<const QUICStreamFrame> &frame)
 {
-  QUICStream *stream           = this->_find_or_create_stream(frame->stream_id());
+  QUICStream *stream = this->_find_or_create_stream(frame->stream_id());
+  if (!stream) {
+    return QUICError(QUICErrorClass::QUIC_TRANSPORT, QUICErrorCode::STREAM_ID_ERROR);
+  }
+
   QUICApplication *application = this->_app_map->get(frame->stream_id());
 
   if (!application->is_stream_set(stream)) {
@@ -148,10 +168,16 @@ QUICStreamManager::_handle_frame(const std::shared_ptr<const QUICRstStreamFrame>
   QUICStream *stream = this->_find_or_create_stream(frame->stream_id());
   if (stream) {
     // TODO Reset the stream
+    return QUICError(QUICErrorClass::NONE);
   } else {
-    // TODO: connection error?
+    return QUICError(QUICErrorClass::QUIC_TRANSPORT, QUICErrorCode::STREAM_ID_ERROR);
   }
+}
 
+QUICError
+QUICStreamManager::_handle_frame(const std::shared_ptr<const QUICMaxStreamIdFrame>
&frame)
+{
+  this->_remote_maximum_stream_id = frame->maximum_stream_id();
   return QUICError(QUICErrorClass::NONE);
 }
 
@@ -171,6 +197,10 @@ QUICStreamManager::_find_or_create_stream(QUICStreamId stream_id)
 {
   QUICStream *stream = this->_find_stream(stream_id);
   if (!stream) {
+    if ((stream_id > this->_local_maximum_stream_id && this->_local_maximum_stream_id
!= 0) ||
+        (stream_id > this->_remote_maximum_stream_id && this->_remote_maximum_stream_id
!= 0)) {
+      return nullptr;
+    }
     // TODO Free the stream somewhere
     stream = new (THREAD_ALLOC(quicStreamAllocator, this_ethread())) QUICStream();
     if (stream_id == STREAM_ID_FOR_HANDSHAKE) {
diff --git a/iocore/net/quic/QUICStreamManager.h b/iocore/net/quic/QUICStreamManager.h
index 40753d4..3fa81ef 100644
--- a/iocore/net/quic/QUICStreamManager.h
+++ b/iocore/net/quic/QUICStreamManager.h
@@ -40,6 +40,7 @@ public:
 
   void init_flow_control_params(const std::shared_ptr<const QUICTransportParameters>
&local_tp,
                                 const std::shared_ptr<const QUICTransportParameters>
&remote_tp);
+  void set_max_stream_id(QUICStreamId id);
   uint64_t total_offset_received() const;
   uint64_t total_offset_sent() const;
   uint32_t stream_count() const;
@@ -57,9 +58,12 @@ private:
   QUICError _handle_frame(const std::shared_ptr<const QUICRstStreamFrame> &);
   QUICError _handle_frame(const std::shared_ptr<const QUICMaxStreamDataFrame> &);
   QUICError _handle_frame(const std::shared_ptr<const QUICStreamBlockedFrame> &);
+  QUICError _handle_frame(const std::shared_ptr<const QUICMaxStreamIdFrame> &);
 
   QUICFrameTransmitter *_tx                                 = nullptr;
   QUICApplicationMap *_app_map                              = nullptr;
   std::shared_ptr<const QUICTransportParameters> _local_tp  = nullptr;
   std::shared_ptr<const QUICTransportParameters> _remote_tp = nullptr;
+  QUICStreamId _local_maximum_stream_id                     = 0;
+  QUICStreamId _remote_maximum_stream_id                    = 0;
 };
diff --git a/iocore/net/quic/test/test_QUICStreamManager.cc b/iocore/net/quic/test/test_QUICStreamManager.cc
index 63ed88c..eb7b77d 100644
--- a/iocore/net/quic/test/test_QUICStreamManager.cc
+++ b/iocore/net/quic/test/test_QUICStreamManager.cc
@@ -66,6 +66,12 @@ TEST_CASE("QUICStreamManager_NewStream", "[quic]")
   std::shared_ptr<QUICFrame> stream_blocked_frame = QUICFrameFactory::create_stream_blocked_frame(4);
   sm.handle_frame(stream_blocked_frame);
   CHECK(sm.stream_count() == 5);
+
+  // Set local maximum stream id
+  sm.set_max_stream_id(4);
+  std::shared_ptr<QUICFrame> stream_blocked_frame_x = QUICFrameFactory::create_stream_blocked_frame(5);
+  sm.handle_frame(stream_blocked_frame_x);
+  CHECK(sm.stream_count() == 5);
 }
 
 TEST_CASE("QUICStreamManager_first_initial_map", "[quic]")

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>'].

Mime
View raw message