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/27 16:39:48 UTC
[trafficserver] 01/03: Remove QUICConnection::reset_connection_id()
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
commit e3ad67a5094a768705c473eefd3b5afddfc69792
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Sat Jan 27 23:48:59 2018 +0900
Remove QUICConnection::reset_connection_id()
---
iocore/net/P_QUICNetVConnection.h | 1 -
iocore/net/P_QUICPacketHandler.h | 2 +-
iocore/net/QUICNetVConnection.cc | 19 +++++++++++------
iocore/net/QUICPacketHandler.cc | 43 +++++++++++----------------------------
iocore/net/quic/QUICConnection.h | 5 -----
iocore/net/quic/QUICPacket.cc | 16 +++++++++++++++
iocore/net/quic/QUICPacket.h | 2 ++
iocore/net/quic/QUICTypes.cc | 2 +-
8 files changed, 45 insertions(+), 45 deletions(-)
diff --git a/iocore/net/P_QUICNetVConnection.h b/iocore/net/P_QUICNetVConnection.h
index 5b47b75..a6e2b88 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -176,7 +176,6 @@ public:
// QUICConnection
QUICConnectionId original_connection_id() override;
QUICConnectionId connection_id() override;
- void reset_connection_id(QUICConnectionId cid) override;
uint32_t maximum_quic_packet_size() override;
uint32_t minimum_quic_packet_size() override;
uint32_t maximum_stream_frame_data_size() override;
diff --git a/iocore/net/P_QUICPacketHandler.h b/iocore/net/P_QUICPacketHandler.h
index 2205a80..8fce956 100644
--- a/iocore/net/P_QUICPacketHandler.h
+++ b/iocore/net/P_QUICPacketHandler.h
@@ -39,7 +39,7 @@ public:
protected:
static void _send_packet(Continuation *c, const QUICPacket &packet, UDPConnection *udp_con, IpEndpoint &addr, uint32_t pmtu);
- static bool _read_connection_id(QUICConnectionId &cid, IOBufferBlock *block);
+ static QUICConnectionId _read_connection_id(IOBufferBlock *block);
virtual void _recv_packet(int event, UDPPacket *udpPacket) = 0;
};
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 57e4f06..d940603 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -187,12 +187,6 @@ QUICNetVConnection::connection_id()
return this->_quic_connection_id;
}
-void
-QUICNetVConnection::reset_connection_id(QUICConnectionId cid)
-{
- this->_quic_connection_id = cid;
-}
-
uint32_t
QUICNetVConnection::pmtu()
{
@@ -1038,6 +1032,19 @@ QUICNetVConnection::_dequeue_recv_packet(QUICPacketCreationResult &result)
result = QUICPacketCreationResult::NOT_READY;
return quic_packet;
}
+
+ if (this->direction() == NET_VCONNECTION_OUT) {
+ // Reset CID if a server sent back a new CID
+ // FIXME This should happen only once
+ IOBufferBlock *block = udp_packet->getIOBlockChain();
+ if (QUICTypeUtil::has_connection_id(reinterpret_cast<const uint8_t *>(block->buf()))) {
+ QUICConnectionId cid = QUICPacket::connection_id(reinterpret_cast<const uint8_t *>(block->buf()));
+ if (this->_quic_connection_id != cid) {
+ this->_quic_connection_id = cid;
+ }
+ }
+ }
+
net_activity(this, this_ethread());
// Create a QUIC packet
diff --git a/iocore/net/QUICPacketHandler.cc b/iocore/net/QUICPacketHandler.cc
index b4c32ef..bdbd261 100644
--- a/iocore/net/QUICPacketHandler.cc
+++ b/iocore/net/QUICPacketHandler.cc
@@ -49,25 +49,11 @@ QUICPacketHandler::_send_packet(Continuation *c, const QUICPacket &packet, UDPCo
udp_con->send(c, udp_packet);
}
-// TODO: Integrate with QUICPacketHeader::connection_id()
-bool
-QUICPacketHandler::_read_connection_id(QUICConnectionId &cid, IOBufferBlock *block)
+QUICConnectionId
+QUICPacketHandler::_read_connection_id(IOBufferBlock *block)
{
- const uint8_t *buf = reinterpret_cast<const uint8_t *>(block->buf());
- const uint8_t cid_offset = 1;
- const uint8_t cid_len = 8;
-
- if (QUICTypeUtil::has_long_header(buf)) {
- cid = QUICTypeUtil::read_QUICConnectionId(buf + cid_offset, cid_len);
- } else {
- if (QUICTypeUtil::has_connection_id(buf)) {
- cid = QUICTypeUtil::read_QUICConnectionId(buf + cid_offset, cid_len);
- } else {
- return false;
- }
- }
-
- return true;
+ const uint8_t *buf = reinterpret_cast<const uint8_t *>(block->buf());
+ return QUICPacket::connection_id(buf);
}
//
@@ -141,19 +127,19 @@ QUICPacketHandlerIn::_recv_packet(int event, UDPPacket *udp_packet)
IOBufferBlock *block = udp_packet->getIOBlockChain();
QUICConnectionId cid;
- bool res = this->_read_connection_id(cid, block);
+ if (QUICTypeUtil::has_connection_id(reinterpret_cast<const uint8_t *>(block->buf()))) {
+ cid = this->_read_connection_id(block);
+ } else {
+ // TODO: find cid from five tuples
+ ink_assert(false);
+ }
ip_port_text_buffer ipb;
Debug("quic_sec", "[%" PRIx64 "] received packet from %s, size=%" PRId64, static_cast<uint64_t>(cid),
ats_ip_nptop(&udp_packet->from.sa, ipb, sizeof(ipb)), udp_packet->getPktLength());
QUICNetVConnection *vc = nullptr;
- if (res) {
- vc = this->_connections.get(cid);
- } else {
- // TODO: find vc from five tuples
- ink_assert(false);
- }
+ vc = this->_connections.get(cid);
if (!vc) {
Connection con;
@@ -277,17 +263,12 @@ QUICPacketHandlerOut::_recv_packet(int event, UDPPacket *udp_packet)
{
IOBufferBlock *block = udp_packet->getIOBlockChain();
- QUICConnectionId cid;
- this->_read_connection_id(cid, block);
+ QUICConnectionId cid = this->_read_connection_id(block);
ip_port_text_buffer ipb;
Debug("quic_sec", "[%" PRIx64 "] received packet from %s, size=%" PRId64, static_cast<uint64_t>(cid),
ats_ip_nptop(&udp_packet->from.sa, ipb, sizeof(ipb)), udp_packet->getPktLength());
- if (this->_vc->connection_id() != cid) {
- this->_vc->reset_connection_id(cid);
- }
-
this->_vc->push_packet(udp_packet);
eventProcessor.schedule_imm(this->_vc, ET_CALL, QUIC_EVENT_PACKET_READ_READY, nullptr);
}
diff --git a/iocore/net/quic/QUICConnection.h b/iocore/net/quic/QUICConnection.h
index 98d7abd..c2df2f3 100644
--- a/iocore/net/quic/QUICConnection.h
+++ b/iocore/net/quic/QUICConnection.h
@@ -40,11 +40,6 @@ public:
virtual QUICConnectionId connection_id() = 0;
/*
- * Server chooses a new value for the connection ID and client needs to reset it.
- */
- virtual void reset_connection_id(QUICConnectionId cid) = 0;
-
- /*
* Retruns the maximum packet size at the time called
*
* The size depends on PMTU.
diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index 097a67e..10c5347 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -629,6 +629,22 @@ QUICPacket::decode_packet_number(QUICPacketNumber &dst, QUICPacketNumber src, si
return true;
}
+QUICConnectionId
+QUICPacket::connection_id(const uint8_t *buf)
+{
+ constexpr uint8_t cid_offset = 1;
+ constexpr uint8_t cid_len = 8;
+ QUICConnectionId cid;
+ if (QUICTypeUtil::has_long_header(buf)) {
+ cid = QUICTypeUtil::read_QUICConnectionId(buf + cid_offset, cid_len);
+ } else {
+ ink_assert(QUICTypeUtil::has_connection_id(buf));
+ cid = QUICTypeUtil::read_QUICConnectionId(buf + cid_offset, cid_len);
+ }
+
+ return cid;
+}
+
//
// QUICPacketFactory
//
diff --git a/iocore/net/quic/QUICPacket.h b/iocore/net/quic/QUICPacket.h
index a392eb5..a7d554d 100644
--- a/iocore/net/quic/QUICPacket.h
+++ b/iocore/net/quic/QUICPacket.h
@@ -220,6 +220,8 @@ public:
const uint8_t *payload() const;
bool is_retransmittable() const;
+ static QUICConnectionId connection_id(const uint8_t *packet);
+
/*
* Size of whole QUIC packet (header + payload + integrity check)
*/
diff --git a/iocore/net/quic/QUICTypes.cc b/iocore/net/quic/QUICTypes.cc
index 399df5c..a622bd5 100644
--- a/iocore/net/quic/QUICTypes.cc
+++ b/iocore/net/quic/QUICTypes.cc
@@ -38,7 +38,7 @@ QUICTypeUtil::has_long_header(const uint8_t *buf)
bool
QUICTypeUtil::has_connection_id(const uint8_t *buf)
{
- return (buf[0] & 0x40) == 0;
+ return ((buf[0] & 0x80) != 0) || ((buf[0] & 0x40) == 0);
}
bool
--
To stop receiving notification emails like this one, please contact
maskit@apache.org.