[trafficserver] branch quic-latest updated: Send stateless reset packet if the client id doesn't seem valid anymore

2017-09-11 Thread maskit
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 a46bcab  Send stateless reset packet if the client id doesn't seem 
valid anymore
a46bcab is described below

commit a46bcab6c6949a7d4685f03dbff912b603574ecf
Author: Masakazu Kitajo 
AuthorDate: Tue Sep 12 14:50:33 2017 +0900

Send stateless reset packet if the client id doesn't seem valid anymore
---
 iocore/net/P_QUICPacketHandler.h   |  1 +
 iocore/net/QUICNetVConnection.cc   |  3 +--
 iocore/net/QUICPacketHandler.cc| 26 +-
 iocore/net/quic/QUICPacket.h   |  4 ++--
 iocore/net/quic/QUICTypes.h|  5 +++--
 iocore/net/quic/test/test_QUICPacketFactory.cc | 13 +
 6 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/iocore/net/P_QUICPacketHandler.h b/iocore/net/P_QUICPacketHandler.h
index c40f255..6b29b6a 100644
--- a/iocore/net/P_QUICPacketHandler.h
+++ b/iocore/net/P_QUICPacketHandler.h
@@ -40,6 +40,7 @@ public:
   virtual int acceptEvent(int event, void *e) override;
   void init_accept(EThread *t) override;
   void send_packet(const QUICPacket , QUICNetVConnection *vc);
+  void send_packet(const QUICPacket , UDPConnection *udp_con, 
IpEndpoint , uint32_t pmtu);
 
 private:
   void _recv_packet(int event, UDPPacket *udpPacket);
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 9cb85fa..bbc5547 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -49,7 +49,6 @@
 static constexpr uint32_t MAX_PACKET_OVERHEAD= 25; // Max long 
header len(17) + FNV-1a hash len(8)
 static constexpr uint32_t MAX_STREAM_FRAME_OVERHEAD  = 15;
 static constexpr uint32_t MINIMUM_INITIAL_CLIENT_PACKET_SIZE = 1200;
-static constexpr char STATELESS_RETRY_TOKEN_KEY[]= 
"stateless_token_retry_key";
 
 ClassAllocator quicNetVCAllocator("quicNetVCAllocator");
 
@@ -96,7 +95,7 @@ void
 QUICNetVConnection::start(SSL_CTX *ssl_ctx)
 {
   // Version 0x0001 uses stream 0 for cryptographic handshake with TLS 
1.3, but newer version may not
-  this->_token.gen_token(STATELESS_RETRY_TOKEN_KEY, _quic_connection_id ^ id);
+  this->_token.gen_token(_quic_connection_id ^ id);
 
   this->_handshake_handler = new QUICHandshake(this, ssl_ctx, this->_token);
   this->_application_map   = new QUICApplicationMap();
diff --git a/iocore/net/QUICPacketHandler.cc b/iocore/net/QUICPacketHandler.cc
index 0531aeb..39df7ce 100644
--- a/iocore/net/QUICPacketHandler.cc
+++ b/iocore/net/QUICPacketHandler.cc
@@ -129,9 +129,19 @@ QUICPacketHandler::_recv_packet(int event, UDPPacket 
*udpPacket)
   }
 
   if (!vc) {
-// Unknown Connection ID
 Connection con;
 con.setRemote(>from.sa);
+
+// Send stateless reset if the packet is not a initial packet
+if (!QUICTypeUtil::hasLongHeader(reinterpret_cast(block->buf( {
+  QUICStatelessToken token;
+  token.gen_token(cid);
+  auto packet = QUICPacketFactory::create_stateless_reset_packet(cid, 
token);
+  this->send_packet(*packet, udpPacket->getConnection(), con.addr, 1200);
+  return;
+}
+
+// Create a new NetVConnection
 vc =
   static_cast(getNetProcessor()->allocate_vc(((UnixUDPConnection 
*)udpPacket->getConnection())->ethread));
 vc->init(udpPacket->getConnection(), this);
@@ -147,7 +157,6 @@ QUICPacketHandler::_recv_packet(int event, UDPPacket 
*udpPacket)
 vc->options.ip_proto  = NetVCOptions::USE_UDP;
 vc->options.ip_family = udpPacket->from.sa.sa_family;
 
-// TODO: Handle Connection ID of Client Cleartext / Non-Final Server 
Cleartext Packet
 this->_connections.put(cid, vc);
   }
 
@@ -168,17 +177,24 @@ QUICPacketHandler::send_packet(const QUICPacket , 
QUICNetVConnection *vc)
 this->_connections.put(packet.connection_id(), vc);
   }
 
+  this->send_packet(packet, vc->get_udp_con(), vc->con.addr, vc->pmtu());
+}
+
+void
+QUICPacketHandler::send_packet(const QUICPacket , UDPConnection 
*udp_con, IpEndpoint , uint32_t pmtu)
+{
   size_t udp_len;
   Ptr udp_payload(new_IOBufferBlock());
-  udp_payload->alloc(iobuffer_size_to_index(vc->pmtu()));
+  udp_payload->alloc(iobuffer_size_to_index(pmtu));
   packet.store(reinterpret_cast(udp_payload->end()), _len);
   udp_payload->fill(udp_len);
 
-  UDPPacket *udpPkt = new_UDPPacket(vc->con.addr, 0, udp_payload);
+  UDPPacket *udpPkt = new_UDPPacket(addr, 0, udp_payload);
 
   // NOTE: p will be enqueued to udpOutQueue of UDPNetHandler
   ip_port_text_buffer ipb;
   Debug("quic_sec", "send %s packet to %s, size=%" PRId64, 
QUICDebugNames::packet_type(packet.type()),
 ats_ip_nptop(>to.sa, ipb, sizeof(ipb)), 
udpPkt->getPktLength());
-  vc->get_udp_con()->send(this, udpPkt);

[trafficserver] branch quic-latest updated: Add create_stateless_reset_packet

2017-09-11 Thread maskit
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 34c9253  Add create_stateless_reset_packet
34c9253 is described below

commit 34c9253dc403af84ed3938414f26bfaa05cc5d0b
Author: Masakazu Kitajo 
AuthorDate: Tue Sep 12 11:21:35 2017 +0900

Add create_stateless_reset_packet
---
 iocore/net/QUICNetVConnection.cc   |  2 +-
 iocore/net/quic/QUICDebugNames.cc  |  4 +--
 iocore/net/quic/QUICHandshake.cc   |  4 +--
 iocore/net/quic/QUICHandshake.h|  4 +--
 iocore/net/quic/QUICPacket.cc  | 45 ++
 iocore/net/quic/QUICPacket.h   |  4 +++
 iocore/net/quic/QUICTransportParameters.cc |  2 +-
 iocore/net/quic/QUICTransportParameters.h  |  2 +-
 iocore/net/quic/QUICTypes.h| 14 +---
 iocore/net/quic/test/test_QUICPacketFactory.cc | 28 
 10 files changed, 90 insertions(+), 19 deletions(-)

diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 3babca6..9cb85fa 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -98,7 +98,7 @@ QUICNetVConnection::start(SSL_CTX *ssl_ctx)
   // Version 0x0001 uses stream 0 for cryptographic handshake with TLS 
1.3, but newer version may not
   this->_token.gen_token(STATELESS_RETRY_TOKEN_KEY, _quic_connection_id ^ id);
 
-  this->_handshake_handler = new QUICHandshake(this, ssl_ctx, 
this->_token.get());
+  this->_handshake_handler = new QUICHandshake(this, ssl_ctx, this->_token);
   this->_application_map   = new QUICApplicationMap();
   this->_application_map->set(STREAM_ID_FOR_HANDSHAKE, 
this->_handshake_handler);
 
diff --git a/iocore/net/quic/QUICDebugNames.cc 
b/iocore/net/quic/QUICDebugNames.cc
index 2f79b92..a6b359e 100644
--- a/iocore/net/quic/QUICDebugNames.cc
+++ b/iocore/net/quic/QUICDebugNames.cc
@@ -44,8 +44,8 @@ QUICDebugNames::packet_type(QUICPacketType type)
 return "ONE_RTT_PROTECTED_KEY_PHASE_0";
   case QUICPacketType::ONE_RTT_PROTECTED_KEY_PHASE_1:
 return "ONE_RTT_PROTECTED_KEY_PHASE_1";
-  case QUICPacketType::PUBLIC_RESET:
-return "PUBLIC_RESET";
+  case QUICPacketType::STATELESS_RESET:
+return "STATELESS_RESET";
   case QUICPacketType::UNINITIALIZED:
   default:
 return "UNKNOWN";
diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc
index 9a2584d..daa47aa 100644
--- a/iocore/net/quic/QUICHandshake.cc
+++ b/iocore/net/quic/QUICHandshake.cc
@@ -54,7 +54,7 @@ static constexpr int UDP_MAXIMUM_PAYLOAD_SIZE = 65527;
 // TODO: fix size
 static constexpr int MAX_HANDSHAKE_MSG_LEN = 65527;
 
-QUICHandshake::QUICHandshake(QUICConnection *qc, SSL_CTX *ssl_ctx, INK_MD5 
token) : QUICApplication(qc), _token(token)
+QUICHandshake::QUICHandshake(QUICConnection *qc, SSL_CTX *ssl_ctx, 
QUICStatelessToken token) : QUICApplication(qc), _token(token)
 {
   this->_ssl = SSL_new(ssl_ctx);
   SSL_set_ex_data(this->_ssl, QUIC::ssl_quic_qc_index, qc);
@@ -258,7 +258,7 @@ QUICHandshake::_load_local_transport_parameters()
 
params->no_activity_timeout_in(), sizeof(uint16_t;
 
   tp->add(QUICTransportParameterId::STATELESS_RETRY_TOKEN,
-  std::unique_ptr(new 
QUICTransportParameterValue(this->_token.u64, 16)));
+  std::unique_ptr(new 
QUICTransportParameterValue(this->_token.get_u64(), 16)));
 
   tp->add_version(QUIC_SUPPORTED_VERSIONS[0]);
   // MAYs
diff --git a/iocore/net/quic/QUICHandshake.h b/iocore/net/quic/QUICHandshake.h
index e8866d6..5d0060a 100644
--- a/iocore/net/quic/QUICHandshake.h
+++ b/iocore/net/quic/QUICHandshake.h
@@ -50,7 +50,7 @@ class SSLNextProtocolSet;
 class QUICHandshake : public QUICApplication
 {
 public:
-  QUICHandshake(QUICConnection *qc, SSL_CTX *ssl_ctx, INK_MD5 token);
+  QUICHandshake(QUICConnection *qc, SSL_CTX *ssl_ctx, QUICStatelessToken 
token);
   ~QUICHandshake();
 
   QUICError start(const QUICPacket *initial_packet, QUICPacketFactory 
*packet_factory);
@@ -88,5 +88,5 @@ private:
   QUICError _process_client_finished();
   QUICError _process_handshake_complete();
 
-  INK_MD5 _token;
+  QUICStatelessToken _token;
 };
diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index bfae22b..97e62c6 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -254,6 +254,8 @@ QUICPacketShortHeader::QUICPacketShortHeader(QUICPacketType 
type, QUICConnection
 this->_key_phase = QUICKeyPhase::PHASE_0;
   } else if (type == QUICPacketType::ONE_RTT_PROTECTED_KEY_PHASE_1) {
 this->_key_phase = QUICKeyPhase::PHASE_1;
+  } else if (type == QUICPacketType::STATELESS_RESET) {
+this->_key_phase = QUICKeyPhase::PHASE_UNINITIALIZED;
   } else 

[trafficserver] branch quic-latest updated: [draft-05] Fix QUICLossDetector to follow pseudocode of draft-05

2017-09-11 Thread masaori
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


The following commit(s) were added to refs/heads/quic-latest by this push:
 new 5442415  [draft-05] Fix QUICLossDetector to follow pseudocode of 
draft-05
5442415 is described below

commit 5442415d17b4062a9cf5b64db62a103d6ff559a9
Author: Masaori Koshiba 
AuthorDate: Tue Sep 12 09:56:37 2017 +0900

[draft-05] Fix QUICLossDetector to follow pseudocode of draft-05
---
 iocore/net/quic/QUICLossDetector.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/iocore/net/quic/QUICLossDetector.cc 
b/iocore/net/quic/QUICLossDetector.cc
index feb48aa..fb72bc2 100644
--- a/iocore/net/quic/QUICLossDetector.cc
+++ b/iocore/net/quic/QUICLossDetector.cc
@@ -45,6 +45,7 @@ QUICLossDetector::QUICLossDetector(QUICPacketTransmitter 
*transmitter) : _transm
   this->_rttvar   = 0;
   this->_largest_sent_before_rto  = 0;
   this->_time_of_last_sent_packet = 0;
+  this->_largest_sent_packet  = 0;
 
   SET_HANDLER(::event_handler);
 }
@@ -183,6 +184,7 @@ void
 QUICLossDetector::_on_ack_received(const std::shared_ptr 
_frame)
 {
   SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+  this->_largest_acked_packet = ack_frame->largest_acknowledged();
   // If the largest acked is newly acked, update the RTT.
   auto pi = this->_sent_packets.find(ack_frame->largest_acknowledged());
   if (pi != this->_sent_packets.end()) {
@@ -208,7 +210,6 @@ QUICLossDetector::_on_packet_acked(QUICPacketNumber 
acked_packet_number)
 {
   SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
   Debug("quic_loss_detector", "Packet number %" PRIu64 " has been acked", 
acked_packet_number);
-  this->_largest_acked_packet = acked_packet_number;
   // If a packet sent prior to RTO was acked, then the RTO
   // was spurious.  Otherwise, inform congestion control.
   if (this->_rto_count > 0 && acked_packet_number > 
this->_largest_sent_before_rto) {

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


[trafficserver] branch master updated: TS-4976: Regularize plugins - thread_pool.

2017-09-11 Thread amc
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 97db22d  TS-4976: Regularize plugins - thread_pool.
97db22d is described below

commit 97db22db6869bb415828a7e1b09c58889d9fb402
Author: Alan M. Carroll 
AuthorDate: Sat Sep 9 13:19:22 2017 -0500

TS-4976: Regularize plugins - thread_pool.
---
 example/Makefile.am|  2 +-
 example/{thread-pool => thread_pool}/README.txt|  5 +-
 example/{thread-pool => thread_pool}/TESTPLAN.txt  | 12 ++--
 .../include/Makefile.am|  0
 example/{thread-pool => thread_pool}/include/gen.c |  0
 .../include/gen_inc.sh |  0
 example/{thread-pool => thread_pool}/psi.c | 72 +-
 .../test/SDKTest/SDKtest_server.config |  0
 .../test/SDKTest/psi_server.c  |  0
 .../test/SynTest/Tests/Psi/1.cfg   |  0
 .../test/SynTest/Tests/Psi/10.cfg  |  0
 .../test/SynTest/Tests/Psi/11.cfg  |  0
 .../test/SynTest/Tests/Psi/12.cfg  |  0
 .../test/SynTest/Tests/Psi/13.cfg  |  0
 .../test/SynTest/Tests/Psi/2.cfg   |  0
 .../test/SynTest/Tests/Psi/3.cfg   |  0
 .../test/SynTest/Tests/Psi/4.cfg   |  0
 .../test/SynTest/Tests/Psi/5.cfg   |  0
 .../test/SynTest/Tests/Psi/6.cfg   |  0
 .../test/SynTest/Tests/Psi/7.cfg   |  0
 .../test/SynTest/Tests/Psi/8.cfg   |  0
 .../test/SynTest/Tests/Psi/9.cfg   |  0
 .../test/SynTest/Tests/Psi/psi_files/tc10_file.txt |  0
 .../test/SynTest/Tests/Psi/psi_files/tc11_file.txt |  0
 .../test/SynTest/Tests/Psi/psi_files/tc12_file.txt |  0
 .../test/SynTest/Tests/Psi/psi_files/tc13_file.txt |  0
 .../test/SynTest/Tests/Psi/psi_files/tc1_file.txt  |  0
 .../test/SynTest/Tests/Psi/psi_files/tc2_file.txt  |  0
 .../test/SynTest/Tests/Psi/psi_files/tc3_file.txt  |  0
 .../test/SynTest/Tests/Psi/psi_files/tc4_file.txt  |  0
 .../test/SynTest/Tests/Psi/psi_files/tc5_file.txt  |  0
 .../test/SynTest/Tests/Psi/psi_files/tc6_file.txt  |  0
 .../test/SynTest/Tests/Psi/psi_files/tc7_file.txt  |  0
 .../test/SynTest/Tests/Psi/psi_files/tc8_file.txt  |  0
 .../test/SynTest/Tests/Psi/psi_files/tc9_file.txt  |  0
 .../test/SynTest/system.cfg|  0
 .../test/SynTest/tests_psi.cfg |  0
 example/{thread-pool => thread_pool}/thread.c  |  4 +-
 example/{thread-pool => thread_pool}/thread.h  |  2 +
 39 files changed, 40 insertions(+), 57 deletions(-)

diff --git a/example/Makefile.am b/example/Makefile.am
index 457c970..d4e4213 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -108,7 +108,7 @@ output_header_la_SOURCES = output_header/output_header.c
 passthru_la_SOURCES = passthru/passthru.cc
 protocol_la_SOURCES = protocol/Protocol.c protocol/TxnSM.c
 protocol_stack_la_SOURCES = protocol_stack/protocol_stack.cc
-psi_la_SOURCES = thread-pool/psi.c thread-pool/thread.c
+psi_la_SOURCES = thread_pool/psi.c thread_pool/thread.c
 query_remap_la_SOURCES = query_remap/query_remap.c
 remap_header_add_la_SOURCES = remap_header_add/remap_header_add.cc
 remap_la_SOURCES = remap/remap.cc
diff --git a/example/thread-pool/README.txt b/example/thread_pool/README.txt
similarity index 97%
rename from example/thread-pool/README.txt
rename to example/thread_pool/README.txt
index 78a4573..da64ae4 100644
--- a/example/thread-pool/README.txt
+++ b/example/thread_pool/README.txt
@@ -108,7 +108,7 @@ Plugin Testing
  Sample include file generation
  --
  A basic utility ('gen')to generate files to be inserted is provided
- in the directory thread-pool/include.
+ in the directory thread_pool/include.
  This create text files of various sizes.
  Compile gen the execute gen_inc.sh to generate files:
  > cd include
@@ -128,6 +128,5 @@ Plugin Testing
  The rate of responses with X-Psi header is configurable thru a SDKTest config 
file.
 
  A SDKTest server plugin as well as a SDKTest configuration file
- are provided in the directory thread-pool/test/SDKTest.
+ are provided in the directory thread_pool/test/SDKTest.
  Refer to the SDKTest manual for detailed setup instructions.
-
diff --git a/example/thread-pool/TESTPLAN.txt b/example/thread_pool/TESTPLAN.txt
similarity index 90%
rename from example/thread-pool/TESTPLAN.txt
rename to example/thread_pool/TESTPLAN.txt
index 3e5cbc4..a884104 100644
--- a/example/thread-pool/TESTPLAN.txt
+++ b/example/thread_pool/TESTPLAN.txt
@@ -1,4 +1,4 @@
-   Thread-Pool Sample Plugin Testing
+   Thread_Pool Sample Plugin Testing
=
 
 
@@ -10,7 +10,7 @@ boundary testing.
 
 List of 

[trafficserver] branch quic-latest updated: [draft-05] Fix error codes

2017-09-11 Thread masaori
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


The following commit(s) were added to refs/heads/quic-latest by this push:
 new 5241e33  [draft-05] Fix error codes
5241e33 is described below

commit 5241e33e39f690f0a7e42acdaf55f2372ae7337b
Author: Masaori Koshiba 
AuthorDate: Mon Sep 11 16:55:46 2017 +0900

[draft-05] Fix error codes
---
 iocore/net/QUICNetVConnection.cc|  6 ++---
 iocore/net/quic/QUICDebugNames.cc   | 32 +
 iocore/net/quic/QUICFlowController.cc   |  2 +-
 iocore/net/quic/QUICHandshake.cc|  6 ++---
 iocore/net/quic/QUICStream.cc   |  2 +-
 iocore/net/quic/QUICTypes.h | 28 +++---
 iocore/net/quic/test/test_QUICFlowController.cc |  4 ++--
 iocore/net/quic/test/test_QUICFrame.cc  | 12 +-
 iocore/net/quic/test/test_QUICStreamManager.cc  |  2 +-
 iocore/net/quic/test/test_QUICStreamState.cc|  8 +++
 10 files changed, 68 insertions(+), 34 deletions(-)

diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index c9654a3..3babca6 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -352,7 +352,7 @@ QUICNetVConnection::state_handshake(int event, Event *data)
   break;
 }
 default:
-  error = QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::QUIC_INTERNAL_ERROR);
+  error = QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::INTERNAL_ERROR);
   break;
 }
 
@@ -538,7 +538,7 @@ 
QUICNetVConnection::_state_handshake_process_initial_client_packet(std::unique_p
 {
   if (packet->size() < MINIMUM_INITIAL_CLIENT_PACKET_SIZE) {
 DebugQUICCon("Packet size is smaller than the minimum initial client 
packet size");
-return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::QUIC_INTERNAL_ERROR);
+return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::INTERNAL_ERROR);
   }
 
   // Start handshake
@@ -625,7 +625,7 @@ QUICNetVConnection::_state_common_receive_packet()
 error = this->_state_connection_established_process_packet(std::move(p));
 break;
   default:
-error = QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::QUIC_INTERNAL_ERROR);
+error = QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::INTERNAL_ERROR);
 break;
   }
   return error;
diff --git a/iocore/net/quic/QUICDebugNames.cc 
b/iocore/net/quic/QUICDebugNames.cc
index d580be7..2f79b92 100644
--- a/iocore/net/quic/QUICDebugNames.cc
+++ b/iocore/net/quic/QUICDebugNames.cc
@@ -115,15 +115,39 @@ QUICDebugNames::error_code(QUICErrorCode code)
 return "APPLICATION_SPECIFIC_ERROR";
   case QUICErrorCode::HOST_LOCAL_ERROR:
 return "HOST_LOCAL_ERROR";
-  case QUICErrorCode::QUIC_TRANSPORT_ERROR:
-return "QUIC_TRANSPORT_ERROR";
-  case QUICErrorCode::QUIC_INTERNAL_ERROR:
-return "QUIC_INTERNAL_ERROR";
+  case QUICErrorCode::NO_ERROR:
+return "NO_ERROR";
+  case QUICErrorCode::INTERNAL_ERROR:
+return "INTERNAL_ERROR";
+  case QUICErrorCode::CANCELLED:
+return "CANCELLED";
+  case QUICErrorCode::FLOW_CONTROL_ERROR:
+return "FLOW_CONTROL_ERROR";
+  case QUICErrorCode::STREAM_ID_ERROR:
+return "STREAM_ID_ERROR";
+  case QUICErrorCode::STREAM_STATE_ERROR:
+return "STREAM_STATE_ERROR";
+  case QUICErrorCode::FINAL_OFFSET_ERROR:
+return "FINAL_OFFSET_ERROR";
+  case QUICErrorCode::FRAME_FORMAT_ERROR:
+return "FRAME_FORMAT_ERROR";
+  case QUICErrorCode::TRANSPORT_PARAMETER_ERROR:
+return "TRANSPORT_PARAMETER_ERROR";
+  case QUICErrorCode::VERSION_NEGOTIATION_ERROR:
+return "VERSION_NEGOTIATION_ERROR";
+  case QUICErrorCode::PROTOCOL_VIOLATION:
+return "PROTOCOL_VIOLATION";
+  case QUICErrorCode::QUIC_RECEIVED_RST:
+return "QUIC_RECEIVED_RST";
   case QUICErrorCode::CRYPTOGRAPHIC_ERROR:
 return "CRYPTOGRAPHIC_ERROR";
   case QUICErrorCode::TLS_HANDSHAKE_FAILED:
 return "TLS_HANDSHAKE_FAILED";
   default:
+if ((static_cast(code) & 0xFF00) == 
static_cast(QUICErrorCode::FRAME_ERROR)) {
+  // TODO: Add frame type
+  return "FRAME_ERROR";
+}
 return "UNKNOWN";
   }
 }
diff --git a/iocore/net/quic/QUICFlowController.cc 
b/iocore/net/quic/QUICFlowController.cc
index ec277e5..77a615d 100644
--- a/iocore/net/quic/QUICFlowController.cc
+++ b/iocore/net/quic/QUICFlowController.cc
@@ -43,7 +43,7 @@ QUICFlowController::update(QUICOffset offset)
   if (this->_offset <= offset) {
 // Assume flow control is not initialized if the limit was 0
 if (this->_limit != 0 && offset > this->_limit) {
-  return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA);
+  return QUICError(QUICErrorClass::QUIC_TRANSPORT, 
QUICErrorCode::FLOW_CONTROL_ERROR);
 }
 

[trafficserver] branch quic-latest updated: Cleanup QUICFrame

2017-09-11 Thread masaori
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


The following commit(s) were added to refs/heads/quic-latest by this push:
 new fd62dfc  Cleanup QUICFrame
fd62dfc is described below

commit fd62dfc9f51d708ddb4e901057ee2c0e405ec1b2
Author: Masaori Koshiba 
AuthorDate: Mon Sep 11 15:47:21 2017 +0900

Cleanup QUICFrame

- Replace hard-coded QUICFrameType
- Reorder arguments of QUICRstFrame constructor
- Use write_QUICStreamId()
---
 iocore/net/quic/QUICFrame.cc   | 32 
 iocore/net/quic/QUICFrame.h|  4 ++--
 iocore/net/quic/test/test_QUICFrame.cc | 14 +++---
 3 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/iocore/net/quic/QUICFrame.cc b/iocore/net/quic/QUICFrame.cc
index c8f2229..6a07641 100644
--- a/iocore/net/quic/QUICFrame.cc
+++ b/iocore/net/quic/QUICFrame.cc
@@ -645,8 +645,8 @@ QUICAckFrame::TimestampSection::store(uint8_t *buf, size_t 
*len) const
 // RST_STREAM frame
 //
 
-QUICRstStreamFrame::QUICRstStreamFrame(QUICErrorCode error_code, QUICStreamId 
stream_id, QUICOffset final_offset)
-  : _error_code(error_code), _stream_id(stream_id), _final_offset(final_offset)
+QUICRstStreamFrame::QUICRstStreamFrame(QUICStreamId stream_id, QUICErrorCode 
error_code, QUICOffset final_offset)
+  : _stream_id(stream_id), _error_code(error_code), _final_offset(final_offset)
 {
 }
 
@@ -667,7 +667,7 @@ QUICRstStreamFrame::store(uint8_t *buf, size_t *len) const
 {
   size_t n;
   uint8_t *p = buf;
-  *p = 0x01;
+  *p = static_cast(QUICFrameType::RST_STREAM);
   ++p;
   QUICTypeUtil::write_QUICStreamId(this->_stream_id, 4, p, );
   p += n;
@@ -727,7 +727,7 @@ QUICPingFrame::size() const
 void
 QUICPingFrame::store(uint8_t *buf, size_t *len) const
 {
-  buf[0] = 0x07;
+  buf[0] = static_cast(QUICFrameType::PING);
   *len   = 1;
 }
 
@@ -749,7 +749,7 @@ QUICPaddingFrame::size() const
 void
 QUICPaddingFrame::store(uint8_t *buf, size_t *len) const
 {
-  buf[0] = 0x00;
+  buf[0] = static_cast(QUICFrameType::PADDING);
   *len   = 1;
 }
 
@@ -782,7 +782,7 @@ QUICConnectionCloseFrame::store(uint8_t *buf, size_t *len) 
const
 {
   size_t n;
   uint8_t *p = buf;
-  *p = 0x02;
+  *p = static_cast(QUICFrameType::CONNECTION_CLOSE);
   ++p;
   QUICTypeUtil::write_QUICErrorCode(this->_error_code, p, );
   p += n;
@@ -849,7 +849,7 @@ QUICMaxDataFrame::store(uint8_t *buf, size_t *len) const
 {
   size_t n;
   uint8_t *p = buf;
-  *p = 0x04;
+  *p = static_cast(QUICFrameType::MAX_DATA);
   ++p;
   QUICTypeUtil::write_uint_as_nbytes(this->_maximum_data, 8, p, );
   p += n;
@@ -893,9 +893,9 @@ QUICMaxStreamDataFrame::store(uint8_t *buf, size_t *len) 
const
 {
   size_t n;
   uint8_t *p = buf;
-  *p = 0x05;
+  *p = static_cast(QUICFrameType::MAX_STREAM_DATA);
   ++p;
-  QUICTypeUtil::write_uint_as_nbytes(this->_stream_id, 4, p, );
+  QUICTypeUtil::write_QUICStreamId(this->_stream_id, 4, p, );
   p += n;
   QUICTypeUtil::write_uint_as_nbytes(this->_maximum_stream_data, 8, p, );
   p += n;
@@ -948,7 +948,7 @@ QUICMaxStreamIdFrame::store(uint8_t *buf, size_t *len) const
 {
   size_t n;
   uint8_t *p = buf;
-  *p = 0x06;
+  *p = static_cast(QUICFrameType::MAX_STREAM_ID);
   ++p;
   QUICTypeUtil::write_uint_as_nbytes(this->_maximum_stream_id, 4, p, );
   p += n;
@@ -984,7 +984,7 @@ QUICBlockedFrame::size() const
 void
 QUICBlockedFrame::store(uint8_t *buf, size_t *len) const
 {
-  buf[0] = 0x08;
+  buf[0] = static_cast(QUICFrameType::BLOCKED);
   *len   = 1;
 }
 
@@ -1013,9 +1013,9 @@ QUICStreamBlockedFrame::store(uint8_t *buf, size_t *len) 
const
 {
   size_t n;
   uint8_t *p = buf;
-  *p = 0x09;
+  *p = static_cast(QUICFrameType::STREAM_BLOCKED);
   ++p;
-  QUICTypeUtil::write_uint_as_nbytes(this->_stream_id, 4, p, );
+  QUICTypeUtil::write_QUICStreamId(this->_stream_id, 4, p, );
   p += n;
 
   *len = p - buf;
@@ -1049,7 +1049,7 @@ QUICStreamIdNeededFrame::size() const
 void
 QUICStreamIdNeededFrame::store(uint8_t *buf, size_t *len) const
 {
-  buf[0] = 0x0a;
+  buf[0] = static_cast(QUICFrameType::STREAM_ID_NEEDED);
   *len   = 1;
 }
 
@@ -1080,7 +1080,7 @@ QUICNewConnectionIdFrame::store(uint8_t *buf, size_t 
*len) const
 {
   size_t n;
   uint8_t *p = buf;
-  *p = 0x0b;
+  *p = static_cast(QUICFrameType::NEW_CONNECTION_ID);
   ++p;
   QUICTypeUtil::write_uint_as_nbytes(this->_sequence, 2, p, );
   p += n;
@@ -1352,7 +1352,7 @@ std::unique_ptr
 QUICFrameFactory::create_rst_stream_frame(QUICStreamId stream_id, 
QUICErrorCode error_code, QUICOffset final_offset)
 {
   QUICRstStreamFrame *frame = quicRstStreamFrameAllocator.alloc();
-  new (frame) QUICRstStreamFrame(error_code, stream_id, final_offset);
+  new (frame) 

[trafficserver] branch quic-latest updated: [draft-05] Add STOP_SENDING frame

2017-09-11 Thread masaori
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


The following commit(s) were added to refs/heads/quic-latest by this push:
 new 58bd89f  [draft-05] Add STOP_SENDING frame
58bd89f is described below

commit 58bd89f66df87e359816085a12a49cce4150bba9
Author: Masaori Koshiba 
AuthorDate: Mon Sep 11 15:11:15 2017 +0900

[draft-05] Add STOP_SENDING frame
---
 iocore/net/quic/QUICFrame.cc   | 72 +-
 iocore/net/quic/QUICFrame.h| 34 
 iocore/net/quic/QUICTypes.h|  2 +
 iocore/net/quic/test/test_QUICFrame.cc | 37 -
 4 files changed, 143 insertions(+), 2 deletions(-)

diff --git a/iocore/net/quic/QUICFrame.cc b/iocore/net/quic/QUICFrame.cc
index 3ab7a52..c8f2229 100644
--- a/iocore/net/quic/QUICFrame.cc
+++ b/iocore/net/quic/QUICFrame.cc
@@ -36,6 +36,7 @@ ClassAllocator 
quicBlockedFrameAllocator("quicBlockedFrameAllo
 ClassAllocator 
quicStreamBlockedFrameAllocator("quicStreamBlockedFrameAllocator");
 ClassAllocator 
quicStreamIdNeededFrameAllocator("quicStreamIdNeededFrameAllocator");
 ClassAllocator 
quicNewConnectionIdFrameAllocator("quicNewConnectionIdFrameAllocator");
+ClassAllocator 
quicStopSendingFrameAllocator("quicStopSendingFrameAllocator");
 ClassAllocator 
quicRetransmissionFrameAllocator("quicRetransmissionFrameAllocator");
 
 QUICFrameType
@@ -44,6 +45,7 @@ QUICFrame::type() const
   return QUICFrame::type(this->_buf);
 }
 
+// XXX QUICFrameType: 0x03 (GOAWAY frame) is removed
 QUICFrameType
 QUICFrame::type(const uint8_t *buf)
 {
@@ -51,7 +53,7 @@ QUICFrame::type(const uint8_t *buf)
 return QUICFrameType::STREAM;
   } else if (buf[0] >= static_cast(QUICFrameType::ACK)) {
 return QUICFrameType::ACK;
-  } else if (static_cast(QUICFrameType::NEW_CONNECTION_ID) < buf[0] 
&& buf[0] < static_cast(QUICFrameType::ACK)) {
+  } else if (buf[0] > static_cast(QUICFrameType::STOP_SENDING) || 
buf[0] == 0x03) {
 return QUICFrameType::UNKNOWN;
   } else {
 return static_cast(buf[0]);
@@ -1109,6 +,62 @@ QUICNewConnectionIdFrame::connection_id() const
 }
 
 //
+// STOP_SENDING frame
+//
+
+QUICStopSendingFrame::QUICStopSendingFrame(QUICStreamId stream_id, 
QUICErrorCode error_code)
+  : _stream_id(stream_id), _error_code(error_code)
+{
+}
+
+QUICFrameType
+QUICStopSendingFrame::type() const
+{
+  return QUICFrameType::STOP_SENDING;
+}
+
+size_t
+QUICStopSendingFrame::size() const
+{
+  return 9;
+}
+
+void
+QUICStopSendingFrame::store(uint8_t *buf, size_t *len) const
+{
+  size_t n;
+  uint8_t *p = buf;
+  *p = static_cast(QUICFrameType::STOP_SENDING);
+  ++p;
+  QUICTypeUtil::write_QUICStreamId(this->_stream_id, 4, p, );
+  p += n;
+  QUICTypeUtil::write_QUICErrorCode(this->_error_code, p, );
+  p += n;
+
+  *len = p - buf;
+}
+
+QUICErrorCode
+QUICStopSendingFrame::error_code() const
+{
+  if (this->_buf) {
+return QUICTypeUtil::read_QUICErrorCode(this->_buf + 5);
+  } else {
+return this->_error_code;
+  }
+}
+
+QUICStreamId
+QUICStopSendingFrame::stream_id() const
+{
+  if (this->_buf) {
+return QUICTypeUtil::read_QUICStreamId(this->_buf + 1, 4);
+  } else {
+return this->_stream_id;
+  }
+}
+
+//
 // QUICRetransmissionFrame
 //
 QUICRetransmissionFrame::QUICRetransmissionFrame(std::unique_ptr original_frame,
@@ -1203,6 +1261,10 @@ QUICFrameFactory::create(const uint8_t *buf, size_t len)
 frame = quicNewConnectionIdFrameAllocator.alloc();
 new (frame) QUICNewConnectionIdFrame(buf, len);
 return std::unique_ptr(frame, 
::delete_new_connection_id_frame);
+  case QUICFrameType::STOP_SENDING:
+frame = quicStopSendingFrameAllocator.alloc();
+new (frame) QUICStopSendingFrame(buf, len);
+return std::unique_ptr(frame, 
::delete_stop_sending_frame);
   default:
 // Unknown frame
 return std::unique_ptr(nullptr, 
::delete_null_frame);
@@ -1294,6 +1356,14 @@ QUICFrameFactory::create_rst_stream_frame(QUICStreamId 
stream_id, QUICErrorCode
   return std::unique_ptr(frame, 
::delete_rst_stream_frame);
 }
 
+std::unique_ptr
+QUICFrameFactory::create_stop_sending_frame(QUICStreamId stream_id, 
QUICErrorCode error_code)
+{
+  QUICStopSendingFrame *frame = quicStopSendingFrameAllocator.alloc();
+  new (frame) QUICStopSendingFrame(stream_id, error_code);
+  return std::unique_ptr(frame, 
::delete_stop_sending_frame);
+}
+
 std::unique_ptr
 QUICFrameFactory::create_retransmission_frame(std::unique_ptr original_frame,