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 25fc918 Cleanup: Remove QUICPacketFactory::_dcil and
QUICPacketShortHeader::_dcil
25fc918 is described below
commit 25fc9182111ddddefa55a750d0514d58b4639919
Author: Masaori Koshiba <[email protected]>
AuthorDate: Fri Jun 15 15:10:30 2018 +0900
Cleanup: Remove QUICPacketFactory::_dcil and QUICPacketShortHeader::_dcil
We don't need to track dcil for Short Header packet, becasue it's same to
scil in local.
In other words, when we need dcil while reading Short Header packet, we
should refer it via
`QUICConfigParams::scid_len()`;
---
iocore/net/QUICNetVConnection.cc | 1 -
iocore/net/quic/QUICPacket.cc | 27 +++++++----------
iocore/net/quic/QUICPacket.h | 7 ++---
iocore/net/quic/test/test_QUICInvariants.cc | 2 +-
iocore/net/quic/test/test_QUICPacket.cc | 46 ++++++++++++++++++-----------
5 files changed, 42 insertions(+), 41 deletions(-)
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index b7d53b3..b17d93c 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -1490,7 +1490,6 @@
QUICNetVConnection::_dequeue_recv_packet(QUICPacketCreationResult &result)
}
this->_last_received_packet_type = packet->type();
- this->_packet_factory.set_dcil(packet->destination_cid().length());
}
// Debug prints
diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index 9b09c6d..e4a9e2a 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -43,8 +43,6 @@ ClassAllocator<QUICPacketShortHeader>
quicPacketShortHeaderAllocator("quicPacket
static constexpr int LONG_HDR_OFFSET_CONNECTION_ID = 6;
static constexpr int LONG_HDR_OFFSET_VERSION = 1;
-static constexpr int SHORT_HDR_OFFSET_CONNECTION_ID = 1;
-
//
// QUICPacketHeader
//
@@ -74,7 +72,7 @@ QUICPacketHeader::packet_size() const
}
QUICPacketHeaderUPtr
-QUICPacketHeader::load(const IpEndpoint from, ats_unique_buf buf, size_t len,
QUICPacketNumber base, uint8_t dcil)
+QUICPacketHeader::load(const IpEndpoint from, ats_unique_buf buf, size_t len,
QUICPacketNumber base)
{
QUICPacketHeaderUPtr header = QUICPacketHeaderUPtr(nullptr,
&QUICPacketHeaderDeleter::delete_null_header);
if (QUICTypeUtil::has_long_header(buf.get())) {
@@ -83,7 +81,7 @@ QUICPacketHeader::load(const IpEndpoint from, ats_unique_buf
buf, size_t len, QU
header = QUICPacketHeaderUPtr(long_header,
&QUICPacketHeaderDeleter::delete_long_header);
} else {
QUICPacketShortHeader *short_header =
quicPacketShortHeaderAllocator.alloc();
- new (short_header) QUICPacketShortHeader(from, std::move(buf), len, base,
dcil);
+ new (short_header) QUICPacketShortHeader(from, std::move(buf), len, base);
header = QUICPacketHeaderUPtr(short_header,
&QUICPacketHeaderDeleter::delete_short_header);
}
return header;
@@ -326,17 +324,16 @@ QUICPacketLongHeader::store(uint8_t *buf, size_t *len)
const
// QUICPacketShortHeader
//
-QUICPacketShortHeader::QUICPacketShortHeader(const IpEndpoint from,
ats_unique_buf buf, size_t len, QUICPacketNumber base,
- uint8_t dcil)
- : QUICPacketHeader(from, std::move(buf), len, base), _dcil(dcil)
+QUICPacketShortHeader::QUICPacketShortHeader(const IpEndpoint from,
ats_unique_buf buf, size_t len, QUICPacketNumber base)
+ : QUICPacketHeader(from, std::move(buf), len, base)
{
- this->_connection_id = QUICTypeUtil::read_QUICConnectionId(this->_buf.get()
+ 1, dcil);
+ QUICInvariants::dcid(this->_connection_id, this->_buf.get(), len);
int offset = 1 + this->_connection_id.length();
this->_packet_number_len =
QUICTypeUtil::read_QUICPacketNumberLen(this->_buf.get() + offset);
QUICPacketNumber src =
QUICTypeUtil::read_QUICPacketNumber(this->_buf.get() + offset);
QUICPacket::decode_packet_number(this->_packet_number, src,
this->_packet_number_len, this->_base_packet_number);
- this->_payload_length = len - (1 + this->_dcil + this->_packet_number_len);
+ this->_payload_length = len - (1 + QUICConfigParams::scid_len() +
this->_packet_number_len);
}
QUICPacketShortHeader::QUICPacketShortHeader(QUICPacketType type, QUICKeyPhase
key_phase, QUICPacketNumber packet_number,
@@ -388,7 +385,9 @@ QUICConnectionId
QUICPacketShortHeader::destination_cid() const
{
if (this->_buf) {
- return QUICTypeUtil::read_QUICConnectionId(this->_buf.get() +
SHORT_HDR_OFFSET_CONNECTION_ID, this->_dcil);
+ QUICConnectionId dcid = QUICConnectionId::ZERO();
+ QUICInvariants::dcid(dcid, this->_buf.get(), this->_buf_len);
+ return dcid;
} else {
return _connection_id;
}
@@ -710,7 +709,7 @@ QUICPacketFactory::create(IpEndpoint from, ats_unique_buf
buf, size_t len, QUICP
ats_unique_buf plain_txt = ats_unique_malloc(max_plain_txt_len);
size_t plain_txt_len = 0;
- QUICPacketHeaderUPtr header = QUICPacketHeader::load(from, std::move(buf),
len, base_packet_number, this->_dcil);
+ QUICPacketHeaderUPtr header = QUICPacketHeader::load(from, std::move(buf),
len, base_packet_number);
QUICConnectionId dcid = header->destination_cid();
QUICConnectionId scid = header->source_cid();
@@ -957,12 +956,6 @@ QUICPacketFactory::set_hs_protocol(QUICHandshakeProtocol
*hs_protocol)
this->_hs_protocol = hs_protocol;
}
-void
-QUICPacketFactory::set_dcil(uint8_t len)
-{
- this->_dcil = len;
-}
-
//
// QUICPacketNumberGenerator
//
diff --git a/iocore/net/quic/QUICPacket.h b/iocore/net/quic/QUICPacket.h
index 2d022e8..ec8dc1c 100644
--- a/iocore/net/quic/QUICPacket.h
+++ b/iocore/net/quic/QUICPacket.h
@@ -117,7 +117,7 @@ public:
*
* This creates either a QUICPacketShortHeader or a QUICPacketLongHeader.
*/
- static QUICPacketHeaderUPtr load(const IpEndpoint from, ats_unique_buf buf,
size_t len, QUICPacketNumber base, uint8_t dcil = 0);
+ static QUICPacketHeaderUPtr load(const IpEndpoint from, ats_unique_buf buf,
size_t len, QUICPacketNumber base);
/*
* Build a QUICPacketHeader
@@ -202,7 +202,7 @@ class QUICPacketShortHeader : public QUICPacketHeader
public:
QUICPacketShortHeader() : QUICPacketHeader(){};
virtual ~QUICPacketShortHeader(){};
- QUICPacketShortHeader(const IpEndpoint from, ats_unique_buf buf, size_t len,
QUICPacketNumber base, uint8_t dcil);
+ QUICPacketShortHeader(const IpEndpoint from, ats_unique_buf buf, size_t len,
QUICPacketNumber base);
QUICPacketShortHeader(QUICPacketType type, QUICKeyPhase key_phase,
QUICPacketNumber packet_number,
QUICPacketNumber base_packet_number, ats_unique_buf
buf, size_t len);
QUICPacketShortHeader(QUICPacketType type, QUICKeyPhase key_phase,
QUICConnectionId connection_id, QUICPacketNumber packet_number,
@@ -226,7 +226,6 @@ public:
private:
int _packet_number_len;
- uint8_t _dcil;
};
class QUICPacketHeaderDeleter
@@ -379,7 +378,6 @@ public:
ats_unique_buf payload, size_t
len, bool retransmittable);
void set_version(QUICVersion negotiated_version);
void set_hs_protocol(QUICHandshakeProtocol *hs_protocol);
- [[deprecated]] void set_dcil(uint8_t len);
private:
QUICVersion _version = QUIC_SUPPORTED_VERSIONS[0];
@@ -388,5 +386,4 @@ private:
static QUICPacketUPtr _create_unprotected_packet(QUICPacketHeaderUPtr
header);
QUICPacketUPtr _create_encrypted_packet(QUICPacketHeaderUPtr header, bool
retransmittable);
- [[deprecated]] uint8_t _dcil = 0;
};
diff --git a/iocore/net/quic/test/test_QUICInvariants.cc
b/iocore/net/quic/test/test_QUICInvariants.cc
index dc1c8d7..5cdbc28 100644
--- a/iocore/net/quic/test/test_QUICInvariants.cc
+++ b/iocore/net/quic/test/test_QUICInvariants.cc
@@ -203,7 +203,7 @@ TEST_CASE("Short Header - regular case", "[quic]")
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, //
0x10, 0x11, //
};
- QUICConnectionId expected_dcid(raw_dcid, 18);
+ QUICConnectionId expected_dcid(raw_dcid, sizeof(raw_dcid));
QUICConnectionId dcid = QUICConnectionId::ZERO();
diff --git a/iocore/net/quic/test/test_QUICPacket.cc
b/iocore/net/quic/test/test_QUICPacket.cc
index dbd30d9..abf5366 100644
--- a/iocore/net/quic/test/test_QUICPacket.cc
+++ b/iocore/net/quic/test/test_QUICPacket.cc
@@ -118,22 +118,30 @@ TEST_CASE("QUICPacketHeader - Long", "[quic]")
TEST_CASE("QUICPacketHeader - Short", "[quic]")
{
+ const uint8_t raw_dcid[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // Destination Connection
ID (144)
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, //
+ 0x10, 0x11, //
+ };
+ QUICConnectionId dcid(raw_dcid, sizeof(raw_dcid));
+
SECTION("Short Header (load)")
{
const uint8_t input[] = {
0x30, // Short header with
(K=0)
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, // Destination
Connection ID
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // Destination
Connection ID (144)
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, //
+ 0x10, 0x11, //
0xC1, 0x23, 0x45, 0x67, // Packet number
0xff, 0xff, // Payload (dummy)
};
- QUICPacketHeaderUPtr header = QUICPacketHeader::load({},
{const_cast<uint8_t *>(input), [](void *p) {}}, sizeof(input), 0, 8);
- CHECK(header->size() == 13);
- CHECK(header->packet_size() == 15);
+ QUICPacketHeaderUPtr header = QUICPacketHeader::load({},
{const_cast<uint8_t *>(input), [](void *p) {}}, sizeof(input), 0);
+ CHECK(header->size() == 23);
+ CHECK(header->packet_size() == 25);
CHECK(header->has_key_phase() == true);
CHECK(header->key_phase() == QUICKeyPhase::PHASE_0);
- CHECK(
- (header->destination_cid() == QUICConnectionId(reinterpret_cast<const
uint8_t *>("\x01\x02\x03\x04\x05\x06\x07\x08"), 8)));
+ CHECK(header->destination_cid() == dcid);
CHECK(header->packet_number() == 0x01234567);
CHECK(header->has_version() == false);
}
@@ -145,29 +153,33 @@ TEST_CASE("QUICPacketHeader - Short", "[quic]")
const uint8_t expected[] = {
0x30, // Short header with
(K=0)
- 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, // Destination
Connection ID
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // Destination
Connection ID (144)
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, //
+ 0x10, 0x11, //
0xC1, 0x23, 0x45, 0x67, // Packet number
0x11, 0x22, 0x33, 0x44, 0x55, // Protected Payload
};
+ size_t payload_len = 5;
+ size_t header_len = sizeof(expected) - 5;
- ats_unique_buf payload = ats_unique_malloc(5);
- memcpy(payload.get(), expected + 13, 5);
- QUICPacketHeaderUPtr header = QUICPacketHeader::build(
- QUICPacketType::PROTECTED, QUICKeyPhase::PHASE_0,
{reinterpret_cast<const uint8_t *>("\x01\x02\x03\x04\x05\x06\x07\x08"), 8},
- 0x01234567, 0, std::move(payload), 32);
- CHECK(header->size() == 13);
+ ats_unique_buf payload = ats_unique_malloc(payload_len);
+ memcpy(payload.get(), expected + header_len, payload_len);
+
+ QUICPacketHeaderUPtr header =
+ QUICPacketHeader::build(QUICPacketType::PROTECTED,
QUICKeyPhase::PHASE_0, dcid, 0x01234567, 0, std::move(payload), 32);
+
+ CHECK(header->size() == 23);
CHECK(header->packet_size() == 0);
CHECK(header->has_key_phase() == true);
CHECK(header->key_phase() == QUICKeyPhase::PHASE_0);
CHECK(header->type() == QUICPacketType::PROTECTED);
- CHECK(
- (header->destination_cid() == QUICConnectionId(reinterpret_cast<const
uint8_t *>("\x01\x02\x03\x04\x05\x06\x07\x08"), 8)));
+ CHECK(header->destination_cid() == dcid);
CHECK(header->packet_number() == 0x01234567);
CHECK(header->has_version() == false);
header->store(buf, &len);
- CHECK(len == 13);
- CHECK(memcmp(buf, expected, len) == 0);
+ CHECK(len == header_len);
+ CHECK(memcmp(buf, expected, header_len) == 0);
}
}
--
To stop receiving notification emails like this one, please contact
[email protected].