Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quic: applying config options upstream #18754

Merged
merged 1 commit into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions source/common/http/http3/conn_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ ActiveClient::ActiveClient(Envoy::Http::HttpConnPoolImplBase& parent,

void Http3ConnPoolImpl::setQuicConfigFromClusterConfig(const Upstream::ClusterInfo& cluster,
quic::QuicConfig& quic_config) {
// TODO(alyssawilk) use and test other defaults.
Quic::convertQuicConfig(cluster.http3Options().quic_protocol_options(), quic_config);
quic::QuicTime::Delta crypto_timeout =
quic::QuicTime::Delta::FromMilliseconds(cluster.connectTimeout().count());
quic_config.set_max_time_before_crypto_handshake(crypto_timeout);
int32_t max_streams = getMaxStreams(cluster);
quic_config.SetMaxBidirectionalStreamsToSend(max_streams);
quic_config.SetMaxUnidirectionalStreamsToSend(max_streams);
Quic::configQuicInitialFlowControlWindow(cluster.http3Options().quic_protocol_options(),
quic_config);
}

Http3ConnPoolImpl::Http3ConnPoolImpl(
Expand Down
6 changes: 1 addition & 5 deletions source/common/quic/active_quic_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,7 @@ ActiveQuicListenerFactory::ActiveQuicListenerFactory(
: 20000;
quic_config_.set_max_time_before_crypto_handshake(
quic::QuicTime::Delta::FromMilliseconds(max_time_before_crypto_handshake_ms));
int32_t max_streams =
PROTOBUF_GET_WRAPPED_OR_DEFAULT(config.quic_protocol_options(), max_concurrent_streams, 100);
quic_config_.SetMaxBidirectionalStreamsToSend(max_streams);
quic_config_.SetMaxUnidirectionalStreamsToSend(max_streams);
configQuicInitialFlowControlWindow(config.quic_protocol_options(), quic_config_);
convertQuicConfig(config.quic_protocol_options(), quic_config_);

// Initialize crypto stream factory.
envoy::config::core::v3::TypedExtensionConfig crypto_stream_config;
Expand Down
8 changes: 8 additions & 0 deletions source/common/quic/envoy_quic_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ createServerConnectionSocket(Network::IoHandle& io_handle,
return connection_socket;
}

void convertQuicConfig(const envoy::config::core::v3::QuicProtocolOptions& config,
quic::QuicConfig& quic_config) {
int32_t max_streams = PROTOBUF_GET_WRAPPED_OR_DEFAULT(config, max_concurrent_streams, 100);
quic_config.SetMaxBidirectionalStreamsToSend(max_streams);
quic_config.SetMaxUnidirectionalStreamsToSend(max_streams);
configQuicInitialFlowControlWindow(config, quic_config);
}

void configQuicInitialFlowControlWindow(const envoy::config::core::v3::QuicProtocolOptions& config,
quic::QuicConfig& quic_config) {
size_t stream_flow_control_window_to_send = PROTOBUF_GET_WRAPPED_OR_DEFAULT(
Expand Down
4 changes: 4 additions & 0 deletions source/common/quic/envoy_quic_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ createServerConnectionSocket(Network::IoHandle& io_handle,
const quic::QuicSocketAddress& peer_address,
const std::string& hostname, absl::string_view alpn);

// Alter QuicConfig based on all the options in the supplied config.
void convertQuicConfig(const envoy::config::core::v3::QuicProtocolOptions& config,
quic::QuicConfig& quic_config);

// Set initial flow control windows in quic_config according to the given Envoy config.
void configQuicInitialFlowControlWindow(const envoy::config::core::v3::QuicProtocolOptions& config,
quic::QuicConfig& quic_config);
Expand Down
21 changes: 21 additions & 0 deletions test/common/quic/envoy_quic_utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,26 @@ TEST(EnvoyQuicUtilsTest, deduceSignatureAlgorithmFromNullPublicKey) {
EXPECT_EQ("Invalid leaf cert, bad public key", error);
}

TEST(EnvoyQuicUtilsTest, ConvertQuicConfig) {
envoy::config::core::v3::QuicProtocolOptions config;
quic::QuicConfig quic_config;

// Test defaults.
convertQuicConfig(config, quic_config);
EXPECT_EQ(100, quic_config.GetMaxBidirectionalStreamsToSend());
EXPECT_EQ(100, quic_config.GetMaxUnidirectionalStreamsToSend());
EXPECT_EQ(16777216, quic_config.GetInitialMaxStreamDataBytesIncomingBidirectionalToSend());
EXPECT_EQ(25165824, quic_config.GetInitialSessionFlowControlWindowToSend());

// Test converting values.
config.mutable_max_concurrent_streams()->set_value(2);
config.mutable_initial_stream_window_size()->set_value(3);
config.mutable_initial_connection_window_size()->set_value(50);
convertQuicConfig(config, quic_config);
EXPECT_EQ(2, quic_config.GetMaxBidirectionalStreamsToSend());
EXPECT_EQ(2, quic_config.GetMaxUnidirectionalStreamsToSend());
EXPECT_EQ(3, quic_config.GetInitialMaxStreamDataBytesIncomingBidirectionalToSend());
}

} // namespace Quic
} // namespace Envoy