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/08/31 05:27:18 UTC

[trafficserver] branch quic-latest updated (4094f6b -> 0103055)

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

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


    from 4094f6b  Acquire mutex lock before handleEvent() call in unit test of QUICStream
     new 4d48f65  Send MAX_DATA frame
     new 0103055  Update connection level FC (local) only if received packet include STREAM frame

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 iocore/net/P_QUICNetVConnection.h                |  1 +
 iocore/net/QUICNetVConnection.cc                 | 29 ++++++++++++++++++------
 iocore/net/quic/QUICFrameDispatcher.cc           |  8 ++++++-
 iocore/net/quic/QUICFrameDispatcher.h            |  3 ++-
 iocore/net/quic/QUICStream.cc                    | 12 +++++++---
 iocore/net/quic/QUICStream.h                     |  2 ++
 iocore/net/quic/QUICStreamManager.cc             | 12 ++++++++++
 iocore/net/quic/QUICStreamManager.h              |  1 +
 iocore/net/quic/test/test_QUICFrameDispatcher.cc |  5 ++--
 9 files changed, 59 insertions(+), 14 deletions(-)


[trafficserver] 01/02: Send MAX_DATA frame

Posted by ma...@apache.org.
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 4d48f656b0e088d10c717a25478909d516b1d3bd
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Fri Aug 31 12:08:48 2018 +0900

    Send MAX_DATA frame
---
 iocore/net/P_QUICNetVConnection.h    |  1 +
 iocore/net/QUICNetVConnection.cc     | 14 +++++++++++++-
 iocore/net/quic/QUICStream.cc        | 12 +++++++++---
 iocore/net/quic/QUICStream.h         |  2 ++
 iocore/net/quic/QUICStreamManager.cc | 12 ++++++++++++
 iocore/net/quic/QUICStreamManager.h  |  1 +
 6 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/iocore/net/P_QUICNetVConnection.h b/iocore/net/P_QUICNetVConnection.h
index ca02b19..2fc8c63 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -272,6 +272,7 @@ private:
   QUICConnectionErrorUPtr _connection_error  = nullptr;
   uint32_t _state_closing_recv_packet_count  = 0;
   uint32_t _state_closing_recv_packet_window = 1;
+  uint64_t _flow_control_buffer_size         = 1024;
 
   void _schedule_packet_write_ready(bool delay = false);
   void _unschedule_packet_write_ready();
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 7b79c48..81a32a0 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -1258,6 +1258,13 @@ QUICNetVConnection::_packetize_frames(QUICEncryptionLevel level, uint64_t max_pa
     frame = this->_packet_retransmitter.generate_frame(level, UINT16_MAX, max_frame_size);
   }
 
+  // MAX_DATA
+  frame = this->_local_flow_controller->generate_frame(level, UINT16_MAX, max_frame_size);
+  if (frame) {
+    ++frame_count;
+    this->_store_frame(buf, len, max_frame_size, std::move(frame));
+  }
+
   // BLOCKED
   if (this->_remote_flow_controller->credit() == 0 && this->_stream_manager->will_generate_frame(level)) {
     frame = this->_remote_flow_controller->generate_frame(level, UINT16_MAX, max_frame_size);
@@ -1382,6 +1389,10 @@ QUICNetVConnection::_recv_and_ack(QUICPacketUPtr packet)
     return QUICErrorUPtr(new QUICConnectionError(QUICTransErrorCode::FLOW_CONTROL_ERROR));
   }
 
+  this->_local_flow_controller->forward_limit(this->_stream_manager->total_reordered_bytes() + this->_flow_control_buffer_size);
+  QUICFCDebug("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller->current_offset(),
+              this->_local_flow_controller->current_limit());
+
   this->_ack_frame_creator.update(level, packet_num, should_send_ack);
 
   return error;
@@ -1443,7 +1454,8 @@ QUICNetVConnection::_init_flow_control_params(const std::shared_ptr<const QUICTr
   uint32_t local_initial_max_data  = 0;
   uint32_t remote_initial_max_data = 0;
   if (local_tp) {
-    local_initial_max_data = local_tp->getAsUInt32(QUICTransportParameterId::INITIAL_MAX_DATA);
+    local_initial_max_data          = local_tp->getAsUInt32(QUICTransportParameterId::INITIAL_MAX_DATA);
+    this->_flow_control_buffer_size = local_initial_max_data;
   }
   if (remote_tp) {
     remote_initial_max_data = remote_tp->getAsUInt32(QUICTransportParameterId::INITIAL_MAX_DATA);
diff --git a/iocore/net/quic/QUICStream.cc b/iocore/net/quic/QUICStream.cc
index a4d22ef..5949c18 100644
--- a/iocore/net/quic/QUICStream.cc
+++ b/iocore/net/quic/QUICStream.cc
@@ -334,8 +334,9 @@ QUICStream::recv(const QUICStreamFrame &frame)
 
     this->_write_to_read_vio(stream_frame->offset(), stream_frame->data(), stream_frame->data_length(),
                              stream_frame->has_fin_flag());
-    this->_local_flow_controller.forward_limit(stream_frame->offset() + stream_frame->data_length() +
-                                               this->_flow_control_buffer_size);
+
+    this->_reordered_bytes = stream_frame->offset() + stream_frame->data_length();
+    this->_local_flow_controller.forward_limit(this->_reordered_bytes + this->_flow_control_buffer_size);
     QUICStreamFCDebug("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller.current_offset(),
                       this->_local_flow_controller.current_limit());
     this->_state.update_with_receiving_frame(*new_frame);
@@ -355,7 +356,6 @@ QUICStream::recv(const QUICMaxStreamDataFrame &frame)
   QUICStreamFCDebug("[REMOTE] %" PRIu64 "/%" PRIu64, this->_remote_flow_controller.current_offset(),
                     this->_remote_flow_controller.current_limit());
 
-  QUICStreamDebug("restart sending");
   int64_t len = this->_process_write_vio();
   if (len > 0) {
     this->_signal_write_event();
@@ -585,6 +585,12 @@ QUICStream::reset(QUICStreamErrorUPtr error)
 }
 
 QUICOffset
+QUICStream::reordered_bytes() const
+{
+  return this->_reordered_bytes;
+}
+
+QUICOffset
 QUICStream::largest_offset_received() const
 {
   return this->_local_flow_controller.current_offset();
diff --git a/iocore/net/quic/QUICStream.h b/iocore/net/quic/QUICStream.h
index e9defc7..c05f985 100644
--- a/iocore/net/quic/QUICStream.h
+++ b/iocore/net/quic/QUICStream.h
@@ -83,6 +83,7 @@ public:
 
   void reset(QUICStreamErrorUPtr error);
 
+  QUICOffset reordered_bytes() const;
   QUICOffset largest_offset_received() const;
   QUICOffset largest_offset_sent() const;
 
@@ -105,6 +106,7 @@ protected:
   QUICConnectionInfoProvider *_info = nullptr;
   QUICStreamId _id                  = 0;
   QUICOffset _send_offset           = 0;
+  QUICOffset _reordered_bytes       = 0;
 
   QUICRemoteStreamFlowController _remote_flow_controller;
   QUICLocalStreamFlowController _local_flow_controller;
diff --git a/iocore/net/quic/QUICStreamManager.cc b/iocore/net/quic/QUICStreamManager.cc
index 1dff812..b6e8fe0 100644
--- a/iocore/net/quic/QUICStreamManager.cc
+++ b/iocore/net/quic/QUICStreamManager.cc
@@ -295,6 +295,18 @@ QUICStreamManager::_find_or_create_stream(QUICStreamId stream_id)
 }
 
 uint64_t
+QUICStreamManager::total_reordered_bytes() const
+{
+  uint64_t total_bytes = 0;
+
+  // FIXME Iterating all (open + closed) streams is expensive
+  for (QUICStream *s = this->stream_list.head; s; s = s->link.next) {
+    total_bytes += s->reordered_bytes();
+  }
+  return total_bytes;
+}
+
+uint64_t
 QUICStreamManager::total_offset_received() const
 {
   uint64_t total_offset_received = 0;
diff --git a/iocore/net/quic/QUICStreamManager.h b/iocore/net/quic/QUICStreamManager.h
index be5c016..0e0266e 100644
--- a/iocore/net/quic/QUICStreamManager.h
+++ b/iocore/net/quic/QUICStreamManager.h
@@ -43,6 +43,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_reordered_bytes() const;
   uint64_t total_offset_received() const;
   uint64_t total_offset_sent() const;
   void add_total_offset_sent(uint32_t sent_byte);


[trafficserver] 02/02: Update connection level FC (local) only if received packet include STREAM frame

Posted by ma...@apache.org.
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 01030555a4cfe8e421886673e8dfdc592e13c53a
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Fri Aug 31 14:24:26 2018 +0900

    Update connection level FC (local) only if received packet include STREAM frame
---
 iocore/net/QUICNetVConnection.cc                 | 23 +++++++++++++----------
 iocore/net/quic/QUICFrameDispatcher.cc           |  8 +++++++-
 iocore/net/quic/QUICFrameDispatcher.h            |  3 ++-
 iocore/net/quic/test/test_QUICFrameDispatcher.cc |  5 +++--
 4 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 81a32a0..83a3cb0 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -1369,10 +1369,11 @@ QUICNetVConnection::_recv_and_ack(QUICPacketUPtr packet)
   QUICEncryptionLevel level   = QUICTypeUtil::encryption_level(packet->type());
 
   bool should_send_ack;
+  bool is_flow_controlled;
 
   QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
 
-  error = this->_frame_dispatcher->receive_frames(level, payload, size, should_send_ack);
+  error = this->_frame_dispatcher->receive_frames(level, payload, size, should_send_ack, is_flow_controlled);
   if (error->cls != QUICErrorClass::NONE) {
     return error;
   }
@@ -1381,17 +1382,19 @@ QUICNetVConnection::_recv_and_ack(QUICPacketUPtr packet)
     should_send_ack = false;
   }
 
-  int ret = this->_local_flow_controller->update(this->_stream_manager->total_offset_received());
-  QUICFCDebug("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller->current_offset(),
-              this->_local_flow_controller->current_limit());
+  if (is_flow_controlled) {
+    int ret = this->_local_flow_controller->update(this->_stream_manager->total_offset_received());
+    QUICFCDebug("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller->current_offset(),
+                this->_local_flow_controller->current_limit());
 
-  if (ret != 0) {
-    return QUICErrorUPtr(new QUICConnectionError(QUICTransErrorCode::FLOW_CONTROL_ERROR));
-  }
+    if (ret != 0) {
+      return QUICErrorUPtr(new QUICConnectionError(QUICTransErrorCode::FLOW_CONTROL_ERROR));
+    }
 
-  this->_local_flow_controller->forward_limit(this->_stream_manager->total_reordered_bytes() + this->_flow_control_buffer_size);
-  QUICFCDebug("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller->current_offset(),
-              this->_local_flow_controller->current_limit());
+    this->_local_flow_controller->forward_limit(this->_stream_manager->total_reordered_bytes() + this->_flow_control_buffer_size);
+    QUICFCDebug("[LOCAL] %" PRIu64 "/%" PRIu64, this->_local_flow_controller->current_offset(),
+                this->_local_flow_controller->current_limit());
+  }
 
   this->_ack_frame_creator.update(level, packet_num, should_send_ack);
 
diff --git a/iocore/net/quic/QUICFrameDispatcher.cc b/iocore/net/quic/QUICFrameDispatcher.cc
index 3d5c876..543a147 100644
--- a/iocore/net/quic/QUICFrameDispatcher.cc
+++ b/iocore/net/quic/QUICFrameDispatcher.cc
@@ -42,11 +42,13 @@ QUICFrameDispatcher::add_handler(QUICFrameHandler *handler)
 }
 
 QUICErrorUPtr
-QUICFrameDispatcher::receive_frames(QUICEncryptionLevel level, const uint8_t *payload, uint16_t size, bool &should_send_ack)
+QUICFrameDispatcher::receive_frames(QUICEncryptionLevel level, const uint8_t *payload, uint16_t size, bool &should_send_ack,
+                                    bool &is_flow_controlled)
 {
   std::shared_ptr<const QUICFrame> frame(nullptr);
   uint16_t cursor     = 0;
   should_send_ack     = false;
+  is_flow_controlled  = false;
   QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
 
   while (cursor < size) {
@@ -59,6 +61,10 @@ QUICFrameDispatcher::receive_frames(QUICEncryptionLevel level, const uint8_t *pa
 
     QUICFrameType type = frame->type();
 
+    if (type == QUICFrameType::STREAM) {
+      is_flow_controlled = true;
+    }
+
     if (is_debug_tag_set(tag) && type != QUICFrameType::PADDING) {
       char msg[1024];
       frame->debug_msg(msg, sizeof(msg));
diff --git a/iocore/net/quic/QUICFrameDispatcher.h b/iocore/net/quic/QUICFrameDispatcher.h
index 6db357d..bd65ba1 100644
--- a/iocore/net/quic/QUICFrameDispatcher.h
+++ b/iocore/net/quic/QUICFrameDispatcher.h
@@ -37,7 +37,8 @@ public:
   /*
    * Returns true if ACK frame should be sent
    */
-  QUICErrorUPtr receive_frames(QUICEncryptionLevel level, const uint8_t *payload, uint16_t size, bool &should_send_ack);
+  QUICErrorUPtr receive_frames(QUICEncryptionLevel level, const uint8_t *payload, uint16_t size, bool &should_send_ackbool,
+                               bool &is_flow_controlled);
 
   void add_handler(QUICFrameHandler *handler);
 
diff --git a/iocore/net/quic/test/test_QUICFrameDispatcher.cc b/iocore/net/quic/test/test_QUICFrameDispatcher.cc
index 30b38ce..a90752d 100644
--- a/iocore/net/quic/test/test_QUICFrameDispatcher.cc
+++ b/iocore/net/quic/test/test_QUICFrameDispatcher.cc
@@ -57,14 +57,15 @@ TEST_CASE("QUICFrameHandler", "[quic]")
   size_t len        = 0;
   streamFrame.store(buf, &len, 4096);
   bool should_send_ack;
-  quicFrameDispatcher.receive_frames(QUICEncryptionLevel::INITIAL, buf, len, should_send_ack);
+  bool is_flow_controlled;
+  quicFrameDispatcher.receive_frames(QUICEncryptionLevel::INITIAL, buf, len, should_send_ack, is_flow_controlled);
   CHECK(connection->getTotalFrameCount() == 0);
   CHECK(streamManager->getTotalFrameCount() == 1);
 
   // CONNECTION_CLOSE frame
   QUICConnectionCloseFrame connectionCloseFrame({});
   connectionCloseFrame.store(buf, &len, 4096);
-  quicFrameDispatcher.receive_frames(QUICEncryptionLevel::INITIAL, buf, len, should_send_ack);
+  quicFrameDispatcher.receive_frames(QUICEncryptionLevel::INITIAL, buf, len, should_send_ack, is_flow_controlled);
   CHECK(connection->getTotalFrameCount() == 1);
   CHECK(streamManager->getTotalFrameCount() == 1);
 }