trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From masa...@apache.org
Subject [trafficserver] branch quic-latest updated: Print "[dcid-scid]" in debug log
Date Fri, 01 Jun 2018 07:28:24 GMT
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 8d56b73  Print "[dcid-scid]" in debug log
8d56b73 is described below

commit 8d56b73aad6d58c164aa93f8131f9032ceb32377
Author: Masaori Koshiba <masaori@apache.org>
AuthorDate: Fri Jun 1 16:26:05 2018 +0900

    Print "[dcid-scid]" in debug log
---
 iocore/net/QUICNetVConnection.cc       |  2 +-
 iocore/net/QUICNextProtocolAccept.cc   |  2 +-
 iocore/net/quic/QUICFrameDispatcher.cc | 10 ++++++----
 iocore/net/quic/QUICFrameDispatcher.h  |  7 ++++++-
 iocore/net/quic/QUICPacket.cc          | 19 ++++++++++++++++---
 iocore/net/quic/QUICTLS.cc             |  2 --
 proxy/hq/HQSessionAccept.cc            |  6 +++---
 proxy/hq/QUICSimpleApp.cc              |  7 ++++---
 8 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index f38506d..5d82557 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -209,7 +209,7 @@ QUICNetVConnection::start()
   this->_application_map->set(STREAM_ID_FOR_HANDSHAKE, this->_handshake_handler);
 
   this->_hs_protocol      = this->_handshake_handler->protocol();
-  this->_frame_dispatcher = new QUICFrameDispatcher();
+  this->_frame_dispatcher = new QUICFrameDispatcher(this);
   this->_packet_factory.set_hs_protocol(this->_hs_protocol);
 
   // Create frame handlers
diff --git a/iocore/net/QUICNextProtocolAccept.cc b/iocore/net/QUICNextProtocolAccept.cc
index d96d275..1f721fa 100644
--- a/iocore/net/QUICNextProtocolAccept.cc
+++ b/iocore/net/QUICNextProtocolAccept.cc
@@ -50,7 +50,7 @@ QUICNextProtocolAccept::mainEvent(int event, void *edata)
 {
   QUICNetVConnection *netvc = quic_netvc_cast(event, edata);
 
-  Debug("quic", "[QUICNextProtocolAccept:mainEvent] event %d netvc %p", event, netvc);
+  Debug("v_quic", "[%s] event %d netvc %p", netvc->cids().data(), event, netvc);
   switch (event) {
   case NET_EVENT_ACCEPT:
     ink_release_assert(netvc != nullptr);
diff --git a/iocore/net/quic/QUICFrameDispatcher.cc b/iocore/net/quic/QUICFrameDispatcher.cc
index a6e5876..2419526 100644
--- a/iocore/net/quic/QUICFrameDispatcher.cc
+++ b/iocore/net/quic/QUICFrameDispatcher.cc
@@ -26,9 +26,12 @@
 
 static constexpr char tag[] = "quic_net";
 
+#define QUICDebug(fmt, ...) Debug(tag, "[%s] " fmt, this->_info->cids().data(), ##__VA_ARGS__)
+
 //
 // Frame Dispatcher
 //
+QUICFrameDispatcher::QUICFrameDispatcher(QUICConnectionInfoProvider *info) : _info(info)
{}
 
 void
 QUICFrameDispatcher::add_handler(QUICFrameHandler *handler)
@@ -49,18 +52,17 @@ QUICFrameDispatcher::receive_frames(const uint8_t *payload, uint16_t size,
bool
   while (cursor < size) {
     frame = this->_frame_factory.fast_create(payload + cursor, size - cursor);
     if (frame == nullptr) {
-      Debug(tag, "Failed to create a frame (%u bytes skipped)", size - cursor);
+      QUICDebug("Failed to create a frame (%u bytes skipped)", size - cursor);
       break;
     }
     cursor += frame->size();
 
     QUICFrameType type = frame->type();
 
-    // TODO: check debug build
-    if (type != QUICFrameType::PADDING) {
+    if (is_debug_tag_set(tag) && type != QUICFrameType::PADDING) {
       char msg[1024];
       frame->debug_msg(msg, sizeof(msg));
-      Debug(tag, "[RX] %s", msg);
+      QUICDebug("[RX] %s", msg);
     }
 
     should_send_ack |= (type != QUICFrameType::PADDING && type != QUICFrameType::ACK);
diff --git a/iocore/net/quic/QUICFrameDispatcher.h b/iocore/net/quic/QUICFrameDispatcher.h
index 397f0d3..e9e3a01 100644
--- a/iocore/net/quic/QUICFrameDispatcher.h
+++ b/iocore/net/quic/QUICFrameDispatcher.h
@@ -23,13 +23,17 @@
 
 #pragma once
 
+#include <vector>
+
+#include "QUICConnection.h"
 #include "QUICFrame.h"
 #include "QUICFrameHandler.h"
-#include <vector>
 
 class QUICFrameDispatcher
 {
 public:
+  QUICFrameDispatcher(QUICConnectionInfoProvider *info);
+
   /*
    * Returns true if ACK frame should be sent
    */
@@ -38,6 +42,7 @@ public:
   void add_handler(QUICFrameHandler *handler);
 
 private:
+  QUICConnectionInfoProvider *_info = nullptr;
   QUICFrameFactory _frame_factory;
   std::vector<QUICFrameHandler *> _handlers[256];
 };
diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index 6d27cc3..945bee9 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -27,6 +27,11 @@
 #include "QUICPacket.h"
 #include "QUICDebugNames.h"
 
+static constexpr std::string_view tag = "quic_packet"sv;
+
+#define QUICDebug(dcid, scid, fmt, ...) \
+  Debug(tag.data(), "[%08" PRIx32 "-%08" PRIx32 "] " fmt, dcid.h32(), scid.h32(), ##__VA_ARGS__);
+
 ClassAllocator<QUICPacket> quicPacketAllocator("quicPacketAllocator");
 ClassAllocator<QUICPacketLongHeader> quicPacketLongHeaderAllocator("quicPacketLongHeaderAllocator");
 ClassAllocator<QUICPacketShortHeader> quicPacketShortHeaderAllocator("quicPacketShortHeaderAllocator");
@@ -719,6 +724,11 @@ QUICPacketFactory::create(IpEndpoint from, ats_unique_buf buf, size_t
len, QUICP
 
   QUICPacketHeaderUPtr header = QUICPacketHeader::load(from, std::move(buf), len, base_packet_number,
this->_dcil);
 
+  QUICConnectionId dcid = header->destination_cid();
+  QUICConnectionId scid = header->source_cid();
+  QUICDebug(scid, dcid, "Decrypting %s packet #%" PRIu64 " using %s", QUICDebugNames::packet_type(header->type()),
+            header->packet_number(), QUICDebugNames::key_phase(header->key_phase()));
+
   if (header->has_version() && !QUICTypeUtil::is_supported_version(header->version()))
{
     if (header->type() == QUICPacketType::VERSION_NEGOTIATION) {
       // version of VN packet is 0x00000000
@@ -732,7 +742,6 @@ QUICPacketFactory::create(IpEndpoint from, ats_unique_buf buf, size_t
len, QUICP
     memcpy(plain_txt.get(), header->payload(), header->payload_size());
     plain_txt_len = header->payload_size();
   } else {
-    Debug("quic_packet", "Decrypting %s packet #%" PRIu64, QUICDebugNames::packet_type(header->type()),
header->packet_number());
     switch (header->type()) {
     case QUICPacketType::STATELESS_RESET:
       // These packets are unprotected. Just copy the payload
@@ -935,14 +944,18 @@ QUICPacketFactory::_create_encrypted_packet(QUICPacketHeaderUPtr header,
bool re
   ats_unique_buf cipher_txt = ats_unique_malloc(max_cipher_txt_len);
   size_t cipher_txt_len     = 0;
 
-  Debug("quic_packet", "Encrypting %s packet #%" PRIu64, QUICDebugNames::packet_type(header->type()),
header->packet_number());
+  QUICConnectionId dcid = header->destination_cid();
+  QUICConnectionId scid = header->source_cid();
+  QUICDebug(dcid, scid, "Encrypting %s packet #%" PRIu64 " using %s", QUICDebugNames::packet_type(header->type()),
+            header->packet_number(), QUICDebugNames::key_phase(header->key_phase()));
+
   QUICPacket *packet = nullptr;
   if (this->_hs_protocol->encrypt(cipher_txt.get(), cipher_txt_len, max_cipher_txt_len,
header->payload(), header->payload_size(),
                                   header->packet_number(), header->buf(), header->size(),
header->key_phase())) {
     packet = quicPacketAllocator.alloc();
     new (packet) QUICPacket(std::move(header), std::move(cipher_txt), cipher_txt_len, retransmittable);
   } else {
-    Debug("quic_packet", "Failed to encrypt a packet");
+    QUICDebug(dcid, scid, "Failed to encrypt a packet");
   }
 
   return QUICPacketUPtr(packet, &QUICPacketDeleter::delete_packet);
diff --git a/iocore/net/quic/QUICTLS.cc b/iocore/net/quic/QUICTLS.cc
index cebfaaa..d6b49cf 100644
--- a/iocore/net/quic/QUICTLS.cc
+++ b/iocore/net/quic/QUICTLS.cc
@@ -309,7 +309,6 @@ QUICTLS::encrypt(uint8_t *cipher, size_t &cipher_len, size_t max_cipher_len,
con
                  uint64_t pkt_num, const uint8_t *ad, size_t ad_len, QUICKeyPhase phase)
const
 {
   QUICPacketProtection *pp = nullptr;
-  Debug(tag, "Encrypting packet using %s key", QUICDebugNames::key_phase(phase));
 
   switch (this->_netvc_context) {
   case NET_VCONNECTION_IN: {
@@ -345,7 +344,6 @@ QUICTLS::decrypt(uint8_t *plain, size_t &plain_len, size_t max_plain_len,
const
                  uint64_t pkt_num, const uint8_t *ad, size_t ad_len, QUICKeyPhase phase)
const
 {
   QUICPacketProtection *pp = nullptr;
-  Debug(tag, "Decrypting packet using %s key", QUICDebugNames::key_phase(phase));
 
   switch (this->_netvc_context) {
   case NET_VCONNECTION_IN: {
diff --git a/proxy/hq/HQSessionAccept.cc b/proxy/hq/HQSessionAccept.cc
index 9906a45..4f9299f 100644
--- a/proxy/hq/HQSessionAccept.cc
+++ b/proxy/hq/HQSessionAccept.cc
@@ -47,11 +47,11 @@ HQSessionAccept::accept(NetVConnection *netvc, MIOBuffer *iobuf, IOBufferReader
   }
   netvc->attributes = this->options.transport_type;
 
-  if (is_debug_tag_set("quic_seq")) {
+  if (is_debug_tag_set("hq")) {
     ip_port_text_buffer ipb;
 
-    Debug("quic_seq", "[%" PRIx64 "] accepted connection from %s transport type = %d",
-          static_cast<uint64_t>(static_cast<QUICConnection *>(static_cast<QUICNetVConnection
*>(netvc))->connection_id()),
+    Debug("hq", "[%s] accepted connection from %s transport type = %d",
+          static_cast<QUICConnection *>(static_cast<QUICNetVConnection *>(netvc))->cids().data(),
           ats_ip_nptop(client_ip, ipb, sizeof(ipb)), netvc->attributes);
   }
 
diff --git a/proxy/hq/QUICSimpleApp.cc b/proxy/hq/QUICSimpleApp.cc
index 8ce397e..7dc5027 100644
--- a/proxy/hq/QUICSimpleApp.cc
+++ b/proxy/hq/QUICSimpleApp.cc
@@ -31,7 +31,8 @@
 #include "HQClientTransaction.h"
 #include "../IPAllow.h"
 
-static constexpr char tag[] = "quic_simple_app";
+static constexpr char tag[]   = "quic_simple_app";
+static constexpr char tag_v[] = "v_quic_simple_app";
 
 QUICSimpleApp::QUICSimpleApp(QUICNetVConnection *client_vc) : QUICApplication(client_vc)
 {
@@ -55,13 +56,13 @@ QUICSimpleApp::~QUICSimpleApp()
 int
 QUICSimpleApp::main_event_handler(int event, Event *data)
 {
-  Debug(tag, "[%" PRIx64 "] %s (%d)", static_cast<uint64_t>(this->_qc->connection_id()),
get_vc_event_name(event), event);
+  Debug(tag_v, "[%s] %s (%d)", this->_qc->cids().data(), get_vc_event_name(event),
event);
 
   VIO *vio                = reinterpret_cast<VIO *>(data);
   QUICStreamIO *stream_io = this->_find_stream_io(vio);
 
   if (stream_io == nullptr) {
-    Debug(tag, "[%" PRIx64 "] Unknown Stream", static_cast<uint64_t>(this->_qc->connection_id()));
+    Debug(tag, "[%s] Unknown Stream", this->_qc->cids().data());
     return -1;
   }
 

-- 
To stop receiving notification emails like this one, please contact
masaori@apache.org.

Mime
View raw message