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 041f420 Print lower 64 bits of source CID at maximum 041f420 is described below commit 041f420e53290181e841fbbb61e09610d8f40c44 Author: Masakazu Kitajo <mas...@apache.org> AuthorDate: Wed May 16 17:35:13 2018 +0900 Print lower 64 bits of source CID at maximum --- iocore/net/P_QUICNetVConnection.h | 4 +-- iocore/net/QUICNetVConnection.cc | 49 +++++++++++++---------------- iocore/net/QUICPacketHandler.cc | 14 ++++----- iocore/net/quic/QUICApplication.cc | 2 +- iocore/net/quic/QUICCongestionController.cc | 24 +++++++------- iocore/net/quic/QUICConnection.h | 14 ++++----- iocore/net/quic/QUICHandshake.cc | 6 ++-- iocore/net/quic/QUICLossDetector.cc | 3 +- iocore/net/quic/QUICStream.cc | 12 +++---- iocore/net/quic/QUICTypes.cc | 14 +++++++++ iocore/net/quic/QUICTypes.h | 5 +++ 11 files changed, 78 insertions(+), 69 deletions(-) diff --git a/iocore/net/P_QUICNetVConnection.h b/iocore/net/P_QUICNetVConnection.h index a327772..c64e072 100644 --- a/iocore/net/P_QUICNetVConnection.h +++ b/iocore/net/P_QUICNetVConnection.h @@ -231,8 +231,8 @@ private: QUICConnectionId _quic_connection_id; QUICFiveTuple _five_tuple; - UDPConnection *_udp_con = nullptr; - QUICPacketHandler *_packet_handler = nullptr; + UDPConnection *_udp_con = nullptr; + QUICPacketHandler *_packet_handler = nullptr; QUICPacketFactory _packet_factory; QUICFrameFactory _frame_factory; QUICAckFrameCreator _ack_frame_creator; diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc index a924e74..d0f6bef 100644 --- a/iocore/net/QUICNetVConnection.cc +++ b/iocore/net/QUICNetVConnection.cc @@ -43,15 +43,13 @@ #define STATE_FROM_VIO(_x) ((NetState *)(((char *)(_x)) - STATE_VIO_OFFSET)) #define STATE_VIO_OFFSET ((uintptr_t) & ((NetState *)0)->vio) -#define QUICConDebug(fmt, ...) \ - Debug("quic_net", "[%" PRIx64 "] " fmt, static_cast<uint64_t>(this->_quic_connection_id), ##__VA_ARGS__) +#define QUICConDebug(fmt, ...) Debug("quic_net", "[%" PRIx64 "] " fmt, this->_peer_quic_connection_id.l64(), ##__VA_ARGS__) -#define QUICConVDebug(fmt, ...) \ - Debug("v_quic_net", "[%" PRIx64 "] " fmt, static_cast<uint64_t>(this->_quic_connection_id), ##__VA_ARGS__) +#define QUICConVDebug(fmt, ...) Debug("v_quic_net", "[%" PRIx64 "] " fmt, this->_peer_quic_connection_id.l64(), ##__VA_ARGS__) -#define QUICError(fmt, ...) \ - Debug("quic_net", "[%" PRIx64 "] " fmt, static_cast<uint64_t>(this->_quic_connection_id), ##__VA_ARGS__); \ - Error("quic_net [%" PRIx64 "] " fmt, static_cast<uint64_t>(this->_quic_connection_id), ##__VA_ARGS__) +#define QUICError(fmt, ...) \ + Debug("quic_net", "[%" PRIx64 "] " fmt, this->_peer_quic_connection_id.l64(), ##__VA_ARGS__); \ + Error("quic_net [%" PRIx64 "] " fmt, this->_peer_quic_connection_id.l64(), ##__VA_ARGS__) static constexpr uint32_t IPV4_HEADER_SIZE = 20; static constexpr uint32_t IPV6_HEADER_SIZE = 40; @@ -87,8 +85,8 @@ QUICNetVConnection::init(QUICConnectionId peer_cid, QUICConnectionId original_ci this->_ctable->insert(this->_original_quic_connection_id, this); } - QUICConDebug("Connection ID %" PRIx64 " has been changed to %" PRIx64, static_cast<uint64_t>(this->_original_quic_connection_id), - static_cast<uint64_t>(this->_quic_connection_id)); + QUICConDebug("Connection ID %" PRIx64 " has been changed to %" PRIx64, this->_original_quic_connection_id.l64(), + this->_quic_connection_id.l64()); } bool @@ -203,13 +201,13 @@ QUICNetVConnection::start() this->_packet_factory.set_hs_protocol(this->_hs_protocol); // Create frame handlers - this->_congestion_controller = new QUICCongestionController(this->connection_id()); + this->_congestion_controller = new QUICCongestionController(this->peer_connection_id()); this->_loss_detector = new QUICLossDetector(this, this->_congestion_controller); this->_remote_flow_controller = new QUICRemoteConnectionFlowController(UINT64_MAX); this->_local_flow_controller = new QUICLocalConnectionFlowController(this->_loss_detector, UINT64_MAX); this->_path_validator = new QUICPathValidator(); this->_stream_manager = - new QUICStreamManager(this->_loss_detector, this->connection_id(), this->_application_map, this->netvc_context); + new QUICStreamManager(this->_loss_detector, this->peer_connection_id(), this->_application_map, this->netvc_context); this->_frame_dispatcher->add_handler(this); this->_frame_dispatcher->add_handler(this->_stream_manager); @@ -455,9 +453,8 @@ QUICNetVConnection::handle_frame(std::shared_ptr<const QUICFrame> frame) switch (frame->type()) { case QUICFrameType::MAX_DATA: this->_remote_flow_controller->forward_limit(std::static_pointer_cast<const QUICMaxDataFrame>(frame)->maximum_data()); - Debug("quic_flow_ctrl", "Connection [%" PRIx64 "] [REMOTE] %" PRIu64 "/%" PRIu64, - static_cast<uint64_t>(this->_quic_connection_id), this->_remote_flow_controller->current_offset(), - this->_remote_flow_controller->current_limit()); + Debug("quic_flow_ctrl", "Connection [%" PRIx64 "] [REMOTE] %" PRIu64 "/%" PRIu64, this->_peer_quic_connection_id.l64(), + this->_remote_flow_controller->current_offset(), this->_remote_flow_controller->current_limit()); this->_schedule_packet_write_ready(); break; @@ -885,8 +882,7 @@ QUICNetVConnection::_state_handshake_process_retry_packet(QUICPacketUPtr packet) // Generate new Connection ID QUICConnectionId tmp = this->_original_quic_connection_id; this->_original_quic_connection_id.randomize(); - QUICConDebug("Connection ID %" PRIx64 " has been changed to %" PRIx64, static_cast<uint64_t>(tmp), - static_cast<uint64_t>(this->_original_quic_connection_id)); + QUICConDebug("Connection ID %" PRIx64 " has been changed to %" PRIx64, tmp.l64(), this->_original_quic_connection_id.l64()); this->_hs_protocol->initialize_key_materials(this->_original_quic_connection_id); @@ -1212,9 +1208,8 @@ QUICNetVConnection::_packetize_frames() ++frame_count; if (frame->type() == QUICFrameType::STREAM) { int ret = this->_remote_flow_controller->update(this->_stream_manager->total_offset_sent()); - Debug("quic_flow_ctrl", "Connection [%" PRIx64 "] [REMOTE] %" PRIu64 "/%" PRIu64, - static_cast<uint64_t>(this->_quic_connection_id), this->_remote_flow_controller->current_offset(), - this->_remote_flow_controller->current_limit()); + Debug("quic_flow_ctrl", "Connection [%" PRIx64 "] [REMOTE] %" PRIu64 "/%" PRIu64, this->_peer_quic_connection_id.l64(), + this->_remote_flow_controller->current_offset(), this->_remote_flow_controller->current_limit()); ink_assert(ret == 0); } this->_store_frame(buf, len, retransmittable, current_packet_type, std::move(frame)); @@ -1285,7 +1280,7 @@ QUICNetVConnection::_recv_and_ack(QUICPacketUPtr packet) } int ret = this->_local_flow_controller->update(this->_stream_manager->total_offset_received()); - Debug("quic_flow_ctrl", "Connection [%" PRIx64 "] [LOCAL] %" PRIu64 "/%" PRIu64, static_cast<uint64_t>(this->_quic_connection_id), + Debug("quic_flow_ctrl", "Connection [%" PRIx64 "] [LOCAL] %" PRIu64 "/%" PRIu64, this->_peer_quic_connection_id.l64(), this->_local_flow_controller->current_offset(), this->_local_flow_controller->current_limit()); if (ret != 0) { return QUICErrorUPtr(new QUICConnectionError(QUICTransErrorCode::FLOW_CONTROL_ERROR)); @@ -1328,7 +1323,8 @@ QUICNetVConnection::_build_packet(ats_unique_buf buf, size_t len, bool retransmi case QUICPacketType::RETRY: // Echo "_largest_received_packet_number" as packet number. Probably this is the packet number from triggering client packet. packet = this->_packet_factory.create_retry_packet(this->_peer_quic_connection_id, this->_quic_connection_id, - this->_packet_recv_queue.largest_received_packet_number(), std::move(buf), len, retransmittable); + this->_packet_recv_queue.largest_received_packet_number(), std::move(buf), + len, retransmittable); break; case QUICPacketType::HANDSHAKE: packet = @@ -1375,11 +1371,10 @@ QUICNetVConnection::_init_flow_control_params(const std::shared_ptr<const QUICTr this->_local_flow_controller->set_limit(local_initial_max_data); this->_remote_flow_controller->set_limit(remote_initial_max_data); - Debug("quic_flow_ctrl", "Connection [%" PRIx64 "] [LOCAL] %" PRIu64 "/%" PRIu64, static_cast<uint64_t>(this->_quic_connection_id), + Debug("quic_flow_ctrl", "Connection [%" PRIx64 "] [LOCAL] %" PRIu64 "/%" PRIu64, this->_peer_quic_connection_id.l64(), this->_local_flow_controller->current_offset(), this->_local_flow_controller->current_limit()); - Debug("quic_flow_ctrl", "Connection [%" PRIx64 "] [REMOTE] %" PRIu64 "/%" PRIu64, - static_cast<uint64_t>(this->_quic_connection_id), this->_remote_flow_controller->current_offset(), - this->_remote_flow_controller->current_limit()); + Debug("quic_flow_ctrl", "Connection [%" PRIx64 "] [REMOTE] %" PRIu64 "/%" PRIu64, this->_peer_quic_connection_id.l64(), + this->_remote_flow_controller->current_offset(), this->_remote_flow_controller->current_limit()); } void @@ -1440,8 +1435,8 @@ QUICNetVConnection::_dequeue_recv_packet(QUICPacketCreationResult &result) if (packet->type() == QUICPacketType::VERSION_NEGOTIATION) { QUICConDebug("Dequeue %s size=%u", QUICDebugNames::packet_type(packet->type()), packet->size()); } else { - QUICConDebug("Dequeue %s pkt_num=%" PRIu64 " size=%u", QUICDebugNames::packet_type(packet->type()), - packet->packet_number(), packet->size()); + QUICConDebug("Dequeue %s pkt_num=%" PRIu64 " size=%u", QUICDebugNames::packet_type(packet->type()), packet->packet_number(), + packet->size()); } break; default: diff --git a/iocore/net/QUICPacketHandler.cc b/iocore/net/QUICPacketHandler.cc index 8954342..17241a8 100644 --- a/iocore/net/QUICPacketHandler.cc +++ b/iocore/net/QUICPacketHandler.cc @@ -74,7 +74,7 @@ QUICPacketHandler::_send_packet(Continuation *c, const QUICPacket &packet, UDPCo // NOTE: p will be enqueued to udpOutQueue of UDPNetHandler ip_port_text_buffer ipb; - Debug("quic_sec", "[%" PRIx64 "] send %s packet to %s, size=%" PRId64, static_cast<uint64_t>(packet.destination_cid()), + Debug("quic_sec", "[%" PRIx64 "] send %s packet to %s, size=%" PRId64, packet.destination_cid().l64(), QUICDebugNames::packet_type(packet.type()), ats_ip_nptop(&udp_packet->to.sa, ipb, sizeof(ipb)), udp_packet->getPktLength()); udp_con->send(c, udp_packet); @@ -178,13 +178,13 @@ QUICPacketHandlerIn::_recv_packet(int event, UDPPacket *udp_packet) if (is_debug_tag_set("quic_sec")) { ip_port_text_buffer ipb; - if (QUICTypeUtil::has_connection_id(reinterpret_cast<const uint8_t *>(block->buf()))) { - QUICConnectionId cid = this->_read_destination_connection_id(block); - Debug("quic_sec", "[%" PRIx64 "] received packet from %s, size=%" PRId64, static_cast<uint64_t>(cid), + if (QUICTypeUtil::has_long_header(reinterpret_cast<const uint8_t *>(block->buf()))) { + QUICConnectionId cid = this->_read_source_connection_id(block); + Debug("quic_sec", "[%" PRIx64 "] received packet from %s, size=%" PRId64, cid.l64(), ats_ip_nptop(&udp_packet->from.sa, ipb, sizeof(ipb)), udp_packet->getPktLength()); } else { - Debug("quic_sec", "received packet from %s, size=%" PRId64 "without CID", - ats_ip_nptop(&udp_packet->from.sa, ipb, sizeof(ipb)), udp_packet->getPktLength()); + Debug("quic_sec", "received packet from %s, size=%" PRId64, ats_ip_nptop(&udp_packet->from.sa, ipb, sizeof(ipb)), + udp_packet->getPktLength()); } } @@ -304,7 +304,7 @@ QUICPacketHandlerOut::_recv_packet(int event, UDPPacket *udp_packet) QUICConnectionId cid = this->_read_destination_connection_id(block); ip_port_text_buffer ipb; - Debug("quic_sec", "[%" PRIx64 "] received packet from %s, size=%" PRId64, static_cast<uint64_t>(cid), + Debug("quic_sec", "[%" PRIx64 "] received packet from %s, size=%" PRId64, cid.l64(), ats_ip_nptop(&udp_packet->from.sa, ipb, sizeof(ipb)), udp_packet->getPktLength()); this->_vc->handle_received_packet(udp_packet); diff --git a/iocore/net/quic/QUICApplication.cc b/iocore/net/quic/QUICApplication.cc index 4283819..b6b4b98 100644 --- a/iocore/net/quic/QUICApplication.cc +++ b/iocore/net/quic/QUICApplication.cc @@ -162,7 +162,7 @@ QUICApplication::reenable(QUICStream *stream) stream_io->read_reenable(); stream_io->write_reenable(); } else { - Debug(tag, "[%" PRIx64 "] Unknown Stream, id: %" PRIx64, static_cast<uint64_t>(this->_qc->connection_id()), stream->id()); + Debug(tag, "[%" PRIx64 "] Unknown Stream, id: %" PRIx64, this->_qc->connection_id().l64(), stream->id()); } return; diff --git a/iocore/net/quic/QUICCongestionController.cc b/iocore/net/quic/QUICCongestionController.cc index 10ea251..8991017 100644 --- a/iocore/net/quic/QUICCongestionController.cc +++ b/iocore/net/quic/QUICCongestionController.cc @@ -26,19 +26,17 @@ #include "QUICConfig.h" -#define QUICCCDebug(fmt, ...) \ - Debug("quic_cc", \ - "[%" PRIx64 "] " \ - "window: %" PRIu32 " bytes: %" PRIu32 " ssthresh: %" PRIu32 " " fmt, \ - static_cast<uint64_t>(this->_connection_id), this->_congestion_window, this->_bytes_in_flight, this->_ssthresh, \ - ##__VA_ARGS__) - -#define QUICCCError(fmt, ...) \ - Error("quic_cc", \ - "[%" PRIx64 "] " \ - "window: %" PRIu32 " bytes: %" PRIu32 " ssthresh: %" PRIu32 " " fmt, \ - static_cast<uint64_t>(this->_connection_id), this->_congestion_window, this->_bytes_in_flight, this->_ssthresh, \ - ##__VA_ARGS__) +#define QUICCCDebug(fmt, ...) \ + Debug("quic_cc", \ + "[%" PRIx64 "] " \ + "window: %" PRIu32 " bytes: %" PRIu32 " ssthresh: %" PRIu32 " " fmt, \ + this->_connection_id.l64(), this->_congestion_window, this->_bytes_in_flight, this->_ssthresh, ##__VA_ARGS__) + +#define QUICCCError(fmt, ...) \ + Error("quic_cc", \ + "[%" PRIx64 "] " \ + "window: %" PRIu32 " bytes: %" PRIu32 " ssthresh: %" PRIu32 " " fmt, \ + this->_connection_id.l64(), this->_congestion_window, this->_bytes_in_flight, this->_ssthresh, ##__VA_ARGS__) QUICCongestionController::QUICCongestionController() : QUICCongestionController(QUICConnectionId::ZERO()) {} diff --git a/iocore/net/quic/QUICConnection.h b/iocore/net/quic/QUICConnection.h index 83c83a8..e7d567b 100644 --- a/iocore/net/quic/QUICConnection.h +++ b/iocore/net/quic/QUICConnection.h @@ -58,11 +58,11 @@ public: virtual QUICStreamManager *stream_manager() = 0; - virtual uint32_t pmtu() = 0; - virtual NetVConnectionContext_t direction() = 0; - virtual SSLNextProtocolSet *next_protocol_set() = 0; - virtual void close(QUICConnectionErrorUPtr error) = 0; - virtual QUICPacketNumber largest_acked_packet_number() = 0; - virtual void handle_received_packet(UDPPacket *packeet) = 0; - virtual bool is_closed() = 0; + virtual uint32_t pmtu() = 0; + virtual NetVConnectionContext_t direction() = 0; + virtual SSLNextProtocolSet *next_protocol_set() = 0; + virtual void close(QUICConnectionErrorUPtr error) = 0; + virtual QUICPacketNumber largest_acked_packet_number() = 0; + virtual void handle_received_packet(UDPPacket *packeet) = 0; + virtual bool is_closed() = 0; }; diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc index 69b5b6f..715c01c 100644 --- a/iocore/net/quic/QUICHandshake.cc +++ b/iocore/net/quic/QUICHandshake.cc @@ -36,11 +36,9 @@ static constexpr char dump_tag[] = "v_quic_handshake_dump_pkt"; -#define QUICHSDebug(fmt, ...) \ - Debug("quic_handshake", "[%" PRIx64 "] " fmt, static_cast<uint64_t>(this->_qc->connection_id()), ##__VA_ARGS__) +#define QUICHSDebug(fmt, ...) Debug("quic_handshake", "[%" PRIx64 "] " fmt, this->_qc->peer_connection_id().l64(), ##__VA_ARGS__) -#define QUICVHSDebug(fmt, ...) \ - Debug("v_quic_handshake", "[%" PRIx64 "] " fmt, static_cast<uint64_t>(this->_qc->connection_id()), ##__VA_ARGS__) +#define QUICVHSDebug(fmt, ...) Debug("v_quic_handshake", "[%" PRIx64 "] " fmt, this->_qc->peer_connection_id().l64(), ##__VA_ARGS__) #define I_WANNA_DUMP_THIS_BUF(buf, len) \ { \ diff --git a/iocore/net/quic/QUICLossDetector.cc b/iocore/net/quic/QUICLossDetector.cc index d385d5e..6ec69aa 100644 --- a/iocore/net/quic/QUICLossDetector.cc +++ b/iocore/net/quic/QUICLossDetector.cc @@ -28,8 +28,7 @@ #include "QUICConfig.h" #include "QUICEvents.h" -#define QUICLDDebug(fmt, ...) \ - Debug("quic_loss_detector", "[%" PRIx64 "] " fmt, static_cast<uint64_t>(this->_connection_id), ##__VA_ARGS__) +#define QUICLDDebug(fmt, ...) Debug("quic_loss_detector", "[%" PRIx64 "] " fmt, this->_connection_id.l64(), ##__VA_ARGS__) QUICLossDetector::QUICLossDetector(QUICPacketTransmitter *transmitter, QUICCongestionController *cc) : _transmitter(transmitter), _cc(cc) diff --git a/iocore/net/quic/QUICStream.cc b/iocore/net/quic/QUICStream.cc index 7c9fafb..c4ac423 100644 --- a/iocore/net/quic/QUICStream.cc +++ b/iocore/net/quic/QUICStream.cc @@ -28,16 +28,16 @@ #include "QUICStreamManager.h" #include "QUICDebugNames.h" -#define QUICStreamDebug(fmt, ...) \ - Debug("quic_stream", "[%" PRIx64 "] [%" PRIx64 "] [%s] " fmt, static_cast<uint64_t>(this->_connection_id), this->_id, \ +#define QUICStreamDebug(fmt, ...) \ + Debug("quic_stream", "[%" PRIx64 "] [%" PRIx64 "] [%s] " fmt, this->_connection_id.l64(), this->_id, \ QUICDebugNames::stream_state(this->_state), ##__VA_ARGS__) -#define QUICVStreamDebug(fmt, ...) \ - Debug("v_quic_stream", "[%" PRIx64 "] [%" PRIx64 "] [%s] " fmt, static_cast<uint64_t>(this->_connection_id), this->_id, \ +#define QUICVStreamDebug(fmt, ...) \ + Debug("v_quic_stream", "[%" PRIx64 "] [%" PRIx64 "] [%s] " fmt, this->_connection_id.l64(), this->_id, \ QUICDebugNames::stream_state(this->_state), ##__VA_ARGS__) -#define QUICStreamFCDebug(fmt, ...) \ - Debug("quic_flow_ctrl", "[%" PRIx64 "] [%" PRIx64 "] [%s] " fmt, static_cast<uint64_t>(this->_connection_id), this->_id, \ +#define QUICStreamFCDebug(fmt, ...) \ + Debug("quic_flow_ctrl", "[%" PRIx64 "] [%" PRIx64 "] [%s] " fmt, this->_connection_id.l64(), this->_id, \ QUICDebugNames::stream_state(this->_state), ##__VA_ARGS__) QUICStream::QUICStream(QUICRTTProvider *rtt_provider, QUICConnectionId cid, QUICStreamId sid, uint64_t recv_max_stream_data, diff --git a/iocore/net/quic/QUICTypes.cc b/iocore/net/quic/QUICTypes.cc index 5fe899f..33a43e2 100644 --- a/iocore/net/quic/QUICTypes.cc +++ b/iocore/net/quic/QUICTypes.cc @@ -21,10 +21,12 @@ * limitations under the License. */ +#include <algorithm> #include "QUICTypes.h" #include "QUICIntUtil.h" bool +#include <algorithm> QUICTypeUtil::has_long_header(const uint8_t *buf) { return (buf[0] & 0x80) != 0; @@ -271,3 +273,15 @@ QUICConnectionId::_hashcode() const (static_cast<uint64_t>(this->_id[2]) << 40) + (static_cast<uint64_t>(this->_id[3]) << 32) + (this->_id[4] << 24) + (this->_id[5] << 16) + (this->_id[6] << 8) + this->_id[7]; } + +uint64_t +QUICConnectionId::l64() const +{ + uint64_t v = 0; + int ndigit = std::min(8U, static_cast<unsigned int>(this->_len)); + int offset = static_cast<unsigned int>(this->_len) - ndigit; + for (int i = 0; i < ndigit; i++) { + v += static_cast<uint64_t>(this->_id[offset + i]) << (8 * (ndigit - i - 1)); + } + return v; +} diff --git a/iocore/net/quic/QUICTypes.h b/iocore/net/quic/QUICTypes.h index 98e49b3..552b685 100644 --- a/iocore/net/quic/QUICTypes.h +++ b/iocore/net/quic/QUICTypes.h @@ -235,6 +235,11 @@ public: return memcmp(this->_id, x._id, sizeof(this->_id)) != 0; } + /* + * This is just for debugging. + */ + uint64_t l64() const; + uint8_t length() const; bool is_zero() const; void randomize(); -- To stop receiving notification emails like this one, please contact mas...@apache.org.