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/01/15 03:03:01 UTC

[trafficserver] branch quic-latest updated (fa2c6df -> a149a1f)

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 fa2c6df  Cleanup QUICHandshake constructor
     new 365b4cc  Divide traffic_quic.cc
     new a149a1f  Support taking address and port on traffic_quic cmd

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:
 cmd/traffic_quic/Makefile.am                       |   3 +-
 cmd/traffic_quic/diags.h                           |  96 ++++++++++++++
 cmd/traffic_quic/quic_client.cc                    |  88 +++++++++++++
 .../QUICEvents.h => cmd/traffic_quic/quic_client.h |  24 +++-
 cmd/traffic_quic/traffic_quic.cc                   | 140 +--------------------
 iocore/net/QUICNetProcessor.cc                     |   6 +-
 6 files changed, 213 insertions(+), 144 deletions(-)
 create mode 100644 cmd/traffic_quic/diags.h
 create mode 100644 cmd/traffic_quic/quic_client.cc
 copy iocore/net/quic/QUICEvents.h => cmd/traffic_quic/quic_client.h (66%)

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

[trafficserver] 01/02: Divide traffic_quic.cc

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 365b4cc97c307050f00805b6834d668cdb8f9558
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Mon Jan 15 11:03:36 2018 +0900

    Divide traffic_quic.cc
---
 cmd/traffic_quic/Makefile.am     |   3 +-
 cmd/traffic_quic/diags.h         |  96 ++++++++++++++++++++++++++++
 cmd/traffic_quic/quic_client.cc  |  70 ++++++++++++++++++++
 cmd/traffic_quic/quic_client.h   |  40 ++++++++++++
 cmd/traffic_quic/traffic_quic.cc | 134 +--------------------------------------
 5 files changed, 211 insertions(+), 132 deletions(-)

diff --git a/cmd/traffic_quic/Makefile.am b/cmd/traffic_quic/Makefile.am
index a737ade..fdca056 100644
--- a/cmd/traffic_quic/Makefile.am
+++ b/cmd/traffic_quic/Makefile.am
@@ -37,6 +37,7 @@ traffic_quic_LDFLAGS = \
   @AM_LDFLAGS@
 
 traffic_quic_SOURCES = \
+  quic_client.cc \
   traffic_quic.cc
 
 traffic_quic_LDADD = \
@@ -46,9 +47,9 @@ traffic_quic_LDADD = \
   $(top_builddir)/mgmt/libmgmt_p.la \
   $(top_builddir)/lib/records/librecords_p.a \
   $(top_builddir)/lib/ts/libtsutil.la \
-  $(top_builddir)/proxy/ParentSelectionStrategy.o \
   $(top_builddir)/lib/tsconfig/libtsconfig.la \
   $(top_builddir)/lib/luajit/src/libluajit.a \
+  $(top_builddir)/proxy/ParentSelectionStrategy.o \
   @LIBTCL@ \
   @HWLOC_LIBS@ \
   @OPENSSL_LIBS@
diff --git a/cmd/traffic_quic/diags.h b/cmd/traffic_quic/diags.h
new file mode 100644
index 0000000..21c4e73
--- /dev/null
+++ b/cmd/traffic_quic/diags.h
@@ -0,0 +1,96 @@
+/** @file
+ *
+ *  A brief file description
+ *
+ *  @section license License
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+// copy from iocore/utils/diags.i
+#pragma once
+
+#include "ts/Diags.h"
+
+#define DIAGS_LOG_FILE "diags.log"
+
+static void
+reconfigure_diags()
+{
+  int i;
+  DiagsConfigState c;
+
+  // initial value set to 0 or 1 based on command line tags
+  c.enabled[DiagsTagType_Debug]  = (diags->base_debug_tags != nullptr);
+  c.enabled[DiagsTagType_Action] = (diags->base_action_tags != nullptr);
+
+  c.enabled[DiagsTagType_Debug]  = 1;
+  c.enabled[DiagsTagType_Action] = 1;
+  diags->show_location           = SHOW_LOCATION_ALL;
+
+  // read output routing values
+  for (i = 0; i < DL_Status; i++) {
+    c.outputs[i].to_stdout   = 0;
+    c.outputs[i].to_stderr   = 1;
+    c.outputs[i].to_syslog   = 0;
+    c.outputs[i].to_diagslog = 0;
+  }
+
+  for (i = DL_Status; i < DiagsLevel_Count; i++) {
+    c.outputs[i].to_stdout   = 0;
+    c.outputs[i].to_stderr   = 0;
+    c.outputs[i].to_syslog   = 0;
+    c.outputs[i].to_diagslog = 1;
+  }
+
+  //////////////////////////////
+  // clear out old tag tables //
+  //////////////////////////////
+
+  diags->deactivate_all(DiagsTagType_Debug);
+  diags->deactivate_all(DiagsTagType_Action);
+
+  //////////////////////////////////////////////////////////////////////
+  //                     add new tag tables
+  //////////////////////////////////////////////////////////////////////
+
+  if (diags->base_debug_tags)
+    diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
+  if (diags->base_action_tags)
+    diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
+
+////////////////////////////////////
+// change the diags config values //
+////////////////////////////////////
+#if !defined(__GNUC__) && !defined(hpux)
+  diags->config = c;
+#else
+  memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
+#endif
+}
+
+static void
+init_diags(const char *bdt, const char *bat)
+{
+  char diags_logpath[500];
+  strcpy(diags_logpath, DIAGS_LOG_FILE);
+
+  diags = new Diags("Client", bdt, bat, new BaseLogFile(diags_logpath));
+  Status("opened %s", diags_logpath);
+
+  reconfigure_diags();
+}
diff --git a/cmd/traffic_quic/quic_client.cc b/cmd/traffic_quic/quic_client.cc
new file mode 100644
index 0000000..7225cfe
--- /dev/null
+++ b/cmd/traffic_quic/quic_client.cc
@@ -0,0 +1,70 @@
+/** @file
+ *
+ *  A brief file description
+ *
+ *  @section license License
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#include "quic_client.h"
+
+// Similar to HttpSM::state_http_server_open(int event, void *data)
+int
+QUICClient::state_http_server_open(int event, void *data)
+{
+  switch (event) {
+  case NET_EVENT_OPEN: {
+    // TODO: create ProxyServerSession / ProxyServerTransaction
+    // TODO: send HTTP/0.9 message
+    Debug("quic_client", "start proxy server ssn/txn");
+    break;
+  }
+  case NET_EVENT_OPEN_FAILED: {
+    ink_assert(false);
+    break;
+  }
+  case NET_EVENT_ACCEPT: {
+    // do nothing
+    break;
+  }
+  default:
+    ink_assert(false);
+  }
+
+  return 0;
+}
+
+void
+QUICClient::start()
+{
+  SET_HANDLER(&QUICClient::state_http_server_open);
+
+  // TODO: getdddrinfo
+  sockaddr_in addr;
+  addr.sin_family      = AF_INET;
+  addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+  addr.sin_port        = htons(this->_remote_port);
+
+  NetVCOptions opt;
+  opt.ip_proto  = NetVCOptions::USE_UDP;
+  opt.ip_family = addr.sin_family;
+
+  SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+
+  quic_NetProcessor.connect_re(this, reinterpret_cast<sockaddr const *>(&addr), &opt);
+}
diff --git a/cmd/traffic_quic/quic_client.h b/cmd/traffic_quic/quic_client.h
new file mode 100644
index 0000000..715d72a
--- /dev/null
+++ b/cmd/traffic_quic/quic_client.h
@@ -0,0 +1,40 @@
+/** @file
+ *
+ *  A brief file description
+ *
+ *  @section license License
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#pragma once
+
+#include "I_EventSystem.h"
+#include "I_NetVConnection.h"
+#include "P_QUICNetProcessor.h"
+
+class QUICClient : public Continuation
+{
+public:
+  QUICClient(const char *addr, int port) : Continuation(new_ProxyMutex()), _remote_port(port) { SET_HANDLER(&QUICClient::start); };
+  void start();
+  int state_http_server_open(int event, void *data);
+
+private:
+  // char *_remote_addr = nullptr;
+  int _remote_port = 0;
+};
diff --git a/cmd/traffic_quic/traffic_quic.cc b/cmd/traffic_quic/traffic_quic.cc
index 6d45552..88450d5 100644
--- a/cmd/traffic_quic/traffic_quic.cc
+++ b/cmd/traffic_quic/traffic_quic.cc
@@ -21,146 +21,18 @@
  *  limitations under the License.
  */
 
-#include "I_EventSystem.h"
-#include "I_NetVConnection.h"
-#include "P_QUICNetProcessor.h"
-
 #include "ts/ink_string.h"
 #include "ts/ink_args.h"
 #include "ts/I_Layout.h"
 #include "ts/I_Version.h"
 
+#include "diags.h"
+#include "quic_client.h"
+
 #define THREADS 1
-#define DIAGS_LOG_FILE "diags.log"
 
 constexpr size_t stacksize = 1048576;
 
-// copy from iocore/utils/diags.i
-static void
-reconfigure_diags()
-{
-  int i;
-  DiagsConfigState c;
-
-  // initial value set to 0 or 1 based on command line tags
-  c.enabled[DiagsTagType_Debug]  = (diags->base_debug_tags != nullptr);
-  c.enabled[DiagsTagType_Action] = (diags->base_action_tags != nullptr);
-
-  c.enabled[DiagsTagType_Debug]  = 1;
-  c.enabled[DiagsTagType_Action] = 1;
-  diags->show_location           = SHOW_LOCATION_ALL;
-
-  // read output routing values
-  for (i = 0; i < DL_Status; i++) {
-    c.outputs[i].to_stdout   = 0;
-    c.outputs[i].to_stderr   = 1;
-    c.outputs[i].to_syslog   = 0;
-    c.outputs[i].to_diagslog = 0;
-  }
-
-  for (i = DL_Status; i < DiagsLevel_Count; i++) {
-    c.outputs[i].to_stdout   = 0;
-    c.outputs[i].to_stderr   = 0;
-    c.outputs[i].to_syslog   = 0;
-    c.outputs[i].to_diagslog = 1;
-  }
-
-  //////////////////////////////
-  // clear out old tag tables //
-  //////////////////////////////
-
-  diags->deactivate_all(DiagsTagType_Debug);
-  diags->deactivate_all(DiagsTagType_Action);
-
-  //////////////////////////////////////////////////////////////////////
-  //                     add new tag tables
-  //////////////////////////////////////////////////////////////////////
-
-  if (diags->base_debug_tags)
-    diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
-  if (diags->base_action_tags)
-    diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-////////////////////////////////////
-// change the diags config values //
-////////////////////////////////////
-#if !defined(__GNUC__) && !defined(hpux)
-  diags->config = c;
-#else
-  memcpy(((void *)&diags->config), ((void *)&c), sizeof(DiagsConfigState));
-#endif
-}
-
-static void
-init_diags(const char *bdt, const char *bat)
-{
-  char diags_logpath[500];
-  strcpy(diags_logpath, DIAGS_LOG_FILE);
-
-  diags = new Diags("Client", bdt, bat, new BaseLogFile(diags_logpath));
-  Status("opened %s", diags_logpath);
-
-  reconfigure_diags();
-}
-
-class QUICClient : public Continuation
-{
-public:
-  QUICClient(const char *addr, int port) : Continuation(new_ProxyMutex()), _remote_port(port) { SET_HANDLER(&QUICClient::start); };
-  void start();
-  int state_http_server_open(int event, void *data);
-
-private:
-  // char *_remote_addr = nullptr;
-  int _remote_port = 0;
-};
-
-// Similar to HttpSM::state_http_server_open(int event, void *data)
-int
-QUICClient::state_http_server_open(int event, void *data)
-{
-  switch (event) {
-  case NET_EVENT_OPEN: {
-    // TODO: create ProxyServerSession / ProxyServerTransaction
-    // TODO: send HTTP/0.9 message
-    Debug("quic_client", "start proxy server ssn/txn");
-    break;
-  }
-  case NET_EVENT_OPEN_FAILED: {
-    ink_assert(false);
-    break;
-  }
-  case NET_EVENT_ACCEPT: {
-    // do nothing
-    break;
-  }
-  default:
-    ink_assert(false);
-  }
-
-  return 0;
-}
-
-void
-QUICClient::start()
-{
-  SET_HANDLER(&QUICClient::state_http_server_open);
-
-  // TODO: getdddrinfo
-  sockaddr_in addr;
-  addr.sin_family      = AF_INET;
-  addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-  addr.sin_port        = htons(this->_remote_port);
-
-  NetVCOptions opt;
-  opt.ip_proto  = NetVCOptions::USE_UDP;
-  opt.ip_family = addr.sin_family;
-
-  SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
-
-  quic_NetProcessor.connect_re(this, reinterpret_cast<sockaddr const *>(&addr), &opt);
-}
-
 // TODO: Support QUIC version, cipher suite ...etc
 // TODO: Support qdrive tests
 //   https://github.com/ekr/qdrive

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

[trafficserver] 02/02: Support taking address and port on traffic_quic cmd

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 a149a1f251e54a0904e38906459bacf8dae38278
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Mon Jan 15 12:00:04 2018 +0900

    Support taking address and port on traffic_quic cmd
---
 cmd/traffic_quic/quic_client.cc  | 58 ++++++++++++++++++++++++++--------------
 cmd/traffic_quic/quic_client.h   | 12 ++++++---
 cmd/traffic_quic/traffic_quic.cc |  6 ++---
 iocore/net/QUICNetProcessor.cc   |  6 ++---
 4 files changed, 53 insertions(+), 29 deletions(-)

diff --git a/cmd/traffic_quic/quic_client.cc b/cmd/traffic_quic/quic_client.cc
index 7225cfe..ec53e04 100644
--- a/cmd/traffic_quic/quic_client.cc
+++ b/cmd/traffic_quic/quic_client.cc
@@ -23,6 +23,44 @@
 
 #include "quic_client.h"
 
+QUICClient::~QUICClient()
+{
+  freeaddrinfo(this->_remote_addr_info);
+}
+
+void
+QUICClient::start()
+{
+  SET_HANDLER(&QUICClient::state_http_server_open);
+
+  struct addrinfo hints;
+
+  memset(&hints, 0, sizeof(struct addrinfo));
+  hints.ai_family   = AF_UNSPEC;
+  hints.ai_socktype = SOCK_DGRAM;
+  hints.ai_flags    = 0;
+  hints.ai_protocol = 0;
+
+  int res = getaddrinfo(this->_remote_addr, this->_remote_port, &hints, &this->_remote_addr_info);
+  if (res < 0) {
+    Debug("quic_client", "Error: %s (%d)", strerror(errno), errno);
+    return;
+  }
+
+  for (struct addrinfo *info = this->_remote_addr_info; info != nullptr; info = info->ai_next) {
+    NetVCOptions opt;
+    opt.ip_proto  = NetVCOptions::USE_UDP;
+    opt.ip_family = info->ai_family;
+
+    SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+
+    Action *action = quic_NetProcessor.connect_re(this, info->ai_addr, &opt);
+    if (action == ACTION_RESULT_DONE) {
+      break;
+    }
+  }
+}
+
 // Similar to HttpSM::state_http_server_open(int event, void *data)
 int
 QUICClient::state_http_server_open(int event, void *data)
@@ -48,23 +86,3 @@ QUICClient::state_http_server_open(int event, void *data)
 
   return 0;
 }
-
-void
-QUICClient::start()
-{
-  SET_HANDLER(&QUICClient::state_http_server_open);
-
-  // TODO: getdddrinfo
-  sockaddr_in addr;
-  addr.sin_family      = AF_INET;
-  addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-  addr.sin_port        = htons(this->_remote_port);
-
-  NetVCOptions opt;
-  opt.ip_proto  = NetVCOptions::USE_UDP;
-  opt.ip_family = addr.sin_family;
-
-  SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
-
-  quic_NetProcessor.connect_re(this, reinterpret_cast<sockaddr const *>(&addr), &opt);
-}
diff --git a/cmd/traffic_quic/quic_client.h b/cmd/traffic_quic/quic_client.h
index 715d72a..05d0c47 100644
--- a/cmd/traffic_quic/quic_client.h
+++ b/cmd/traffic_quic/quic_client.h
@@ -30,11 +30,17 @@
 class QUICClient : public Continuation
 {
 public:
-  QUICClient(const char *addr, int port) : Continuation(new_ProxyMutex()), _remote_port(port) { SET_HANDLER(&QUICClient::start); };
+  QUICClient(const char *addr, const char *port) : Continuation(new_ProxyMutex()), _remote_addr(addr), _remote_port(port)
+  {
+    SET_HANDLER(&QUICClient::start);
+  };
+  ~QUICClient();
+
   void start();
   int state_http_server_open(int event, void *data);
 
 private:
-  // char *_remote_addr = nullptr;
-  int _remote_port = 0;
+  const char *_remote_addr;
+  const char *_remote_port;
+  struct addrinfo *_remote_addr_info = nullptr;
 };
diff --git a/cmd/traffic_quic/traffic_quic.cc b/cmd/traffic_quic/traffic_quic.cc
index 88450d5..f153e8f 100644
--- a/cmd/traffic_quic/traffic_quic.cc
+++ b/cmd/traffic_quic/traffic_quic.cc
@@ -47,13 +47,13 @@ main(int argc, const char **argv)
   AppVersionInfo appVersionInfo;
   appVersionInfo.setup(PACKAGE_NAME, "traffic_quic", PACKAGE_VERSION, __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
 
-  char addr[1024]       = "";
-  int port              = 4433;
+  char addr[1024]       = "127.0.0.1";
+  char port[16]         = "4433";
   char debug_tags[1024] = "quic|udp";
 
   const ArgumentDescription argument_descriptions[] = {
     {"addr", 'a', "Address", "S1023", addr, nullptr, nullptr},
-    {"port", 'p', "Port", "I", &port, nullptr, nullptr},
+    {"port", 'p', "Port", "S15", port, nullptr, nullptr},
     {"debug", 'T', "Vertical-bar-separated Debug Tags", "S1023", debug_tags, nullptr, nullptr},
     HELP_ARGUMENT_DESCRIPTION(),
     VERSION_ARGUMENT_DESCRIPTION(),
diff --git a/iocore/net/QUICNetProcessor.cc b/iocore/net/QUICNetProcessor.cc
index 31740f5..01a4462 100644
--- a/iocore/net/QUICNetProcessor.cc
+++ b/iocore/net/QUICNetProcessor.cc
@@ -119,7 +119,7 @@ QUICNetProcessor::connect_re(Continuation *cont, sockaddr const *remote_addr, Ne
   ink_assert(t);
 
   sockaddr_in local_addr;
-  local_addr.sin_family      = AF_INET;
+  local_addr.sin_family      = remote_addr->sa_family;
   local_addr.sin_addr.s_addr = htonl(INADDR_ANY);
   local_addr.sin_port        = 0;
 
@@ -142,7 +142,7 @@ QUICNetProcessor::connect_re(Continuation *cont, sockaddr const *remote_addr, Ne
   // FIXME: create QUICPacketHandler for Client (origin server side)
   QUICPacketHandler *packet_handler = new QUICPacketHandler(accept_opt, this->_ssl_ctx);
   packet_handler->init_accept(t);
-  packet_handler->action_ = new NetAcceptAction();
+  packet_handler->action_  = new NetAcceptAction();
   *packet_handler->action_ = cont;
 
   con->setBinding(reinterpret_cast<sockaddr const *>(&local_addr));
@@ -152,7 +152,7 @@ QUICNetProcessor::connect_re(Continuation *cont, sockaddr const *remote_addr, Ne
   PollDescriptor *pd = pc->pollDescriptor;
 
   errno = 0;
-  res = con->ep.start(pd, con, EVENTIO_READ);
+  res   = con->ep.start(pd, con, EVENTIO_READ);
   if (res < 0) {
     Debug("udpnet", "Error: %s (%d)", strerror(errno), errno);
   }

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