mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-11-09 10:00:57 +03:00
Set upper limits on max_packet_size from the peer.
Summary: This will limit us to standard Ethernet MTU (1500) for now, but I think that is fine. This will allow us to experiment with packet size from the client more easily. Reviewed By: yangchi Differential Revision: D20709146 fbshipit-source-id: 608463de53d4520a257052491683263e14fc9682
This commit is contained in:
committed by
Facebook GitHub Bot
parent
19e1c14afd
commit
2176f080ff
@@ -30,9 +30,8 @@ constexpr uint16_t kDefaultUDPSendPacketLen =
|
|||||||
(kDefaultV4UDPSendPacketLen < kDefaultV6UDPSendPacketLen
|
(kDefaultV4UDPSendPacketLen < kDefaultV6UDPSendPacketLen
|
||||||
? kDefaultV4UDPSendPacketLen
|
? kDefaultV4UDPSendPacketLen
|
||||||
: kDefaultV6UDPSendPacketLen);
|
: kDefaultV6UDPSendPacketLen);
|
||||||
// This is the default if the transport parameter for max packet size is missing
|
// The max we will tolerate a peer's max_packet_size to be.
|
||||||
// or zero.
|
constexpr uint16_t kDefaultMaxUDPPayload = 1452;
|
||||||
constexpr uint16_t kDefaultMaxUDPPayload = 4096;
|
|
||||||
|
|
||||||
// This is the minimum the max_packet_size transport parameter is allowed to be,
|
// This is the minimum the max_packet_size transport parameter is allowed to be,
|
||||||
// per the spec. Note this actually refers to the max UDP payload size, not the
|
// per the spec. Note this actually refers to the max UDP payload size, not the
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void processServerInitialParams(
|
|||||||
// TODO Validate active_connection_id_limit
|
// TODO Validate active_connection_id_limit
|
||||||
|
|
||||||
if (!packetSize || *packetSize == 0) {
|
if (!packetSize || *packetSize == 0) {
|
||||||
packetSize = kDefaultMaxUDPPayload;
|
packetSize = kDefaultUDPSendPacketLen;
|
||||||
}
|
}
|
||||||
if (*packetSize < kMinMaxUDPPayload) {
|
if (*packetSize < kMinMaxUDPPayload) {
|
||||||
throw QuicTransportException(
|
throw QuicTransportException(
|
||||||
@@ -134,8 +134,10 @@ void processServerInitialParams(
|
|||||||
ackDelayExponent.value_or(kDefaultAckDelayExponent);
|
ackDelayExponent.value_or(kDefaultAckDelayExponent);
|
||||||
// TODO: udpSendPacketLen should also be limited by PMTU
|
// TODO: udpSendPacketLen should also be limited by PMTU
|
||||||
if (conn.transportSettings.canIgnorePathMTU) {
|
if (conn.transportSettings.canIgnorePathMTU) {
|
||||||
conn.udpSendPacketLen =
|
if (*packetSize > kDefaultMaxUDPPayload) {
|
||||||
std::min<uint64_t>(*packetSize, kDefaultMaxUDPPayload);
|
*packetSize = kDefaultUDPSendPacketLen;
|
||||||
|
}
|
||||||
|
conn.udpSendPacketLen = *packetSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently no-op for a client; it doesn't issue connection ids
|
// Currently no-op for a client; it doesn't issue connection ids
|
||||||
|
|||||||
@@ -1228,7 +1228,7 @@ class FakeOneRttHandshakeLayer : public FizzClientHandshake {
|
|||||||
|
|
||||||
bool connected_{false};
|
bool connected_{false};
|
||||||
QuicVersion negotiatedVersion{QuicVersion::MVFST};
|
QuicVersion negotiatedVersion{QuicVersion::MVFST};
|
||||||
uint64_t maxRecvPacketSize{2 * 1024};
|
uint64_t maxRecvPacketSize{kDefaultMaxUDPPayload};
|
||||||
uint64_t maxInitialStreamData{kDefaultStreamWindowSize};
|
uint64_t maxInitialStreamData{kDefaultStreamWindowSize};
|
||||||
uint64_t connWindowSize{kDefaultConnectionWindowSize};
|
uint64_t connWindowSize{kDefaultConnectionWindowSize};
|
||||||
uint64_t maxInitialStreamsBidi{std::numeric_limits<uint32_t>::max()};
|
uint64_t maxInitialStreamsBidi{std::numeric_limits<uint32_t>::max()};
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ void processClientInitialParams(
|
|||||||
// TODO Validate active_connection_id_limit
|
// TODO Validate active_connection_id_limit
|
||||||
|
|
||||||
if (!packetSize || *packetSize == 0) {
|
if (!packetSize || *packetSize == 0) {
|
||||||
packetSize = kDefaultMaxUDPPayload;
|
packetSize = kDefaultUDPSendPacketLen;
|
||||||
}
|
}
|
||||||
if (*packetSize < kMinMaxUDPPayload) {
|
if (*packetSize < kMinMaxUDPPayload) {
|
||||||
throw QuicTransportException(
|
throw QuicTransportException(
|
||||||
@@ -165,8 +165,10 @@ void processClientInitialParams(
|
|||||||
ackDelayExponent.value_or(kDefaultAckDelayExponent);
|
ackDelayExponent.value_or(kDefaultAckDelayExponent);
|
||||||
// TODO: udpSendPacketLen should also be limited by PMTU
|
// TODO: udpSendPacketLen should also be limited by PMTU
|
||||||
if (conn.transportSettings.canIgnorePathMTU) {
|
if (conn.transportSettings.canIgnorePathMTU) {
|
||||||
conn.udpSendPacketLen =
|
if (*packetSize > kDefaultMaxUDPPayload) {
|
||||||
std::min<uint64_t>(*packetSize, kDefaultMaxUDPPayload);
|
*packetSize = kDefaultUDPSendPacketLen;
|
||||||
|
}
|
||||||
|
conn.udpSendPacketLen = *packetSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.peerActiveConnectionIdLimit =
|
conn.peerActiveConnectionIdLimit =
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ class FakeServerHandshake : public ServerHandshake {
|
|||||||
QuicServerConnectionState& conn_;
|
QuicServerConnectionState& conn_;
|
||||||
bool chloSync_{false};
|
bool chloSync_{false};
|
||||||
bool cfinSync_{false};
|
bool cfinSync_{false};
|
||||||
uint64_t maxRecvPacketSize{2 * 1024};
|
uint64_t maxRecvPacketSize{kDefaultMaxUDPPayload};
|
||||||
bool allowZeroRttKeys_{false};
|
bool allowZeroRttKeys_{false};
|
||||||
std::vector<folly::IPAddress> sourceAddrs_;
|
std::vector<folly::IPAddress> sourceAddrs_;
|
||||||
folly::Optional<uint64_t> clientActiveConnectionIdLimit_;
|
folly::Optional<uint64_t> clientActiveConnectionIdLimit_;
|
||||||
@@ -3645,6 +3645,7 @@ TEST_F(
|
|||||||
server->getConn().transportSettings.limitedCwndInMss * originalUdpSize +
|
server->getConn().transportSettings.limitedCwndInMss * originalUdpSize +
|
||||||
server->getConn().transportSettings.limitedCwndInMss *
|
server->getConn().transportSettings.limitedCwndInMss *
|
||||||
server->getConn().udpSendPacketLen;
|
server->getConn().udpSendPacketLen;
|
||||||
|
EXPECT_NE(originalUdpSize, server->getConn().udpSendPacketLen);
|
||||||
EXPECT_EQ(*server->getNonConstConn().writableBytesLimit, expectedLen);
|
EXPECT_EQ(*server->getNonConstConn().writableBytesLimit, expectedLen);
|
||||||
std::vector<int> indices =
|
std::vector<int> indices =
|
||||||
getQLogEventIndices(QLogEventType::TransportStateUpdate, qLogger);
|
getQLogEventIndices(QLogEventType::TransportStateUpdate, qLogger);
|
||||||
@@ -3658,6 +3659,16 @@ TEST_F(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(QuicUnencryptedServerTransportTest, MaxReceivePacketSizeTooLarge) {
|
||||||
|
getFakeHandshakeLayer()->allowZeroRttKeys();
|
||||||
|
auto originalUdpSize = server->getConn().udpSendPacketLen;
|
||||||
|
fakeHandshake->maxRecvPacketSize = 4096;
|
||||||
|
setupClientReadCodec();
|
||||||
|
recvClientHello();
|
||||||
|
EXPECT_NE(originalUdpSize, server->getConn().udpSendPacketLen);
|
||||||
|
EXPECT_EQ(server->getConn().udpSendPacketLen, kDefaultUDPSendPacketLen);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(QuicUnencryptedServerTransportTest, TestGarbageData) {
|
TEST_F(QuicUnencryptedServerTransportTest, TestGarbageData) {
|
||||||
auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Server);
|
auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Server);
|
||||||
server->getNonConstConn().qLogger = qLogger;
|
server->getNonConstConn().qLogger = qLogger;
|
||||||
|
|||||||
Reference in New Issue
Block a user