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/18 05:49:02 UTC
[trafficserver] branch quic-latest updated: Complete handshake
after sending finished
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 2b002aa Complete handshake after sending finished
2b002aa is described below
commit 2b002aabe93ecc6eaa1cd71b06d02b5243d34f2d
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Wed Jan 17 17:03:07 2018 +0900
Complete handshake after sending finished
---
iocore/net/P_QUICNetVConnection.h | 3 +--
iocore/net/QUICNetVConnection.cc | 31 ++++++++++++++++++++++---------
iocore/net/QUICPacketHandler.cc | 4 ++++
iocore/net/quic/QUICConnection.h | 5 +++++
iocore/net/quic/QUICEvents.h | 1 +
iocore/net/quic/QUICHandshake.cc | 36 ++++++++++++++++++++++--------------
6 files changed, 55 insertions(+), 25 deletions(-)
diff --git a/iocore/net/P_QUICNetVConnection.h b/iocore/net/P_QUICNetVConnection.h
index 6a46e45..5b47b75 100644
--- a/iocore/net/P_QUICNetVConnection.h
+++ b/iocore/net/P_QUICNetVConnection.h
@@ -176,6 +176,7 @@ 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;
@@ -248,8 +249,6 @@ private:
std::queue<QUICFrameUPtr> _frame_send_queue;
std::queue<QUICFrameUPtr> _stream_frame_send_queue;
- bool _is_initial = true;
-
void _schedule_packet_write_ready();
void _unschedule_packet_write_ready();
void _close_packet_write_ready(Event *data);
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index b09f235..3a64bca 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -185,6 +185,12 @@ QUICNetVConnection::connection_id()
return this->_quic_connection_id;
}
+void
+QUICNetVConnection::reset_connection_id(QUICConnectionId cid)
+{
+ this->_quic_connection_id = cid;
+}
+
uint32_t
QUICNetVConnection::pmtu()
{
@@ -947,15 +953,23 @@ QUICNetVConnection::_build_packet(ats_unique_buf buf, size_t len, bool retransmi
std::move(buf), len, retransmittable);
break;
default:
- if (this->_handshake_handler && this->_handshake_handler->is_completed()) {
- packet = this->_packet_factory.create_server_protected_packet(this->_quic_connection_id, this->largest_acked_packet_number(),
- std::move(buf), len, retransmittable);
- } else {
- // FIXME: remove this flag
- if (this->get_context() == NET_VCONNECTION_OUT && this->_is_initial) {
- this->_is_initial = false;
- packet = this->_packet_factory.create_initial_packet(
+ if (this->get_context() == NET_VCONNECTION_OUT) {
+ if (this->_handshake_handler->handler == reinterpret_cast<NetVConnHandler>(&QUICHandshake::state_initial)) {
+ packet = this->_packet_factory.create_initial_packet(
this->_original_quic_connection_id, this->largest_acked_packet_number(), QUIC_SUPPORTED_VERSIONS[0], std::move(buf), len);
+ this->_handshake_handler->handleEvent(QUIC_EVENT_HANDSHAKE_PACKET_WRITE_COMPLETE, nullptr);
+ } else if (this->_handshake_handler->handler == reinterpret_cast<NetVConnHandler>(&QUICHandshake::state_key_exchange)) {
+ packet = this->_packet_factory.create_handshake_packet(this->_quic_connection_id, this->largest_acked_packet_number(),
+ std::move(buf), len, retransmittable);
+ this->_handshake_handler->handleEvent(QUIC_EVENT_HANDSHAKE_PACKET_WRITE_COMPLETE, nullptr);
+ } else {
+ packet = this->_packet_factory.create_server_protected_packet(
+ this->_quic_connection_id, this->largest_acked_packet_number(), std::move(buf), len, retransmittable);
+ }
+ } else {
+ if (this->_handshake_handler && this->_handshake_handler->is_completed()) {
+ packet = this->_packet_factory.create_server_protected_packet(
+ this->_quic_connection_id, this->largest_acked_packet_number(), std::move(buf), len, retransmittable);
} else {
packet = this->_packet_factory.create_handshake_packet(this->_quic_connection_id, this->largest_acked_packet_number(),
std::move(buf), len, retransmittable);
@@ -1157,7 +1171,6 @@ QUICNetVConnection::_switch_to_established_state()
{
if (this->_complete_handshake_if_possible() == 0) {
QUICConDebug("Enter state_connection_established");
- QUICConDebug("%s", this->_handshake_handler->negotiated_cipher_suite());
SET_HANDLER((NetVConnHandler)&QUICNetVConnection::state_connection_established);
if (netvc_context == NET_VCONNECTION_IN) {
diff --git a/iocore/net/QUICPacketHandler.cc b/iocore/net/QUICPacketHandler.cc
index 12e3cc4..0dac684 100644
--- a/iocore/net/QUICPacketHandler.cc
+++ b/iocore/net/QUICPacketHandler.cc
@@ -285,6 +285,10 @@ QUICPacketHandlerOut::_recv_packet(int event, UDPPacket *udp_packet)
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 c2df2f3..98d7abd 100644
--- a/iocore/net/quic/QUICConnection.h
+++ b/iocore/net/quic/QUICConnection.h
@@ -40,6 +40,11 @@ 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/QUICEvents.h b/iocore/net/quic/QUICEvents.h
index c3f9b44..ffbb3b4 100644
--- a/iocore/net/quic/QUICEvents.h
+++ b/iocore/net/quic/QUICEvents.h
@@ -29,6 +29,7 @@
enum {
QUIC_EVENT_PACKET_READ_READY = QUIC_EVENT_EVENTS_START,
QUIC_EVENT_PACKET_WRITE_READY,
+ QUIC_EVENT_HANDSHAKE_PACKET_WRITE_COMPLETE,
QUIC_EVENT_CLOSING_TIMEOUT,
QUIC_EVENT_SHUTDOWN,
QUIC_EVENT_LD_SHUTDOWN,
diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc
index 03a453c..e4612c3 100644
--- a/iocore/net/quic/QUICHandshake.cc
+++ b/iocore/net/quic/QUICHandshake.cc
@@ -21,16 +21,19 @@
* limitations under the License.
*/
-#include "QUICGlobals.h"
#include "QUICHandshake.h"
-#include "QUICCryptoTls.h"
#include <utility>
-#include "QUICVersionNegotiator.h"
-#include "QUICConfig.h"
+
#include "P_SSLNextProtocolSet.h"
#include "P_VConnection.h"
+#include "QUICCryptoTls.h"
+#include "QUICEvents.h"
+#include "QUICGlobals.h"
+#include "QUICVersionNegotiator.h"
+#include "QUICConfig.h"
+
static constexpr char dump_tag[] = "v_quic_handshake_dump_pkt";
#define QUICHSDebug(fmt, ...) \
@@ -281,6 +284,11 @@ QUICHandshake::state_initial(int event, Event *data)
QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
switch (event) {
+ case QUIC_EVENT_HANDSHAKE_PACKET_WRITE_COMPLETE: {
+ QUICHSDebug("Enter state_key_exchange");
+ SET_HANDLER(&QUICHandshake::state_key_exchange);
+ break;
+ }
case VC_EVENT_READ_READY:
case VC_EVENT_READ_COMPLETE: {
if (this->_netvc_context == NET_VCONNECTION_IN) {
@@ -319,6 +327,14 @@ QUICHandshake::state_key_exchange(int event, Event *data)
QUICErrorUPtr error = QUICErrorUPtr(new QUICNoError());
switch (event) {
+ case QUIC_EVENT_HANDSHAKE_PACKET_WRITE_COMPLETE: {
+ int res = this->_complete_handshake();
+ if (!res) {
+ this->_abort_handshake(QUICTransErrorCode::TLS_HANDSHAKE_FAILED);
+ }
+
+ break;
+ }
case VC_EVENT_READ_READY:
case VC_EVENT_READ_COMPLETE: {
ink_assert(this->_netvc_context == NET_VCONNECTION_OUT);
@@ -479,9 +495,6 @@ QUICHandshake::_process_initial()
switch (result) {
case SSL_ERROR_WANT_READ: {
- QUICHSDebug("Enter state_key_exchange");
- SET_HANDLER(&QUICHandshake::state_key_exchange);
-
stream_io->write_reenable();
stream_io->read_reenable();
@@ -527,13 +540,7 @@ QUICHandshake::_process_server_hello()
switch (result) {
case SSL_ERROR_NONE: {
- int res = this->_complete_handshake();
- if (res) {
- stream_io->write_reenable();
- } else {
- this->_abort_handshake(QUICTransErrorCode::TLS_HANDSHAKE_FAILED);
- }
-
+ stream_io->write_reenable();
break;
}
case SSL_ERROR_WANT_READ: {
@@ -581,6 +588,7 @@ QUICHandshake::_complete_handshake()
{
QUICHSDebug("Enter state_complete");
SET_HANDLER(&QUICHandshake::state_complete);
+ QUICHSDebug("%s", this->negotiated_cipher_suite());
int res = this->_crypto->update_key_materials();
if (res) {
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].