Skip to content

Commit 446f6cc

Browse files
jbeshaymeta-codesync[bot]
authored andcommitted
Use a larger read buffer on the client to accommodate servers that ignore a small max_receive_size during the handshake
Summary: If the client sets a small max_udp_payload_size (<1280), some servers ignore it and end up sending larger packets anyway. Currently, our client transport sets its read buffer to the size of the max_udp_payload_size it sent in the handshake, and ends up truncating any incoming packets that are longer than that. Using a larger read buffer enables reading these packets successfully even though the server is violating the max_udp_payload_size parameter. Reviewed By: lnicco, kvtsoy Differential Revision: D85821409 fbshipit-source-id: 8257b3367cde8e8a7c7a888beb243ed93e950a19
1 parent 68e57c4 commit 446f6cc

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

quic/client/QuicClientTransport.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ void QuicClientTransport::onNotifyDataAvailable(
3434
QuicAsyncUDPSocket& sock) noexcept {
3535
auto self = this->shared_from_this();
3636
CHECK(conn_) << "trying to receive packets without a connection";
37-
auto readBufferSize =
38-
conn_->transportSettings.maxRecvPacketSize * numGROBuffers_;
37+
auto readBufferSize = std::max(
38+
conn_->transportSettings.maxRecvPacketSize,
39+
uint64_t(kDefaultUDPReadBufferSize)) *
40+
numGROBuffers_;
3941
const uint16_t numPackets = conn_->transportSettings.maxRecvBatchSize;
4042

4143
const size_t readAllocSize =

quic/client/QuicClientTransportLite.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,8 +1880,10 @@ void QuicClientTransportLite::onNotifyDataAvailable(
18801880
QuicAsyncUDPSocket& sock) noexcept {
18811881
auto self = this->shared_from_this();
18821882
CHECK(conn_) << "trying to receive packets without a connection";
1883-
auto readBufferSize =
1884-
conn_->transportSettings.maxRecvPacketSize * numGROBuffers_;
1883+
auto readBufferSize = std::max(
1884+
conn_->transportSettings.maxRecvPacketSize,
1885+
uint64_t(kDefaultUDPReadBufferSize)) *
1886+
numGROBuffers_;
18851887

18861888
const size_t readAllocSize =
18871889
conn_->transportSettings.readCoalescingSize > kDefaultUDPSendPacketLen

0 commit comments

Comments
 (0)