mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-11-24 04:01:07 +03:00
Accept session tickets with additional optional parameters
Summary: Allow server to accept session tickets with additional paramters that won't be used. A subset of servers can include additional transport parameters in the session ticket that are only useful to them. This allows other servers to still use the ticket as long as it has the fields they expect, ignoring any additional parameters. Reviewed By: mjoras Differential Revision: D43131800 fbshipit-source-id: ff4ea503c2e30b9bd0e1caf77b418c3891ffdd7f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ccde77f256
commit
62d4ef978a
@@ -589,7 +589,7 @@ constexpr std::chrono::seconds kTimeToRetainLastCongestionAndRttState = 60s;
|
|||||||
|
|
||||||
constexpr uint16_t kMaxNumMigrationsAllowed = 6;
|
constexpr uint16_t kMaxNumMigrationsAllowed = 6;
|
||||||
|
|
||||||
constexpr auto kExpectedNumOfParamsInTheTicket = 8;
|
constexpr auto kMinimumNumOfParamsInTheTicket = 8;
|
||||||
|
|
||||||
constexpr auto kStatelessResetTokenSecretLength = 32;
|
constexpr auto kStatelessResetTokenSecretLength = 32;
|
||||||
|
|
||||||
|
|||||||
@@ -58,14 +58,12 @@ bool DefaultAppTokenValidator::validate(
|
|||||||
|
|
||||||
auto& params = appToken->transportParams.parameters;
|
auto& params = appToken->transportParams.parameters;
|
||||||
|
|
||||||
// TODO T33454954 Simplify ticket transport params. see comments in D9324131
|
// Reject tickets that do not have the minimum number of params in the ticket.
|
||||||
// Currenly only initialMaxData, initialMaxStreamData, ackDelayExponent, and
|
// This is a minimum to allow sending additional optional params
|
||||||
// maxRecvPacketSize are written into the ticket. In case new parameters
|
// that can be ignored by servers that don't support them.
|
||||||
// are added for making early data decision (although not likely), this
|
if (params.size() < kMinimumNumOfParamsInTheTicket) {
|
||||||
// validator fails the check if number of parameters is not
|
VLOG(10)
|
||||||
// kExpectedNumOfParamsInTheTicket.
|
<< "Number of parameters in the ticket is less than the minimum expected";
|
||||||
if (params.size() != kExpectedNumOfParamsInTheTicket) {
|
|
||||||
VLOG(10) << "Unexpected number of parameters in the ticket";
|
|
||||||
return validated = false;
|
return validated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ void expectAppTokenEqual(
|
|||||||
decodedAppToken->transportParams.parameters.size(),
|
decodedAppToken->transportParams.parameters.size(),
|
||||||
appToken.transportParams.parameters.size());
|
appToken.transportParams.parameters.size());
|
||||||
|
|
||||||
EXPECT_EQ(
|
EXPECT_GE(
|
||||||
decodedAppToken->transportParams.parameters.size(),
|
decodedAppToken->transportParams.parameters.size(),
|
||||||
kExpectedNumOfParamsInTheTicket);
|
kMinimumNumOfParamsInTheTicket);
|
||||||
// TODO Split out into individual flow control parameters.
|
// TODO Split out into individual flow control parameters.
|
||||||
auto maxStreamData = getIntegerParameter(
|
auto maxStreamData = getIntegerParameter(
|
||||||
TransportParameterId::initial_max_stream_data_bidi_local,
|
TransportParameterId::initial_max_stream_data_bidi_local,
|
||||||
|
|||||||
@@ -57,6 +57,39 @@ TEST(DefaultAppTokenValidatorTest, TestValidParams) {
|
|||||||
EXPECT_TRUE(validator.validate(resState));
|
EXPECT_TRUE(validator.validate(resState));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(DefaultAppTokenValidatorTest, TestValidOptionalParameter) {
|
||||||
|
QuicServerConnectionState conn(
|
||||||
|
FizzServerQuicHandshakeContext::Builder().build());
|
||||||
|
conn.peerAddress = folly::SocketAddress("1.2.3.4", 443);
|
||||||
|
conn.version = QuicVersion::MVFST;
|
||||||
|
conn.transportSettings.zeroRttSourceTokenMatchingPolicy =
|
||||||
|
ZeroRttSourceTokenMatchingPolicy::LIMIT_IF_NO_EXACT_MATCH;
|
||||||
|
auto quicStats = std::make_shared<MockQuicStats>();
|
||||||
|
conn.statsCallback = quicStats.get();
|
||||||
|
|
||||||
|
AppToken appToken;
|
||||||
|
appToken.transportParams = createTicketTransportParameters(
|
||||||
|
conn.transportSettings.idleTimeout.count(),
|
||||||
|
conn.transportSettings.maxRecvPacketSize,
|
||||||
|
conn.transportSettings.advertisedInitialConnectionWindowSize,
|
||||||
|
conn.transportSettings.advertisedInitialBidiLocalStreamWindowSize,
|
||||||
|
conn.transportSettings.advertisedInitialBidiRemoteStreamWindowSize,
|
||||||
|
conn.transportSettings.advertisedInitialUniStreamWindowSize,
|
||||||
|
conn.transportSettings.advertisedInitialMaxStreamsBidi,
|
||||||
|
conn.transportSettings.advertisedInitialMaxStreamsUni);
|
||||||
|
appToken.transportParams.parameters.push_back(
|
||||||
|
encodeIntegerParameter(TransportParameterId::disable_migration, 1));
|
||||||
|
ResumptionState resState;
|
||||||
|
resState.appToken = encodeAppToken(appToken);
|
||||||
|
|
||||||
|
conn.earlyDataAppParamsValidator = [](const folly::Optional<std::string>&,
|
||||||
|
const Buf&) { return true; };
|
||||||
|
DefaultAppTokenValidator validator(&conn);
|
||||||
|
EXPECT_CALL(*quicStats, onZeroRttAccepted()).Times(1);
|
||||||
|
EXPECT_CALL(*quicStats, onZeroRttRejected()).Times(0);
|
||||||
|
EXPECT_TRUE(validator.validate(resState));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(
|
TEST(
|
||||||
DefaultAppTokenValidatorTest,
|
DefaultAppTokenValidatorTest,
|
||||||
TestValidUnequalParamsUpdateTransportSettings) {
|
TestValidUnequalParamsUpdateTransportSettings) {
|
||||||
|
|||||||
Reference in New Issue
Block a user