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/16 02:53:58 UTC
[trafficserver] branch quic-latest updated: Fix Transport Parameter
validations and default value of _initial_max_stream_*
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 010f95e Fix Transport Parameter validations and default value of _initial_max_stream_*
010f95e is described below
commit 010f95eb9b103b99f55a9d8eb5b28e68b43f6309
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Tue Jan 16 11:53:42 2018 +0900
Fix Transport Parameter validations and default value of _initial_max_stream_*
---
iocore/net/quic/QUICConfig.h | 8 ++---
iocore/net/quic/QUICHandshake.cc | 3 +-
iocore/net/quic/QUICTransportParameters.cc | 53 +++++++++++++++++++-----------
iocore/net/quic/QUICTypes.h | 4 +--
4 files changed, 41 insertions(+), 27 deletions(-)
diff --git a/iocore/net/quic/QUICConfig.h b/iocore/net/quic/QUICConfig.h
index c4525a1..233c035 100644
--- a/iocore/net/quic/QUICConfig.h
+++ b/iocore/net/quic/QUICConfig.h
@@ -46,10 +46,10 @@ private:
uint32_t _no_activity_timeout_out = 30;
uint32_t _initial_max_data = 131072;
uint32_t _initial_max_stream_data = 2048;
- uint32_t _initial_max_stream_id_bidi_in = 100;
- uint32_t _initial_max_stream_id_bidi_out = 101;
- uint32_t _initial_max_stream_id_uni_in = 102;
- uint32_t _initial_max_stream_id_uni_out = 103;
+ uint32_t _initial_max_stream_id_bidi_out = 100;
+ uint32_t _initial_max_stream_id_bidi_in = 101;
+ uint32_t _initial_max_stream_id_uni_out = 102;
+ uint32_t _initial_max_stream_id_uni_in = 103;
uint32_t _server_id = 0;
};
diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc
index b700eb3..81598e6 100644
--- a/iocore/net/quic/QUICHandshake.cc
+++ b/iocore/net/quic/QUICHandshake.cc
@@ -223,7 +223,8 @@ QUICHandshake::set_transport_parameters(std::shared_ptr<QUICTransportParametersI
this->_remote_transport_parameters = tp;
// TODO Add client side implementation
- ink_assert(false);
+
+ return;
}
void
diff --git a/iocore/net/quic/QUICTransportParameters.cc b/iocore/net/quic/QUICTransportParameters.cc
index c3c25c4..0bffe55 100644
--- a/iocore/net/quic/QUICTransportParameters.cc
+++ b/iocore/net/quic/QUICTransportParameters.cc
@@ -125,7 +125,13 @@ QUICTransportParameters::_load(const uint8_t *buf, size_t len)
}
// Validate parameters
- this->_valid = (this->_validate_parameters() == 0);
+ int res = this->_validate_parameters();
+ if (res < 0) {
+ Debug(tag, "Transport parameter is not valid (err=%d)", res);
+ this->_valid = false;
+ } else {
+ this->_valid = true;
+ }
}
int
@@ -139,52 +145,53 @@ QUICTransportParameters::_validate_parameters() const
return -1;
}
} else {
- return -1;
+ return -2;
}
if ((ite = this->_parameters.find(QUICTransportParameterId::INITIAL_MAX_DATA)) != this->_parameters.end()) {
if (ite->second->len() != 4) {
- return -1;
+ return -3;
}
} else {
- return -1;
+ return -4;
}
if ((ite = this->_parameters.find(QUICTransportParameterId::IDLE_TIMEOUT)) != this->_parameters.end()) {
if (ite->second->len() != 2) {
- return -1;
+ return -5;
}
if (QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len()) > 600) {
- return -1;
+ return -6;
}
} else {
- return -1;
+ return -7;
}
// MAYs
if ((ite = this->_parameters.find(QUICTransportParameterId::OMIT_CONNECTION_ID)) != this->_parameters.end()) {
if (ite->second->len() != 0) {
- return -1;
+ return -8;
}
}
if ((ite = this->_parameters.find(QUICTransportParameterId::MAX_PACKET_SIZE)) != this->_parameters.end()) {
if (ite->second->len() != 2) {
- return -1;
+ return -9;
}
if (QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len()) < 1200) {
- return -1;
+ return -10;
}
}
if ((ite = this->_parameters.find(QUICTransportParameterId::ACK_DELAY_EXPONENT)) != this->_parameters.end()) {
if (ite->second->len() != 1) {
- return -1;
+ return -11;
}
if (QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len()) > 20) {
- return -1;
+ return -12;
}
}
+
return 0;
}
@@ -358,7 +365,8 @@ QUICTransportParametersInClientHello::_validate_parameters() const
if (ite->second->len() != 4) {
return -2;
}
- if ((QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len()) & 0x03) != 1) {
+ if (QUICTypeUtil::detect_stream_type(QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len())) !=
+ QUICStreamType::CLIENT_BIDI) {
return -3;
}
}
@@ -367,7 +375,8 @@ QUICTransportParametersInClientHello::_validate_parameters() const
if (ite->second->len() != 4) {
return -4;
}
- if ((QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len()) & 0x03) != 3) {
+ if (QUICTypeUtil::detect_stream_type(QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len())) !=
+ QUICStreamType::CLIENT_UNI) {
return -5;
}
}
@@ -445,7 +454,7 @@ QUICTransportParametersInEncryptedExtensions::_validate_parameters() const
// MUSTs
if ((ite = this->_parameters.find(QUICTransportParameterId::STATELESS_RESET_TOKEN)) != this->_parameters.end()) {
- if (ite->second->len() != 2) {
+ if (ite->second->len() != QUICStatelessResetToken::LEN) {
return -1;
}
} else {
@@ -457,7 +466,8 @@ QUICTransportParametersInEncryptedExtensions::_validate_parameters() const
if (ite->second->len() != 4) {
return -3;
}
- if ((QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len()) & 0x03) != 1) {
+ if (QUICTypeUtil::detect_stream_type(QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len())) !=
+ QUICStreamType::SERVER_BIDI) {
return -4;
}
}
@@ -466,7 +476,8 @@ QUICTransportParametersInEncryptedExtensions::_validate_parameters() const
if (ite->second->len() != 4) {
return -5;
}
- if ((QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len()) & 0x03) != 3) {
+ if (QUICTypeUtil::detect_stream_type(QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len())) !=
+ QUICStreamType::SERVER_UNI) {
return -6;
}
}
@@ -508,7 +519,7 @@ QUICTransportParametersInNewSessionTicket::_validate_parameters() const
// MUSTs
if ((ite = this->_parameters.find(QUICTransportParameterId::STATELESS_RESET_TOKEN)) != this->_parameters.end()) {
- if (ite->second->len() != 2) {
+ if (ite->second->len() != QUICStatelessResetToken::LEN) {
return -1;
}
} else {
@@ -520,7 +531,8 @@ QUICTransportParametersInNewSessionTicket::_validate_parameters() const
if (ite->second->len() != 4) {
return -3;
}
- if ((QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len()) & 0x03) != 1) {
+ if (QUICTypeUtil::detect_stream_type(QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len())) !=
+ QUICStreamType::SERVER_BIDI) {
return -4;
}
}
@@ -529,7 +541,8 @@ QUICTransportParametersInNewSessionTicket::_validate_parameters() const
if (ite->second->len() != 4) {
return -5;
}
- if ((QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len()) & 0x03) != 3) {
+ if (QUICTypeUtil::detect_stream_type(QUICTypeUtil::read_nbytes_as_uint(ite->second->data(), ite->second->len())) !=
+ QUICStreamType::SERVER_UNI) {
return -6;
}
}
diff --git a/iocore/net/quic/QUICTypes.h b/iocore/net/quic/QUICTypes.h
index 912a82a..4744cbc 100644
--- a/iocore/net/quic/QUICTypes.h
+++ b/iocore/net/quic/QUICTypes.h
@@ -247,8 +247,8 @@ private:
void _gen_token(uint64_t data);
};
-enum class QUICStreamType {
- CLIENT_BIDI,
+enum class QUICStreamType : uint8_t {
+ CLIENT_BIDI = 0x00,
SERVER_BIDI,
CLIENT_UNI,
SERVER_UNI,
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].