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 6f409c2 Use const references instead of moving QUICPacketUPtr
6f409c2 is described below
commit 6f409c2ef37ae8cec5b3049387c12da610b8b7ac
Author: Masakazu Kitajo <[email protected]>
AuthorDate: Fri Mar 15 13:52:41 2019 +0900
Use const references instead of moving QUICPacketUPtr
---
iocore/net/P_QUICNetVConnection.h | 20 +++----
iocore/net/QUICNetVConnection.cc | 68 +++++++++++-----------
iocore/net/quic/QUICHandshake.cc | 14 ++---
iocore/net/quic/QUICHandshake.h | 4 +-
iocore/net/quic/QUICVersionNegotiator.cc | 12 ++--
iocore/net/quic/QUICVersionNegotiator.h | 2 +-
iocore/net/quic/test/test_QUICVersionNegotiator.cc | 8 +--
7 files changed, 64 insertions(+), 64 deletions(-)
diff --git a/iocore/net/P_QUICNetVConnection.h
b/iocore/net/P_QUICNetVConnection.h
index 18c207b..59432ac 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -296,17 +296,17 @@ private:
QUICPacketUPtr _build_packet(QUICEncryptionLevel level, Ptr<IOBufferBlock>
parent_block, bool retransmittable, bool probing,
bool crypto);
- QUICConnectionErrorUPtr _recv_and_ack(QUICPacket &packet, bool
*has_non_probing_frame = nullptr);
-
- QUICConnectionErrorUPtr _state_handshake_process_packet(QUICPacketUPtr
packet);
- QUICConnectionErrorUPtr
_state_handshake_process_version_negotiation_packet(QUICPacketUPtr packet);
- QUICConnectionErrorUPtr
_state_handshake_process_initial_packet(QUICPacketUPtr packet);
- QUICConnectionErrorUPtr _state_handshake_process_retry_packet(QUICPacketUPtr
packet);
- QUICConnectionErrorUPtr
_state_handshake_process_handshake_packet(QUICPacketUPtr packet);
- QUICConnectionErrorUPtr
_state_handshake_process_zero_rtt_protected_packet(QUICPacketUPtr packet);
+ QUICConnectionErrorUPtr _recv_and_ack(const QUICPacket &packet, bool
*has_non_probing_frame = nullptr);
+
+ QUICConnectionErrorUPtr _state_handshake_process_packet(const QUICPacket
&packet);
+ QUICConnectionErrorUPtr
_state_handshake_process_version_negotiation_packet(const QUICPacket &packet);
+ QUICConnectionErrorUPtr _state_handshake_process_initial_packet(const
QUICPacket &packet);
+ QUICConnectionErrorUPtr _state_handshake_process_retry_packet(const
QUICPacket &packet);
+ QUICConnectionErrorUPtr _state_handshake_process_handshake_packet(const
QUICPacket &packet);
+ QUICConnectionErrorUPtr
_state_handshake_process_zero_rtt_protected_packet(const QUICPacket &packet);
QUICConnectionErrorUPtr _state_connection_established_receive_packet();
- QUICConnectionErrorUPtr
_state_connection_established_process_protected_packet(QUICPacketUPtr packet);
- QUICConnectionErrorUPtr
_state_connection_established_migrate_connection(const QUICPacket &p);
+ QUICConnectionErrorUPtr
_state_connection_established_process_protected_packet(const QUICPacket
&packet);
+ QUICConnectionErrorUPtr
_state_connection_established_migrate_connection(const QUICPacket &packet);
QUICConnectionErrorUPtr
_state_connection_established_initiate_connection_migration();
QUICConnectionErrorUPtr _state_closing_receive_packet();
QUICConnectionErrorUPtr _state_draining_receive_packet();
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index b7067f2..40ef0bf 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -785,7 +785,7 @@ QUICNetVConnection::state_handshake(int event, Event *data)
// - It could be just an errora on lower layer
error = nullptr;
} else if (result == QUICPacketCreationResult::SUCCESS || result ==
QUICPacketCreationResult::UNSUPPORTED) {
- error = this->_state_handshake_process_packet(std::move(packet));
+ error = this->_state_handshake_process_packet(*packet);
}
// if we complete handshake, switch to establish state
@@ -1055,31 +1055,31 @@ QUICNetVConnection::negotiated_application_name() const
}
QUICConnectionErrorUPtr
-QUICNetVConnection::_state_handshake_process_packet(QUICPacketUPtr packet)
+QUICNetVConnection::_state_handshake_process_packet(const QUICPacket &packet)
{
QUICConnectionErrorUPtr error = nullptr;
- switch (packet->type()) {
+ switch (packet.type()) {
case QUICPacketType::VERSION_NEGOTIATION:
- error =
this->_state_handshake_process_version_negotiation_packet(std::move(packet));
+ error = this->_state_handshake_process_version_negotiation_packet(packet);
break;
case QUICPacketType::INITIAL:
- error = this->_state_handshake_process_initial_packet(std::move(packet));
+ error = this->_state_handshake_process_initial_packet(packet);
break;
case QUICPacketType::RETRY:
- error = this->_state_handshake_process_retry_packet(std::move(packet));
+ error = this->_state_handshake_process_retry_packet(packet);
break;
case QUICPacketType::HANDSHAKE:
- error = this->_state_handshake_process_handshake_packet(std::move(packet));
+ error = this->_state_handshake_process_handshake_packet(packet);
if (this->_pp_key_info.is_decryption_key_available(QUICKeyPhase::INITIAL)
&& this->netvc_context == NET_VCONNECTION_IN) {
this->_pp_key_info.drop_keys(QUICKeyPhase::INITIAL);
}
break;
case QUICPacketType::ZERO_RTT_PROTECTED:
- error =
this->_state_handshake_process_zero_rtt_protected_packet(std::move(packet));
+ error = this->_state_handshake_process_zero_rtt_protected_packet(packet);
break;
case QUICPacketType::PROTECTED:
default:
- QUICConDebug("Ignore %s(%" PRIu8 ") packet",
QUICDebugNames::packet_type(packet->type()),
static_cast<uint8_t>(packet->type()));
+ QUICConDebug("Ignore %s(%" PRIu8 ") packet",
QUICDebugNames::packet_type(packet.type()),
static_cast<uint8_t>(packet.type()));
error =
std::make_unique<QUICConnectionError>(QUICTransErrorCode::INTERNAL_ERROR);
break;
@@ -1088,11 +1088,11 @@
QUICNetVConnection::_state_handshake_process_packet(QUICPacketUPtr packet)
}
QUICConnectionErrorUPtr
-QUICNetVConnection::_state_handshake_process_version_negotiation_packet(QUICPacketUPtr
packet)
+QUICNetVConnection::_state_handshake_process_version_negotiation_packet(const
QUICPacket &packet)
{
QUICConnectionErrorUPtr error = nullptr;
- if (packet->destination_cid() != this->connection_id()) {
+ if (packet.destination_cid() != this->connection_id()) {
QUICConDebug("Ignore Version Negotiation packet");
return error;
}
@@ -1100,7 +1100,7 @@
QUICNetVConnection::_state_handshake_process_version_negotiation_packet(QUICPack
if (this->_handshake_handler->is_version_negotiated()) {
QUICConDebug("ignore VN - already negotiated");
} else {
- error = this->_handshake_handler->negotiate_version(packet.get(),
&this->_packet_factory);
+ error = this->_handshake_handler->negotiate_version(packet,
&this->_packet_factory);
// discard all transport state except packet number
for (auto s : QUIC_PN_SPACES) {
@@ -1118,7 +1118,7 @@
QUICNetVConnection::_state_handshake_process_version_negotiation_packet(QUICPack
}
QUICConnectionErrorUPtr
-QUICNetVConnection::_state_handshake_process_initial_packet(QUICPacketUPtr
packet)
+QUICNetVConnection::_state_handshake_process_initial_packet(const QUICPacket
&packet)
{
// QUIC packet could be smaller than MINIMUM_INITIAL_PACKET_SIZE when
coalescing packets
// if (packet->size() < MINIMUM_INITIAL_PACKET_SIZE) {
@@ -1140,12 +1140,11 @@
QUICNetVConnection::_state_handshake_process_initial_packet(QUICPacketUPtr packe
this->_frame_dispatcher->add_handler(this->_alt_con_manager);
}
QUICTPConfigQCP tp_config(this->_quic_config, NET_VCONNECTION_IN);
- error =
- this->_handshake_handler->start(tp_config, packet.get(),
&this->_packet_factory, this->_alt_con_manager->preferred_address());
+ error = this->_handshake_handler->start(tp_config, packet,
&this->_packet_factory, this->_alt_con_manager->preferred_address());
// If version negotiation was failed and VERSION NEGOTIATION packet was
sent, nothing to do.
if (this->_handshake_handler->is_version_negotiated()) {
- error = this->_recv_and_ack(*packet);
+ error = this->_recv_and_ack(packet);
if (error == nullptr && !this->_handshake_handler->has_remote_tp()) {
error =
std::make_unique<QUICConnectionError>(QUICTransErrorCode::TRANSPORT_PARAMETER_ERROR);
@@ -1153,7 +1152,7 @@
QUICNetVConnection::_state_handshake_process_initial_packet(QUICPacketUPtr packe
}
} else {
// on client side, _handshake_handler is already started. Just process
packet like _state_handshake_process_handshake_packet()
- error = this->_recv_and_ack(*packet);
+ error = this->_recv_and_ack(packet);
}
return error;
@@ -1163,7 +1162,7 @@
QUICNetVConnection::_state_handshake_process_initial_packet(QUICPacketUPtr packe
This doesn't call this->_recv_and_ack(), because RETRY packet doesn't have
any frames.
*/
QUICConnectionErrorUPtr
-QUICNetVConnection::_state_handshake_process_retry_packet(QUICPacketUPtr
packet)
+QUICNetVConnection::_state_handshake_process_retry_packet(const QUICPacket
&packet)
{
ink_assert(this->netvc_context == NET_VCONNECTION_OUT);
@@ -1173,9 +1172,9 @@
QUICNetVConnection::_state_handshake_process_retry_packet(QUICPacketUPtr packet)
}
// TODO: move packet->payload to _av_token
- this->_av_token_len = packet->payload_length();
+ this->_av_token_len = packet.payload_length();
this->_av_token = ats_unique_malloc(this->_av_token_len);
- memcpy(this->_av_token.get(), packet->payload(), this->_av_token_len);
+ memcpy(this->_av_token.get(), packet.payload(), this->_av_token_len);
// discard all transport state
this->_handshake_handler->reset();
@@ -1198,32 +1197,32 @@
QUICNetVConnection::_state_handshake_process_retry_packet(QUICPacketUPtr packet)
}
QUICConnectionErrorUPtr
-QUICNetVConnection::_state_handshake_process_handshake_packet(QUICPacketUPtr
packet)
+QUICNetVConnection::_state_handshake_process_handshake_packet(const QUICPacket
&packet)
{
// Source address is verified by receiving any message from the client
encrypted using the
// Handshake keys.
if (this->netvc_context == NET_VCONNECTION_IN &&
!this->_verfied_state.is_verified()) {
this->_verfied_state.set_addr_verifed();
}
- return this->_recv_and_ack(*packet);
+ return this->_recv_and_ack(packet);
}
QUICConnectionErrorUPtr
-QUICNetVConnection::_state_handshake_process_zero_rtt_protected_packet(QUICPacketUPtr
packet)
+QUICNetVConnection::_state_handshake_process_zero_rtt_protected_packet(const
QUICPacket &packet)
{
this->_stream_manager->init_flow_control_params(this->_handshake_handler->local_transport_parameters(),
this->_handshake_handler->remote_transport_parameters());
this->_start_application();
- return this->_recv_and_ack(*packet);
+ return this->_recv_and_ack(packet);
}
QUICConnectionErrorUPtr
-QUICNetVConnection::_state_connection_established_process_protected_packet(QUICPacketUPtr
packet)
+QUICNetVConnection::_state_connection_established_process_protected_packet(const
QUICPacket &packet)
{
QUICConnectionErrorUPtr error = nullptr;
bool has_non_probing_frame = false;
- error = this->_recv_and_ack(*packet, &has_non_probing_frame);
+ error = this->_recv_and_ack(packet, &has_non_probing_frame);
if (error != nullptr) {
return error;
}
@@ -1234,11 +1233,11 @@
QUICNetVConnection::_state_connection_established_process_protected_packet(QUICP
// on the old path until they initiate migration.
// if (packet.destination_cid() == this->_quic_connection_id &&
has_non_probing_frame) {
if (this->_alt_con_manager != nullptr) {
- if (packet->destination_cid() != this->_quic_connection_id ||
!ats_ip_addr_port_eq(packet->from(), this->remote_addr)) {
+ if (packet.destination_cid() != this->_quic_connection_id ||
!ats_ip_addr_port_eq(packet.from(), this->remote_addr)) {
if (!has_non_probing_frame) {
QUICConDebug("FIXME: Connection migration has been initiated without
non-probing frames");
}
- error = this->_state_connection_established_migrate_connection(*packet);
+ error = this->_state_connection_established_migrate_connection(packet);
if (error != nullptr) {
return error;
}
@@ -1262,7 +1261,7 @@
QUICNetVConnection::_state_connection_established_receive_packet()
// Receive a QUIC packet
net_activity(this, this_ethread());
do {
- QUICPacketUPtr p = this->_dequeue_recv_packet(result);
+ QUICPacketUPtr packet = this->_dequeue_recv_packet(result);
if (result == QUICPacketCreationResult::FAILED) {
// Don't make this error, and discard the packet.
// Because:
@@ -1278,18 +1277,19 @@
QUICNetVConnection::_state_connection_established_receive_packet()
}
// Process the packet
- switch (p->type()) {
+ switch (packet->type()) {
case QUICPacketType::PROTECTED:
- error =
this->_state_connection_established_process_protected_packet(std::move(p));
+ error =
this->_state_connection_established_process_protected_packet(*packet);
break;
case QUICPacketType::INITIAL:
case QUICPacketType::HANDSHAKE:
case QUICPacketType::ZERO_RTT_PROTECTED:
// Pass packet to _recv_and_ack to send ack to the packet. Stream data
will be discarded by offset mismatch.
- error = this->_recv_and_ack(*p);
+ error = this->_recv_and_ack(*packet);
break;
default:
- QUICConDebug("Unknown packet type: %s(%" PRIu8 ")",
QUICDebugNames::packet_type(p->type()), static_cast<uint8_t>(p->type()));
+ QUICConDebug("Unknown packet type: %s(%" PRIu8 ")",
QUICDebugNames::packet_type(packet->type()),
+ static_cast<uint8_t>(packet->type()));
error =
std::make_unique<QUICConnectionError>(QUICTransErrorCode::INTERNAL_ERROR);
break;
@@ -1652,7 +1652,7 @@ QUICNetVConnection::_packetize_closing_frame()
}
QUICConnectionErrorUPtr
-QUICNetVConnection::_recv_and_ack(QUICPacket &packet, bool
*has_non_probing_frame)
+QUICNetVConnection::_recv_and_ack(const QUICPacket &packet, bool
*has_non_probing_frame)
{
ink_assert(packet.type() != QUICPacketType::RETRY);
diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc
index 475112c..ca8d120 100644
--- a/iocore/net/quic/QUICHandshake.cc
+++ b/iocore/net/quic/QUICHandshake.cc
@@ -119,18 +119,18 @@ QUICHandshake::start(const QUICTPConfig &tp_config,
QUICPacketFactory *packet_fa
}
QUICConnectionErrorUPtr
-QUICHandshake::start(const QUICTPConfig &tp_config, const QUICPacket
*initial_packet, QUICPacketFactory *packet_factory,
+QUICHandshake::start(const QUICTPConfig &tp_config, const QUICPacket
&initial_packet, QUICPacketFactory *packet_factory,
const QUICPreferredAddress *pref_addr)
{
// Negotiate version
if (this->_version_negotiator->status() ==
QUICVersionNegotiationStatus::NOT_NEGOTIATED) {
- if (initial_packet->type() != QUICPacketType::INITIAL) {
+ if (initial_packet.type() != QUICPacketType::INITIAL) {
return
std::make_unique<QUICConnectionError>(QUICTransErrorCode::PROTOCOL_VIOLATION);
}
- if (initial_packet->version()) {
+ if (initial_packet.version()) {
if (this->_version_negotiator->negotiate(initial_packet) ==
QUICVersionNegotiationStatus::NEGOTIATED) {
- QUICHSDebug("Version negotiation succeeded: %x",
initial_packet->version());
- this->_load_local_server_transport_parameters(tp_config,
initial_packet->version(), pref_addr);
+ QUICHSDebug("Version negotiation succeeded: %x",
initial_packet.version());
+ this->_load_local_server_transport_parameters(tp_config,
initial_packet.version(), pref_addr);
packet_factory->set_version(this->_version_negotiator->negotiated_version());
} else {
ink_assert(!"Unsupported version initial packet should be droped
QUICPakcetHandler");
@@ -143,7 +143,7 @@ QUICHandshake::start(const QUICTPConfig &tp_config, const
QUICPacket *initial_pa
}
QUICConnectionErrorUPtr
-QUICHandshake::negotiate_version(const QUICPacket *vn, QUICPacketFactory
*packet_factory)
+QUICHandshake::negotiate_version(const QUICPacket &vn, QUICPacketFactory
*packet_factory)
{
// Client side only
ink_assert(this->_qc->direction() == NET_VCONNECTION_OUT);
@@ -155,7 +155,7 @@ QUICHandshake::negotiate_version(const QUICPacket *vn,
QUICPacketFactory *packet
return nullptr;
}
- if (vn->version() != 0x00) {
+ if (vn.version() != 0x00) {
QUICHSDebug("Version field must be 0x00000000");
return
std::make_unique<QUICConnectionError>(QUICTransErrorCode::PROTOCOL_VIOLATION);
}
diff --git a/iocore/net/quic/QUICHandshake.h b/iocore/net/quic/QUICHandshake.h
index 0cdb94d..5ce46b9 100644
--- a/iocore/net/quic/QUICHandshake.h
+++ b/iocore/net/quic/QUICHandshake.h
@@ -57,11 +57,11 @@ public:
// for client side
QUICConnectionErrorUPtr start(const QUICTPConfig &tp_config,
QUICPacketFactory *packet_factory, bool vn_exercise_enabled);
- QUICConnectionErrorUPtr negotiate_version(const QUICPacket *packet,
QUICPacketFactory *packet_factory);
+ QUICConnectionErrorUPtr negotiate_version(const QUICPacket &packet,
QUICPacketFactory *packet_factory);
void reset();
// for server side
- QUICConnectionErrorUPtr start(const QUICTPConfig &tp_config, const
QUICPacket *initial_packet, QUICPacketFactory *packet_factory,
+ QUICConnectionErrorUPtr start(const QUICTPConfig &tp_config, const
QUICPacket &initial_packet, QUICPacketFactory *packet_factory,
const QUICPreferredAddress *pref_addr);
QUICConnectionErrorUPtr do_handshake();
diff --git a/iocore/net/quic/QUICVersionNegotiator.cc
b/iocore/net/quic/QUICVersionNegotiator.cc
index f325fd0..677c134 100644
--- a/iocore/net/quic/QUICVersionNegotiator.cc
+++ b/iocore/net/quic/QUICVersionNegotiator.cc
@@ -31,20 +31,20 @@ QUICVersionNegotiator::status()
}
QUICVersionNegotiationStatus
-QUICVersionNegotiator::negotiate(const QUICPacket *packet)
+QUICVersionNegotiator::negotiate(const QUICPacket &packet)
{
- switch (packet->type()) {
+ switch (packet.type()) {
case QUICPacketType::INITIAL: {
- if (QUICTypeUtil::is_supported_version(packet->version())) {
+ if (QUICTypeUtil::is_supported_version(packet.version())) {
this->_status = QUICVersionNegotiationStatus::NEGOTIATED;
- this->_negotiated_version = packet->version();
+ this->_negotiated_version = packet.version();
}
break;
}
case QUICPacketType::VERSION_NEGOTIATION: {
- const uint8_t *supported_versions = packet->payload();
- uint16_t supported_versions_len = packet->payload_length();
+ const uint8_t *supported_versions = packet.payload();
+ uint16_t supported_versions_len = packet.payload_length();
uint16_t len = 0;
while (len < supported_versions_len) {
diff --git a/iocore/net/quic/QUICVersionNegotiator.h
b/iocore/net/quic/QUICVersionNegotiator.h
index c59d59e..a931e05 100644
--- a/iocore/net/quic/QUICVersionNegotiator.h
+++ b/iocore/net/quic/QUICVersionNegotiator.h
@@ -35,7 +35,7 @@ class QUICVersionNegotiator
{
public:
QUICVersionNegotiationStatus status();
- QUICVersionNegotiationStatus negotiate(const QUICPacket *initial_packet);
+ QUICVersionNegotiationStatus negotiate(const QUICPacket &initial_packet);
QUICVersionNegotiationStatus validate(const
QUICTransportParametersInClientHello *tp);
QUICVersionNegotiationStatus validate(const
QUICTransportParametersInEncryptedExtensions *tp);
QUICVersion negotiated_version();
diff --git a/iocore/net/quic/test/test_QUICVersionNegotiator.cc
b/iocore/net/quic/test/test_QUICVersionNegotiator.cc
index 9a1b9c8..174d50c 100644
--- a/iocore/net/quic/test/test_QUICVersionNegotiator.cc
+++ b/iocore/net/quic/test/test_QUICVersionNegotiator.cc
@@ -44,7 +44,7 @@ TEST_CASE("QUICVersionNegotiator - Server Side", "[quic]")
packet_factory.set_version(QUIC_SUPPORTED_VERSIONS[0]);
QUICPacketUPtr initial_packet =
packet_factory.create_initial_packet({}, {}, 0,
std::move(dummy_payload), dummy_payload_len, true, false, true);
- vn.negotiate(initial_packet.get());
+ vn.negotiate(*initial_packet);
CHECK(vn.status() == QUICVersionNegotiationStatus::NEGOTIATED);
// Validate version
@@ -63,7 +63,7 @@ TEST_CASE("QUICVersionNegotiator - Server Side", "[quic]")
packet_factory.set_version(QUIC_SUPPORTED_VERSIONS[0]);
QUICPacketUPtr initial_packet =
packet_factory.create_initial_packet({}, {}, 0,
std::move(dummy_payload), dummy_payload_len, true, false, true);
- vn.negotiate(initial_packet.get());
+ vn.negotiate(*initial_packet);
CHECK(vn.status() == QUICVersionNegotiationStatus::NEGOTIATED);
// Validate version
@@ -82,7 +82,7 @@ TEST_CASE("QUICVersionNegotiator - Server Side", "[quic]")
packet_factory.set_version(QUIC_EXERCISE_VERSION);
QUICPacketUPtr initial_packet =
packet_factory.create_initial_packet({}, {}, 0,
std::move(dummy_payload), dummy_payload_len, true, false, true);
- vn.negotiate(initial_packet.get());
+ vn.negotiate(*initial_packet);
CHECK(vn.status() == QUICVersionNegotiationStatus::NOT_NEGOTIATED);
// Validate version
@@ -132,7 +132,7 @@ TEST_CASE("QUICVersionNegotiator - Client Side", "[quic]")
packet_factory.create_version_negotiation_packet(initial_packet->source_cid(),
initial_packet->destination_cid());
// Negotiate version
- vn.negotiate(vn_packet.get());
+ vn.negotiate(*vn_packet);
CHECK(vn.status() == QUICVersionNegotiationStatus::NEGOTIATED);
CHECK(vn.negotiated_version() == QUIC_SUPPORTED_VERSIONS[0]);