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/22 07:04:09 UTC

[trafficserver] 03/03: Check frame size when AckFrameCreator/AltConnectionManager/PathValidator generate frame

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 49f8be8763e60c2ee4c13c5d10956e2059cc712c
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Wed Aug 22 16:02:20 2018 +0900

    Check frame size when AckFrameCreator/AltConnectionManager/PathValidator generate frame
---
 iocore/net/quic/QUICAckFrameCreator.cc      | 13 +++++++++----
 iocore/net/quic/QUICAltConnectionManager.cc | 10 ++++++++--
 iocore/net/quic/QUICPathValidator.cc        | 19 +++++++++++++++----
 3 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/iocore/net/quic/QUICAckFrameCreator.cc b/iocore/net/quic/QUICAckFrameCreator.cc
index cdfda94..239aff0 100644
--- a/iocore/net/quic/QUICAckFrameCreator.cc
+++ b/iocore/net/quic/QUICAckFrameCreator.cc
@@ -64,10 +64,15 @@ QUICAckFrameCreator::generate_frame(QUICEncryptionLevel level, uint64_t connecti
   if (this->_can_send[index]) {
     QUICAckPacketNumbers *packet_numbers = &this->_packet_numbers[index];
 
-    ack_frame                 = this->_create_ack_frame(level);
-    this->_can_send[index]    = false;
-    this->_should_send[index] = false;
-    packet_numbers->clear();
+    ack_frame = this->_create_ack_frame(level);
+    if (ack_frame && ack_frame->size() > maximum_frame_size) {
+      // Cancel generating frame
+      ack_frame = QUICFrameFactory::create_null_frame();
+    } else {
+      this->_can_send[index]    = false;
+      this->_should_send[index] = false;
+      packet_numbers->clear();
+    }
   }
 
   return ack_frame;
diff --git a/iocore/net/quic/QUICAltConnectionManager.cc b/iocore/net/quic/QUICAltConnectionManager.cc
index 4ad73f7..feb1aa8 100644
--- a/iocore/net/quic/QUICAltConnectionManager.cc
+++ b/iocore/net/quic/QUICAltConnectionManager.cc
@@ -116,9 +116,15 @@ QUICAltConnectionManager::generate_frame(QUICEncryptionLevel level, uint64_t con
   int count = this->_nids;
   for (int i = 0; i < count; ++i) {
     if (!this->_alt_quic_connection_ids[i].advertised) {
-      this->_alt_quic_connection_ids[i].advertised = true;
-      return QUICFrameFactory::create_new_connection_id_frame(
+      frame = QUICFrameFactory::create_new_connection_id_frame(
         this->_alt_quic_connection_ids[i].seq_num, this->_alt_quic_connection_ids[i].id, this->_alt_quic_connection_ids[i].token);
+
+      if (frame && frame->size() > maximum_frame_size) {
+        // Cancel generating frame
+        frame = QUICFrameFactory::create_null_frame();
+      } else {
+        this->_alt_quic_connection_ids[i].advertised = true;
+      }
     }
   }
   this->_need_advertise = false;
diff --git a/iocore/net/quic/QUICPathValidator.cc b/iocore/net/quic/QUICPathValidator.cc
index 53db58d..bdc6cc6 100644
--- a/iocore/net/quic/QUICPathValidator.cc
+++ b/iocore/net/quic/QUICPathValidator.cc
@@ -126,13 +126,24 @@ QUICPathValidator::generate_frame(QUICEncryptionLevel level, uint64_t connection
   }
 
   if (this->_has_outgoing_response) {
-    frame                        = QUICFrameFactory::create_path_response_frame(this->_incoming_challenge);
-    this->_has_outgoing_response = false;
+    frame = QUICFrameFactory::create_path_response_frame(this->_incoming_challenge);
+    if (frame && frame->size() > maximum_quic_packet_size) {
+      // Cancel generating frame
+      frame = QUICFrameFactory::create_null_frame();
+    } else {
+      this->_has_outgoing_response = false;
+    }
   } else if (this->_has_outgoing_challenge) {
     frame = QUICFrameFactory::create_path_challenge_frame(this->_outgoing_challenge +
                                                           (QUICPathChallengeFrame::DATA_LEN * (this->_has_outgoing_challenge - 1)));
-    --this->_has_outgoing_challenge;
-    ink_assert(this->_has_outgoing_challenge >= 0);
+    if (frame && frame->size() > maximum_quic_packet_size) {
+      // Cancel generating frame
+      frame = QUICFrameFactory::create_null_frame();
+    } else {
+      --this->_has_outgoing_challenge;
+      ink_assert(this->_has_outgoing_challenge >= 0);
+    }
   }
+
   return frame;
 }