From 255f78b3cc66d9ed3aa86cb491d98759314294b9 Mon Sep 17 00:00:00 2001 From: alyssawilk Date: Thu, 18 Mar 2021 16:45:51 -0400 Subject: [PATCH] quic: adding upstream config (#15537) Alas I didn't end up moving all of the protocol options over, as the cluster has its own timeout params so most of the QuicProtocolOptions are listener-specific. Commit Message: adding quic protocol config to quic upstream Risk Level: n/a (quic only) Testing: unit tests Docs Changes: n/a Release Notes: n/a part of #14829 Signed-off-by: Alyssa Wilk --- api/envoy/config/core/v3/protocol.proto | 8 +++++++ api/envoy/config/core/v4alpha/protocol.proto | 12 ++++++++++ .../config/listener/v3/quic_config.proto | 5 ++-- .../config/listener/v4alpha/quic_config.proto | 5 ++-- .../envoy/config/core/v3/protocol.proto | 8 +++++++ .../envoy/config/core/v4alpha/protocol.proto | 12 ++++++++++ .../config/listener/v3/quic_config.proto | 5 ++-- .../config/listener/v4alpha/quic_config.proto | 5 ++-- include/envoy/upstream/upstream.h | 6 +++++ source/common/http/conn_pool_base.cc | 9 +++++--- source/common/http/conn_pool_base.h | 10 ++++---- source/common/http/http2/conn_pool.cc | 10 ++++---- source/common/http/http3/BUILD | 2 +- source/common/http/http3/conn_pool.h | 13 +++++++---- .../http3/quic_client_connection_factory.h | 2 +- source/common/upstream/upstream_impl.h | 3 +++ .../quiche/active_quic_listener.cc | 3 ++- source/extensions/upstreams/http/config.cc | 23 +++++++++---------- source/extensions/upstreams/http/config.h | 2 +- .../active_quic_listener_config_test.cc | 6 +++-- .../quiche/active_quic_listener_test.cc | 3 ++- .../quiche/quic_upstream_test.cc | 9 +++++++- test/mocks/upstream/cluster_info.cc | 1 + test/mocks/upstream/cluster_info.h | 2 ++ 24 files changed, 117 insertions(+), 47 deletions(-) diff --git a/api/envoy/config/core/v3/protocol.proto b/api/envoy/config/core/v3/protocol.proto index 03c48d6f0ba8..8c7693c8ab17 100644 --- a/api/envoy/config/core/v3/protocol.proto +++ b/api/envoy/config/core/v3/protocol.proto @@ -24,6 +24,13 @@ message TcpProtocolOptions { "envoy.api.v2.core.TcpProtocolOptions"; } +// QUIC protocol options which apply to both downstream and upstream connections. +message QuicProtocolOptions { + // Maximum number of streams that the client can negotiate per connection. 100 + // if not specified. + google.protobuf.UInt32Value max_concurrent_streams = 1; +} + message UpstreamHttpProtocolOptions { option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.core.UpstreamHttpProtocolOptions"; @@ -406,4 +413,5 @@ message GrpcProtocolOptions { // // Eventually this will include configuration for tuning HTTP/3. message Http3ProtocolOptions { + QuicProtocolOptions quic_protocol_options = 1; } diff --git a/api/envoy/config/core/v4alpha/protocol.proto b/api/envoy/config/core/v4alpha/protocol.proto index 1e380ad618e9..1f0af4d12922 100644 --- a/api/envoy/config/core/v4alpha/protocol.proto +++ b/api/envoy/config/core/v4alpha/protocol.proto @@ -24,6 +24,16 @@ message TcpProtocolOptions { "envoy.config.core.v3.TcpProtocolOptions"; } +// QUIC protocol options which apply to both downstream and upstream connections. +message QuicProtocolOptions { + option (udpa.annotations.versioning).previous_message_type = + "envoy.config.core.v3.QuicProtocolOptions"; + + // Maximum number of streams that the client can negotiate per connection. 100 + // if not specified. + google.protobuf.UInt32Value max_concurrent_streams = 1; +} + message UpstreamHttpProtocolOptions { option (udpa.annotations.versioning).previous_message_type = "envoy.config.core.v3.UpstreamHttpProtocolOptions"; @@ -401,4 +411,6 @@ message GrpcProtocolOptions { message Http3ProtocolOptions { option (udpa.annotations.versioning).previous_message_type = "envoy.config.core.v3.Http3ProtocolOptions"; + + QuicProtocolOptions quic_protocol_options = 1; } diff --git a/api/envoy/config/listener/v3/quic_config.proto b/api/envoy/config/listener/v3/quic_config.proto index 658389ed3bfd..bbfbe71feae0 100644 --- a/api/envoy/config/listener/v3/quic_config.proto +++ b/api/envoy/config/listener/v3/quic_config.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package envoy.config.listener.v3; import "envoy/config/core/v3/base.proto"; +import "envoy/config/core/v3/protocol.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/wrappers.proto"; @@ -24,9 +25,7 @@ message QuicProtocolOptions { option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.listener.QuicProtocolOptions"; - // Maximum number of streams that the client can negotiate per connection. 100 - // if not specified. - google.protobuf.UInt32Value max_concurrent_streams = 1; + core.v3.QuicProtocolOptions quic_protocol_options = 1; // Maximum number of milliseconds that connection will be alive when there is // no network activity. 300000ms if not specified. diff --git a/api/envoy/config/listener/v4alpha/quic_config.proto b/api/envoy/config/listener/v4alpha/quic_config.proto index f9c6d02b6452..10aaf1f19aa7 100644 --- a/api/envoy/config/listener/v4alpha/quic_config.proto +++ b/api/envoy/config/listener/v4alpha/quic_config.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package envoy.config.listener.v4alpha; import "envoy/config/core/v4alpha/base.proto"; +import "envoy/config/core/v4alpha/protocol.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/wrappers.proto"; @@ -24,9 +25,7 @@ message QuicProtocolOptions { option (udpa.annotations.versioning).previous_message_type = "envoy.config.listener.v3.QuicProtocolOptions"; - // Maximum number of streams that the client can negotiate per connection. 100 - // if not specified. - google.protobuf.UInt32Value max_concurrent_streams = 1; + core.v4alpha.QuicProtocolOptions quic_protocol_options = 1; // Maximum number of milliseconds that connection will be alive when there is // no network activity. 300000ms if not specified. diff --git a/generated_api_shadow/envoy/config/core/v3/protocol.proto b/generated_api_shadow/envoy/config/core/v3/protocol.proto index 03c48d6f0ba8..8c7693c8ab17 100644 --- a/generated_api_shadow/envoy/config/core/v3/protocol.proto +++ b/generated_api_shadow/envoy/config/core/v3/protocol.proto @@ -24,6 +24,13 @@ message TcpProtocolOptions { "envoy.api.v2.core.TcpProtocolOptions"; } +// QUIC protocol options which apply to both downstream and upstream connections. +message QuicProtocolOptions { + // Maximum number of streams that the client can negotiate per connection. 100 + // if not specified. + google.protobuf.UInt32Value max_concurrent_streams = 1; +} + message UpstreamHttpProtocolOptions { option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.core.UpstreamHttpProtocolOptions"; @@ -406,4 +413,5 @@ message GrpcProtocolOptions { // // Eventually this will include configuration for tuning HTTP/3. message Http3ProtocolOptions { + QuicProtocolOptions quic_protocol_options = 1; } diff --git a/generated_api_shadow/envoy/config/core/v4alpha/protocol.proto b/generated_api_shadow/envoy/config/core/v4alpha/protocol.proto index 318d27d718a9..131553b755df 100644 --- a/generated_api_shadow/envoy/config/core/v4alpha/protocol.proto +++ b/generated_api_shadow/envoy/config/core/v4alpha/protocol.proto @@ -24,6 +24,16 @@ message TcpProtocolOptions { "envoy.config.core.v3.TcpProtocolOptions"; } +// QUIC protocol options which apply to both downstream and upstream connections. +message QuicProtocolOptions { + option (udpa.annotations.versioning).previous_message_type = + "envoy.config.core.v3.QuicProtocolOptions"; + + // Maximum number of streams that the client can negotiate per connection. 100 + // if not specified. + google.protobuf.UInt32Value max_concurrent_streams = 1; +} + message UpstreamHttpProtocolOptions { option (udpa.annotations.versioning).previous_message_type = "envoy.config.core.v3.UpstreamHttpProtocolOptions"; @@ -411,4 +421,6 @@ message GrpcProtocolOptions { message Http3ProtocolOptions { option (udpa.annotations.versioning).previous_message_type = "envoy.config.core.v3.Http3ProtocolOptions"; + + QuicProtocolOptions quic_protocol_options = 1; } diff --git a/generated_api_shadow/envoy/config/listener/v3/quic_config.proto b/generated_api_shadow/envoy/config/listener/v3/quic_config.proto index 658389ed3bfd..bbfbe71feae0 100644 --- a/generated_api_shadow/envoy/config/listener/v3/quic_config.proto +++ b/generated_api_shadow/envoy/config/listener/v3/quic_config.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package envoy.config.listener.v3; import "envoy/config/core/v3/base.proto"; +import "envoy/config/core/v3/protocol.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/wrappers.proto"; @@ -24,9 +25,7 @@ message QuicProtocolOptions { option (udpa.annotations.versioning).previous_message_type = "envoy.api.v2.listener.QuicProtocolOptions"; - // Maximum number of streams that the client can negotiate per connection. 100 - // if not specified. - google.protobuf.UInt32Value max_concurrent_streams = 1; + core.v3.QuicProtocolOptions quic_protocol_options = 1; // Maximum number of milliseconds that connection will be alive when there is // no network activity. 300000ms if not specified. diff --git a/generated_api_shadow/envoy/config/listener/v4alpha/quic_config.proto b/generated_api_shadow/envoy/config/listener/v4alpha/quic_config.proto index f9c6d02b6452..10aaf1f19aa7 100644 --- a/generated_api_shadow/envoy/config/listener/v4alpha/quic_config.proto +++ b/generated_api_shadow/envoy/config/listener/v4alpha/quic_config.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package envoy.config.listener.v4alpha; import "envoy/config/core/v4alpha/base.proto"; +import "envoy/config/core/v4alpha/protocol.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/wrappers.proto"; @@ -24,9 +25,7 @@ message QuicProtocolOptions { option (udpa.annotations.versioning).previous_message_type = "envoy.config.listener.v3.QuicProtocolOptions"; - // Maximum number of streams that the client can negotiate per connection. 100 - // if not specified. - google.protobuf.UInt32Value max_concurrent_streams = 1; + core.v4alpha.QuicProtocolOptions quic_protocol_options = 1; // Maximum number of milliseconds that connection will be alive when there is // no network activity. 300000ms if not specified. diff --git a/include/envoy/upstream/upstream.h b/include/envoy/upstream/upstream.h index e1b9e9c8a115..6a5cb1a151c2 100644 --- a/include/envoy/upstream/upstream.h +++ b/include/envoy/upstream/upstream.h @@ -764,6 +764,12 @@ class ClusterInfo { */ virtual const envoy::config::core::v3::Http2ProtocolOptions& http2Options() const PURE; + /** + * @return const envoy::config::core::v3::Http3ProtocolOptions& for HTTP/3 connections + * created on behalf of this cluster. @see envoy::config::core::v3::Http3ProtocolOptions. + */ + virtual const envoy::config::core::v3::Http3ProtocolOptions& http3Options() const PURE; + /** * @return const envoy::config::core::v3::HttpProtocolOptions for all of HTTP versions. */ diff --git a/source/common/http/conn_pool_base.cc b/source/common/http/conn_pool_base.cc index 96e68d05f854..a5b6a4b4e9ae 100644 --- a/source/common/http/conn_pool_base.cc +++ b/source/common/http/conn_pool_base.cc @@ -176,21 +176,23 @@ uint64_t maxStreamsPerConnection(uint64_t max_streams_config) { } MultiplexedActiveClientBase::MultiplexedActiveClientBase(HttpConnPoolImplBase& parent, + uint32_t max_concurrent_streams, Stats::Counter& cx_total) : Envoy::Http::ActiveClient( parent, maxStreamsPerConnection(parent.host()->cluster().maxRequestsPerConnection()), - parent.host()->cluster().http2Options().max_concurrent_streams().value()) { + max_concurrent_streams) { codec_client_->setCodecClientCallbacks(*this); codec_client_->setCodecConnectionCallbacks(*this); cx_total.inc(); } MultiplexedActiveClientBase::MultiplexedActiveClientBase(HttpConnPoolImplBase& parent, + uint32_t max_concurrent_streams, Stats::Counter& cx_total, Upstream::Host::CreateConnectionData& data) : Envoy::Http::ActiveClient( parent, maxStreamsPerConnection(parent.host()->cluster().maxRequestsPerConnection()), - parent.host()->cluster().http2Options().max_concurrent_streams().value(), data) { + max_concurrent_streams, data) { codec_client_->setCodecClientCallbacks(*this); codec_client_->setCodecConnectionCallbacks(*this); cx_total.inc(); @@ -198,10 +200,11 @@ MultiplexedActiveClientBase::MultiplexedActiveClientBase(HttpConnPoolImplBase& p MultiplexedActiveClientBase::MultiplexedActiveClientBase(Envoy::Http::HttpConnPoolImplBase& parent, Upstream::Host::CreateConnectionData& data, + uint32_t max_concurrent_streams, Stats::Counter& cx_total) : Envoy::Http::ActiveClient( parent, maxStreamsPerConnection(parent.host()->cluster().maxRequestsPerConnection()), - parent.host()->cluster().http2Options().max_concurrent_streams().value(), data) { + max_concurrent_streams, data) { codec_client_->setCodecClientCallbacks(*this); codec_client_->setCodecConnectionCallbacks(*this); cx_total.inc(); diff --git a/source/common/http/conn_pool_base.h b/source/common/http/conn_pool_base.h index 21e6e782c009..27bcbf6a55ee 100644 --- a/source/common/http/conn_pool_base.h +++ b/source/common/http/conn_pool_base.h @@ -173,9 +173,10 @@ class MultiplexedActiveClientBase : public CodecClientCallbacks, public Http::ConnectionCallbacks, public Envoy::Http::ActiveClient { public: - MultiplexedActiveClientBase(HttpConnPoolImplBase& parent, Stats::Counter& cx_total); - MultiplexedActiveClientBase(HttpConnPoolImplBase& parent, Stats::Counter& cx_total, - Upstream::Host::CreateConnectionData& data); + MultiplexedActiveClientBase(HttpConnPoolImplBase& parent, uint32_t max_concurrent_streams, + Stats::Counter& cx_total); + MultiplexedActiveClientBase(HttpConnPoolImplBase& parent, uint32_t max_concurrent_streams, + Stats::Counter& cx_total, Upstream::Host::CreateConnectionData& data); ~MultiplexedActiveClientBase() override = default; // ConnPoolImpl::ActiveClient @@ -205,7 +206,8 @@ class MultiplexedActiveClientBase : public CodecClientCallbacks, protected: MultiplexedActiveClientBase(Envoy::Http::HttpConnPoolImplBase& parent, - Upstream::Host::CreateConnectionData& data, Stats::Counter& cx_total); + Upstream::Host::CreateConnectionData& data, + uint32_t max_concurrent_streams, Stats::Counter& cx_total); private: bool closed_with_active_rq_{}; diff --git a/source/common/http/http2/conn_pool.cc b/source/common/http/http2/conn_pool.cc index d98aee6e7c43..fe8dca2c4247 100644 --- a/source/common/http/http2/conn_pool.cc +++ b/source/common/http/http2/conn_pool.cc @@ -13,13 +13,15 @@ namespace Http { namespace Http2 { ActiveClient::ActiveClient(HttpConnPoolImplBase& parent) - : MultiplexedActiveClientBase(parent, - parent.host()->cluster().stats().upstream_cx_http2_total_) {} + : MultiplexedActiveClientBase( + parent, parent.host()->cluster().http2Options().max_concurrent_streams().value(), + parent.host()->cluster().stats().upstream_cx_http2_total_) {} ActiveClient::ActiveClient(Envoy::Http::HttpConnPoolImplBase& parent, Upstream::Host::CreateConnectionData& data) - : MultiplexedActiveClientBase(parent, data, - parent.host()->cluster().stats().upstream_cx_http2_total_) {} + : MultiplexedActiveClientBase( + parent, data, parent.host()->cluster().http2Options().max_concurrent_streams().value(), + parent.host()->cluster().stats().upstream_cx_http2_total_) {} ConnectionPool::InstancePtr allocateConnPool(Event::Dispatcher& dispatcher, Random::RandomGenerator& random_generator, diff --git a/source/common/http/http3/BUILD b/source/common/http/http3/BUILD index c0700ecf1417..112ca100d629 100644 --- a/source/common/http/http3/BUILD +++ b/source/common/http/http3/BUILD @@ -38,7 +38,7 @@ envoy_cc_library( "//include/envoy/config:typed_config_interface", "//include/envoy/network:connection_interface", "//include/envoy/ssl:context_config_interface", - "@envoy_api//envoy/config/listener/v3:pkg_cc_proto", + "@envoy_api//envoy/config/core/v3:pkg_cc_proto", ], ) diff --git a/source/common/http/http3/conn_pool.h b/source/common/http/http3/conn_pool.h index c2a664dd86fc..6f3196253048 100644 --- a/source/common/http/http3/conn_pool.h +++ b/source/common/http/http3/conn_pool.h @@ -11,14 +11,19 @@ namespace Envoy { namespace Http { namespace Http3 { -// TODO(#14829) the constructor of Http2::ActiveClient sets max requests per -// connection based on HTTP/2 config. Sort out the HTTP/3 config story. class ActiveClient : public MultiplexedActiveClientBase { public: ActiveClient(Envoy::Http::HttpConnPoolImplBase& parent, Upstream::Host::CreateConnectionData& data) - : MultiplexedActiveClientBase( - parent, parent.host()->cluster().stats().upstream_cx_http3_total_, data) {} + : MultiplexedActiveClientBase(parent, + parent.host() + ->cluster() + .http3Options() + .quic_protocol_options() + .max_concurrent_streams() + .value(), + parent.host()->cluster().stats().upstream_cx_http3_total_, + data) {} }; ConnectionPool::InstancePtr diff --git a/source/common/http/http3/quic_client_connection_factory.h b/source/common/http/http3/quic_client_connection_factory.h index 2277f6baadd7..7a27a1a26365 100644 --- a/source/common/http/http3/quic_client_connection_factory.h +++ b/source/common/http/http3/quic_client_connection_factory.h @@ -2,7 +2,7 @@ #include -#include "envoy/config/listener/v3/quic_config.pb.h" +#include "envoy/config/core/v3/protocol.pb.h" #include "envoy/config/typed_config.h" #include "envoy/network/connection.h" #include "envoy/ssl/context_config.h" diff --git a/source/common/upstream/upstream_impl.h b/source/common/upstream/upstream_impl.h index 3510313adc7d..eb38961922c3 100644 --- a/source/common/upstream/upstream_impl.h +++ b/source/common/upstream/upstream_impl.h @@ -561,6 +561,9 @@ class ClusterInfoImpl : public ClusterInfo, const envoy::config::core::v3::Http2ProtocolOptions& http2Options() const override { return http_protocol_options_->http2_options_; } + const envoy::config::core::v3::Http3ProtocolOptions& http3Options() const override { + return http_protocol_options_->http3_options_; + } const envoy::config::core::v3::HttpProtocolOptions& commonHttpProtocolOptions() const override { return http_protocol_options_->common_http_protocol_options_; } diff --git a/source/extensions/quic_listeners/quiche/active_quic_listener.cc b/source/extensions/quic_listeners/quiche/active_quic_listener.cc index 3bd2d2f38d9b..003ceeb9fd3b 100644 --- a/source/extensions/quic_listeners/quiche/active_quic_listener.cc +++ b/source/extensions/quic_listeners/quiche/active_quic_listener.cc @@ -219,7 +219,8 @@ 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, max_concurrent_streams, 100); + 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); } diff --git a/source/extensions/upstreams/http/config.cc b/source/extensions/upstreams/http/config.cc index eff6d2d4af20..ba4a83ef8281 100644 --- a/source/extensions/upstreams/http/config.cc +++ b/source/extensions/upstreams/http/config.cc @@ -41,17 +41,13 @@ getHttp2Options(const envoy::extensions::upstreams::http::v3::HttpProtocolOption return options.explicit_http_config().http2_protocol_options(); } -absl::optional +const envoy::config::core::v3::Http3ProtocolOptions& getHttp3Options(const envoy::extensions::upstreams::http::v3::HttpProtocolOptions& options) { if (options.has_use_downstream_protocol_config() && options.use_downstream_protocol_config().has_http3_protocol_options()) { return options.use_downstream_protocol_config().http3_protocol_options(); } - if (options.has_explicit_http_config() && - options.explicit_http_config().has_http3_protocol_options()) { - return options.explicit_http_config().http3_protocol_options(); - } - return {}; + return options.explicit_http_config().http3_protocol_options(); } } // namespace @@ -89,14 +85,17 @@ ProtocolOptionsConfigImpl::ProtocolOptionsConfigImpl( ? absl::make_optional( options.upstream_http_protocol_options()) : absl::nullopt) { - if (http3_options_.has_value()) { - use_http3_ = true; - } - if (options.has_explicit_http_config() && - options.explicit_http_config().has_http2_protocol_options()) { - use_http2_ = true; + if (options.has_explicit_http_config()) { + if (options.explicit_http_config().has_http3_protocol_options()) { + use_http3_ = true; + } else if (options.explicit_http_config().has_http2_protocol_options()) { + use_http2_ = true; + } } if (options.has_use_downstream_protocol_config()) { + if (options.use_downstream_protocol_config().has_http3_protocol_options()) { + use_http3_ = true; + } if (options.use_downstream_protocol_config().has_http2_protocol_options()) { use_http2_ = true; } diff --git a/source/extensions/upstreams/http/config.h b/source/extensions/upstreams/http/config.h index bd620bc15761..9fd0141d7756 100644 --- a/source/extensions/upstreams/http/config.h +++ b/source/extensions/upstreams/http/config.h @@ -41,7 +41,7 @@ class ProtocolOptionsConfigImpl : public Upstream::ProtocolOptionsConfig { const Envoy::Http::Http1Settings http1_settings_; const envoy::config::core::v3::Http2ProtocolOptions http2_options_; - absl::optional http3_options_{}; + const envoy::config::core::v3::Http3ProtocolOptions http3_options_{}; const envoy::config::core::v3::HttpProtocolOptions common_http_protocol_options_; const absl::optional upstream_http_protocol_options_; diff --git a/test/extensions/quic_listeners/quiche/active_quic_listener_config_test.cc b/test/extensions/quic_listeners/quiche/active_quic_listener_config_test.cc index d116f816b6ca..6831664f57b3 100644 --- a/test/extensions/quic_listeners/quiche/active_quic_listener_config_test.cc +++ b/test/extensions/quic_listeners/quiche/active_quic_listener_config_test.cc @@ -29,7 +29,8 @@ TEST(ActiveQuicListenerConfigTest, CreateActiveQuicListenerFactory) { ProtobufTypes::MessagePtr config = config_factory.createEmptyConfigProto(); std::string yaml = R"EOF( - max_concurrent_streams: 10 + quic_protocol_options: + max_concurrent_streams: 10 idle_timeout: { seconds: 2 } @@ -63,7 +64,8 @@ TEST(ActiveQuicListenerConfigTest, QuicListenerFlagNotConfigured) { ProtobufTypes::MessagePtr config = config_factory.createEmptyConfigProto(); std::string yaml = R"EOF( - max_concurrent_streams: 10 + quic_protocol_options: + max_concurrent_streams: 10 idle_timeout: { seconds: 2 } diff --git a/test/extensions/quic_listeners/quiche/active_quic_listener_test.cc b/test/extensions/quic_listeners/quiche/active_quic_listener_test.cc index e1499b4d7bda..f68bc6420c85 100644 --- a/test/extensions/quic_listeners/quiche/active_quic_listener_test.cc +++ b/test/extensions/quic_listeners/quiche/active_quic_listener_test.cc @@ -386,7 +386,8 @@ class ActiveQuicListenerEmptyFlagConfigTest : public ActiveQuicListenerTest { protected: std::string yamlForQuicConfig() override { return R"EOF( - max_concurrent_streams: 10 + quic_protocol_options: + max_concurrent_streams: 10 )EOF"; } }; diff --git a/test/extensions/quic_listeners/quiche/quic_upstream_test.cc b/test/extensions/quic_listeners/quiche/quic_upstream_test.cc index 3a9a2c53cc18..5c2ed95a8ce7 100644 --- a/test/extensions/quic_listeners/quiche/quic_upstream_test.cc +++ b/test/extensions/quic_listeners/quiche/quic_upstream_test.cc @@ -132,7 +132,9 @@ TEST_F(ClusterInfoImplTest, Http3) { envoy.extensions.upstreams.http.v3.HttpProtocolOptions: "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions explicit_http_config: - http3_protocol_options: {} + http3_protocol_options: + quic_protocol_options: + max_concurrent_streams: 2 common_http_protocol_options: idle_timeout: 1s )EOF"; @@ -150,10 +152,15 @@ TEST_F(ClusterInfoImplTest, Http3) { auto explicit_h3 = makeCluster(yaml + explicit_http3); EXPECT_EQ(Http::Protocol::Http3, explicit_h3->info()->upstreamHttpProtocol({Http::Protocol::Http10})[0]); + EXPECT_EQ( + explicit_h3->info()->http3Options().quic_protocol_options().max_concurrent_streams().value(), + 2); auto downstream_h3 = makeCluster(yaml + downstream_http3); EXPECT_EQ(Http::Protocol::Http3, downstream_h3->info()->upstreamHttpProtocol({Http::Protocol::Http3})[0]); + EXPECT_FALSE( + downstream_h3->info()->http3Options().quic_protocol_options().has_max_concurrent_streams()); } TEST_F(ClusterInfoImplTest, Http3BadConfig) { diff --git a/test/mocks/upstream/cluster_info.cc b/test/mocks/upstream/cluster_info.cc index 0b986eda49f4..063dfc76f6cd 100644 --- a/test/mocks/upstream/cluster_info.cc +++ b/test/mocks/upstream/cluster_info.cc @@ -68,6 +68,7 @@ MockClusterInfo::MockClusterInfo() ON_CALL(*this, edsServiceName()).WillByDefault(ReturnPointee(&eds_service_name_)); ON_CALL(*this, http1Settings()).WillByDefault(ReturnRef(http1_settings_)); ON_CALL(*this, http2Options()).WillByDefault(ReturnRef(http2_options_)); + ON_CALL(*this, http3Options()).WillByDefault(ReturnRef(http3_options_)); ON_CALL(*this, commonHttpProtocolOptions()) .WillByDefault(ReturnRef(common_http_protocol_options_)); ON_CALL(*this, extensionProtocolOptions(_)).WillByDefault(Return(extension_protocol_options_)); diff --git a/test/mocks/upstream/cluster_info.h b/test/mocks/upstream/cluster_info.h index ca9bb74024fb..31a941bb53ff 100644 --- a/test/mocks/upstream/cluster_info.h +++ b/test/mocks/upstream/cluster_info.h @@ -99,6 +99,7 @@ class MockClusterInfo : public ClusterInfo { MOCK_METHOD(uint64_t, features, (), (const)); MOCK_METHOD(const Http::Http1Settings&, http1Settings, (), (const)); MOCK_METHOD(const envoy::config::core::v3::Http2ProtocolOptions&, http2Options, (), (const)); + MOCK_METHOD(const envoy::config::core::v3::Http3ProtocolOptions&, http3Options, (), (const)); MOCK_METHOD(const envoy::config::core::v3::HttpProtocolOptions&, commonHttpProtocolOptions, (), (const)); MOCK_METHOD(ProtocolOptionsConfigConstSharedPtr, extensionProtocolOptions, (const std::string&), @@ -154,6 +155,7 @@ class MockClusterInfo : public ClusterInfo { absl::optional eds_service_name_; Http::Http1Settings http1_settings_; envoy::config::core::v3::Http2ProtocolOptions http2_options_; + envoy::config::core::v3::Http3ProtocolOptions http3_options_; envoy::config::core::v3::HttpProtocolOptions common_http_protocol_options_; ProtocolOptionsConfigConstSharedPtr extension_protocol_options_; uint64_t max_requests_per_connection_{};