Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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
1 change: 1 addition & 0 deletions source/common/http/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ envoy_cc_library(
":http3_status_tracker",
":mixed_conn_pool",
"//source/common/http/http3:conn_pool_lib",
"//source/common/quic:quic_stat_names_lib",
],
)

Expand Down
8 changes: 5 additions & 3 deletions source/common/http/conn_pool_grid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,13 @@ ConnectivityGrid::ConnectivityGrid(
const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options,
Upstream::ClusterConnectivityState& state, TimeSource& time_source,
AlternateProtocolsCacheSharedPtr alternate_protocols,
std::chrono::milliseconds next_attempt_duration, ConnectivityOptions connectivity_options)
std::chrono::milliseconds next_attempt_duration, ConnectivityOptions connectivity_options,
Quic::QuicStatNames& quic_stat_names, Stats::Scope& scope)
: dispatcher_(dispatcher), random_generator_(random_generator), host_(host),
priority_(priority), options_(options), transport_socket_options_(transport_socket_options),
state_(state), next_attempt_duration_(next_attempt_duration), time_source_(time_source),
http3_status_tracker_(dispatcher_), alternate_protocols_(alternate_protocols) {
http3_status_tracker_(dispatcher_), alternate_protocols_(alternate_protocols),
quic_stat_names_(quic_stat_names), scope_(scope) {
// ProdClusterManagerFactory::allocateConnPool verifies the protocols are HTTP/1, HTTP/2 and
// HTTP/3.
// TODO(#15649) support v6/v4, WiFi/cellular.
Expand Down Expand Up @@ -225,7 +227,7 @@ absl::optional<ConnectivityGrid::PoolIterator> ConnectivityGrid::createNextPool(
if (pools_.empty()) {
pools_.push_back(Http3::allocateConnPool(dispatcher_, random_generator_, host_, priority_,
options_, transport_socket_options_, state_,
time_source_));
time_source_, quic_stat_names_, scope_));
return pools_.begin();
}
pools_.push_back(std::make_unique<HttpConnPoolImplMixed>(dispatcher_, random_generator_, host_,
Expand Down
7 changes: 6 additions & 1 deletion source/common/http/conn_pool_grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "source/common/http/alternate_protocols_cache_impl.h"
#include "source/common/http/conn_pool_base.h"
#include "source/common/http/http3_status_tracker.h"
#include "source/common/quic/quic_stat_names.h"

#include "absl/container/flat_hash_map.h"

Expand Down Expand Up @@ -134,7 +135,8 @@ class ConnectivityGrid : public ConnectionPool::Instance,
Upstream::ClusterConnectivityState& state, TimeSource& time_source,
AlternateProtocolsCacheSharedPtr alternate_protocols,
std::chrono::milliseconds next_attempt_duration,
ConnectivityOptions connectivity_options);
ConnectivityOptions connectivity_options, Quic::QuicStatNames& quic_stat_names,
Stats::Scope& scope);
~ConnectivityGrid() override;

// Http::ConnPool::Instance
Expand Down Expand Up @@ -210,6 +212,9 @@ class ConnectivityGrid : public ConnectionPool::Instance,

// Wrapped callbacks are stashed in the wrapped_callbacks_ for ownership.
std::list<WrapperCallbacksPtr> wrapped_callbacks_;

Quic::QuicStatNames& quic_stat_names_;
Stats::Scope& scope_;
};

} // namespace Http
Expand Down
11 changes: 7 additions & 4 deletions source/common/http/http3/conn_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ allocateConnPool(Event::Dispatcher& dispatcher, Random::RandomGenerator& random_
Upstream::HostConstSharedPtr host, Upstream::ResourcePriority priority,
const Network::ConnectionSocket::OptionsSharedPtr& options,
const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options,
Upstream::ClusterConnectivityState& state, TimeSource& time_source) {
Upstream::ClusterConnectivityState& state, TimeSource& time_source,
Quic::QuicStatNames& quic_stat_names, Stats::Scope& scope) {
return std::make_unique<Http3ConnPoolImpl>(
host, priority, dispatcher, options, transport_socket_options, random_generator, state,
[](HttpConnPoolImplBase* pool) -> ::Envoy::ConnectionPool::ActiveClientPtr {
[&quic_stat_names,
&scope](HttpConnPoolImplBase* pool) -> ::Envoy::ConnectionPool::ActiveClientPtr {
// If there's no ssl context, the secrets are not loaded. Fast-fail by returning null.
auto factory = &pool->host()->transportSocketFactory();
ASSERT(dynamic_cast<Quic::QuicClientTransportSocketFactory*>(factory) != nullptr);
Expand All @@ -77,8 +79,9 @@ allocateConnPool(Event::Dispatcher& dispatcher, Random::RandomGenerator& random_
if (!source_address.get()) {
source_address = Network::Utility::getLocalAddress(host_address->ip()->version());
}
data.connection_ = Quic::createQuicNetworkConnection(
h3_pool->quicInfo(), pool->dispatcher(), host_address, source_address);
data.connection_ =
Quic::createQuicNetworkConnection(h3_pool->quicInfo(), pool->dispatcher(), host_address,
source_address, quic_stat_names, scope);
return std::make_unique<ActiveClient>(*pool, data);
},
[](Upstream::Host::CreateConnectionData& data, HttpConnPoolImplBase* pool) {
Expand Down
3 changes: 2 additions & 1 deletion source/common/http/http3/conn_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ allocateConnPool(Event::Dispatcher& dispatcher, Random::RandomGenerator& random_
Upstream::HostConstSharedPtr host, Upstream::ResourcePriority priority,
const Network::ConnectionSocket::OptionsSharedPtr& options,
const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options,
Upstream::ClusterConnectivityState& state, TimeSource& time_source);
Upstream::ClusterConnectivityState& state, TimeSource& time_source,
Quic::QuicStatNames& quic_stat_names, Stats::Scope& scope);

} // namespace Http3
} // namespace Http
Expand Down
1 change: 1 addition & 0 deletions source/common/quic/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ envoy_cc_library(
":envoy_quic_stream_lib",
":envoy_quic_utils_lib",
":quic_filter_manager_connection_lib",
":quic_stat_names_lib",
"//source/common/buffer:buffer_lib",
"//source/common/common:assert_lib",
"//source/common/http:codes_lib",
Expand Down
5 changes: 3 additions & 2 deletions source/common/quic/client_connection_factory_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ PersistentQuicInfoImpl::PersistentQuicInfoImpl(
std::unique_ptr<Network::ClientConnection>
createQuicNetworkConnection(Http::PersistentQuicInfo& info, Event::Dispatcher& dispatcher,
Network::Address::InstanceConstSharedPtr server_addr,
Network::Address::InstanceConstSharedPtr local_addr) {
Network::Address::InstanceConstSharedPtr local_addr,
QuicStatNames& quic_stat_names, Stats::Scope& scope) {
// This flag fix a QUICHE issue which may crash Envoy during connection close.
SetQuicReloadableFlag(quic_single_ack_in_packet2, true);
PersistentQuicInfoImpl* info_impl = reinterpret_cast<PersistentQuicInfoImpl*>(&info);
Expand All @@ -74,7 +75,7 @@ createQuicNetworkConnection(Http::PersistentQuicInfo& info, Event::Dispatcher& d
auto ret = std::make_unique<EnvoyQuicClientSession>(
info_impl->quic_config_, info_impl->supported_versions_, std::move(connection),
info_impl->server_id_, std::move(config), &info_impl->push_promise_index_, dispatcher,
info_impl->buffer_limit_, info_impl->crypto_stream_factory_);
info_impl->buffer_limit_, info_impl->crypto_stream_factory_, quic_stat_names, scope);
return ret;
}

Expand Down
3 changes: 2 additions & 1 deletion source/common/quic/client_connection_factory_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ struct PersistentQuicInfoImpl : public Http::PersistentQuicInfo {
std::unique_ptr<Network::ClientConnection>
createQuicNetworkConnection(Http::PersistentQuicInfo& info, Event::Dispatcher& dispatcher,
Network::Address::InstanceConstSharedPtr server_addr,
Network::Address::InstanceConstSharedPtr local_addr);
Network::Address::InstanceConstSharedPtr local_addr,
QuicStatNames& quic_stat_names, Stats::Scope& scope);

} // namespace Quic
} // namespace Envoy
7 changes: 5 additions & 2 deletions source/common/quic/envoy_quic_client_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ EnvoyQuicClientSession::EnvoyQuicClientSession(
std::unique_ptr<EnvoyQuicClientConnection> connection, const quic::QuicServerId& server_id,
std::shared_ptr<quic::QuicCryptoClientConfig> crypto_config,
quic::QuicClientPushPromiseIndex* push_promise_index, Event::Dispatcher& dispatcher,
uint32_t send_buffer_limit, EnvoyQuicCryptoClientStreamFactoryInterface& crypto_stream_factory)
uint32_t send_buffer_limit, EnvoyQuicCryptoClientStreamFactoryInterface& crypto_stream_factory,
QuicStatNames& quic_stat_names, Stats::Scope& scope)
: QuicFilterManagerConnectionImpl(*connection, connection->connection_id(), dispatcher,
send_buffer_limit),
quic::QuicSpdyClientSession(config, supported_versions, connection.release(), server_id,
crypto_config.get(), push_promise_index),
host_name_(server_id.host()), crypto_config_(crypto_config),
crypto_stream_factory_(crypto_stream_factory) {}
crypto_stream_factory_(crypto_stream_factory), quic_stat_names_(quic_stat_names),
scope_(scope) {}

EnvoyQuicClientSession::~EnvoyQuicClientSession() {
ASSERT(!connection()->connected());
Expand All @@ -35,6 +37,7 @@ void EnvoyQuicClientSession::connect() {
void EnvoyQuicClientSession::OnConnectionClosed(const quic::QuicConnectionCloseFrame& frame,
quic::ConnectionCloseSource source) {
quic::QuicSpdyClientSession::OnConnectionClosed(frame, source);
quic_stat_names_.chargeQuicConnectionCloseStats(scope_, frame.quic_error_code, source, true);
onConnectionCloseEvent(frame, source, version());
}

Expand Down
6 changes: 5 additions & 1 deletion source/common/quic/envoy_quic_client_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "source/common/quic/envoy_quic_client_connection.h"
#include "source/common/quic/quic_filter_manager_connection_impl.h"
#include "source/common/quic/envoy_quic_crypto_stream_factory.h"
#include "source/common/quic/quic_stat_names.h"

namespace Envoy {
namespace Quic {
Expand All @@ -38,7 +39,8 @@ class EnvoyQuicClientSession : public QuicFilterManagerConnectionImpl,
std::shared_ptr<quic::QuicCryptoClientConfig> crypto_config,
quic::QuicClientPushPromiseIndex* push_promise_index,
Event::Dispatcher& dispatcher, uint32_t send_buffer_limit,
EnvoyQuicCryptoClientStreamFactoryInterface& crypto_stream_factory);
EnvoyQuicCryptoClientStreamFactoryInterface& crypto_stream_factory,
QuicStatNames& quic_stat_names, Stats::Scope& scope);

~EnvoyQuicClientSession() override;

Expand Down Expand Up @@ -102,6 +104,8 @@ class EnvoyQuicClientSession : public QuicFilterManagerConnectionImpl,
const absl::string_view host_name_;
std::shared_ptr<quic::QuicCryptoClientConfig> crypto_config_;
EnvoyQuicCryptoClientStreamFactoryInterface& crypto_stream_factory_;
QuicStatNames& quic_stat_names_;
Stats::Scope& scope_;
};

} // namespace Quic
Expand Down
1 change: 1 addition & 0 deletions source/common/upstream/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ envoy_cc_library(
"//source/common/tcp:conn_pool_lib",
"//source/common/upstream:priority_conn_pool_map_impl_lib",
"//source/common/upstream:upstream_lib",
"//source/common/quic:quic_stat_names_lib",
"@envoy_api//envoy/admin/v3:pkg_cc_proto",
"@envoy_api//envoy/config/bootstrap/v3:pkg_cc_proto",
"@envoy_api//envoy/config/cluster/v3:pkg_cc_proto",
Expand Down
6 changes: 4 additions & 2 deletions source/common/upstream/cluster_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,8 @@ Http::ConnectionPool::InstancePtr ProdClusterManagerFactory::allocateConnPool(
Envoy::Http::ConnectivityGrid::ConnectivityOptions coptions{protocols};
return std::make_unique<Http::ConnectivityGrid>(
dispatcher, api_.randomGenerator(), host, priority, options, transport_socket_options,
state, source, alternate_protocols_cache, std::chrono::milliseconds(300), coptions);
state, source, alternate_protocols_cache, std::chrono::milliseconds(300), coptions,
quic_stat_names_, stats_);
#else
// Should be blocked by configuration checking at an earlier point.
NOT_REACHED_GCOVR_EXCL_LINE;
Expand All @@ -1571,7 +1572,8 @@ Http::ConnectionPool::InstancePtr ProdClusterManagerFactory::allocateConnPool(
runtime_.snapshot().featureEnabled("upstream.use_http3", 100)) {
#ifdef ENVOY_ENABLE_QUIC
return Http::Http3::allocateConnPool(dispatcher, api_.randomGenerator(), host, priority,
options, transport_socket_options, state, source);
options, transport_socket_options, state, source,
quic_stat_names_, stats_);
#else
UNREFERENCED_PARAMETER(source);
// Should be blocked by configuration checking at an earlier point.
Expand Down
24 changes: 12 additions & 12 deletions source/common/upstream/cluster_manager_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "source/common/http/alternate_protocols_cache_impl.h"
#include "source/common/http/alternate_protocols_cache_manager_impl.h"
#include "source/common/http/async_client_impl.h"
#include "source/common/quic/quic_stat_names.h"
#include "source/common/upstream/load_stats_reporter.h"
#include "source/common/upstream/priority_conn_pool_map.h"
#include "source/common/upstream/upstream_impl.h"
Expand All @@ -44,23 +45,21 @@ namespace Upstream {
*/
class ProdClusterManagerFactory : public ClusterManagerFactory {
public:
ProdClusterManagerFactory(Server::Admin& admin, Runtime::Loader& runtime, Stats::Store& stats,
ThreadLocal::Instance& tls, Network::DnsResolverSharedPtr dns_resolver,
Ssl::ContextManager& ssl_context_manager,
Event::Dispatcher& main_thread_dispatcher,
const LocalInfo::LocalInfo& local_info,
Secret::SecretManager& secret_manager,
ProtobufMessage::ValidationContext& validation_context, Api::Api& api,
Http::Context& http_context, Grpc::Context& grpc_context,
Router::Context& router_context,
AccessLog::AccessLogManager& log_manager,
Singleton::Manager& singleton_manager, const Server::Options& options)
ProdClusterManagerFactory(
Server::Admin& admin, Runtime::Loader& runtime, Stats::Store& stats,
ThreadLocal::Instance& tls, Network::DnsResolverSharedPtr dns_resolver,
Ssl::ContextManager& ssl_context_manager, Event::Dispatcher& main_thread_dispatcher,
const LocalInfo::LocalInfo& local_info, Secret::SecretManager& secret_manager,
ProtobufMessage::ValidationContext& validation_context, Api::Api& api,
Http::Context& http_context, Grpc::Context& grpc_context, Router::Context& router_context,
AccessLog::AccessLogManager& log_manager, Singleton::Manager& singleton_manager,
const Server::Options& options, Quic::QuicStatNames& quic_stat_names)
Comment thread
alyssawilk marked this conversation as resolved.
: main_thread_dispatcher_(main_thread_dispatcher), validation_context_(validation_context),
api_(api), http_context_(http_context), grpc_context_(grpc_context),
router_context_(router_context), admin_(admin), runtime_(runtime), stats_(stats), tls_(tls),
dns_resolver_(dns_resolver), ssl_context_manager_(ssl_context_manager),
local_info_(local_info), secret_manager_(secret_manager), log_manager_(log_manager),
singleton_manager_(singleton_manager), options_(options),
singleton_manager_(singleton_manager), options_(options), quic_stat_names_(quic_stat_names),
alternate_protocols_cache_manager_factory_(singleton_manager,
main_thread_dispatcher.timeSource(), tls_),
alternate_protocols_cache_manager_(alternate_protocols_cache_manager_factory_.get()) {}
Expand Down Expand Up @@ -108,6 +107,7 @@ class ProdClusterManagerFactory : public ClusterManagerFactory {
AccessLog::AccessLogManager& log_manager_;
Singleton::Manager& singleton_manager_;
const Server::Options& options_;
Quic::QuicStatNames& quic_stat_names_;
Http::AlternateProtocolsCacheManagerFactoryImpl alternate_protocols_cache_manager_factory_;
Http::AlternateProtocolsCacheManagerSharedPtr alternate_protocols_cache_manager_;
};
Expand Down
3 changes: 2 additions & 1 deletion source/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ envoy_cc_library(
"//source/common/network:utility_lib",
"//source/common/protobuf:utility_lib",
"//source/common/stream_info:stream_info_lib",
"//source/extensions/filters/network/http_connection_manager:config",
"//source/common/quic:quic_stat_names_lib",
"//source/extensions/filters/network/http_connection_manager:config",
"//source/extensions/upstreams/http/generic:config",
"@envoy_api//envoy/admin/v3:pkg_cc_proto",
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
Expand Down Expand Up @@ -520,6 +520,7 @@ envoy_cc_library(
"//source/common/memory:heap_shrinker_lib",
"//source/common/memory:stats_lib",
"//source/common/protobuf:utility_lib",
"//source/common/quic:quic_stat_names_lib",
"//source/common/router:rds_lib",
"//source/common/runtime:runtime_lib",
"//source/common/secret:secret_manager_impl_lib",
Expand Down
1 change: 1 addition & 0 deletions source/server/config_validation/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ envoy_cc_library(
"//source/common/grpc:common_lib",
"//source/common/local_info:local_info_lib",
"//source/common/protobuf:utility_lib",
"//source/common/quic:quic_stat_names_lib",
"//source/common/router:context_lib",
"//source/common/router:rds_lib",
"//source/common/runtime:runtime_lib",
Expand Down
10 changes: 5 additions & 5 deletions source/server/config_validation/cluster_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class ValidationClusterManagerFactory : public ProdClusterManagerFactory {
ProtobufMessage::ValidationContext& validation_context, Api::Api& api,
Http::Context& http_context, Grpc::Context& grpc_context, Router::Context& router_context,
AccessLog::AccessLogManager& log_manager, Singleton::Manager& singleton_manager,
const Server::Options& options)
: ProdClusterManagerFactory(admin, runtime, stats, tls, dns_resolver, ssl_context_manager,
main_thread_dispatcher, local_info, secret_manager,
validation_context, api, http_context, grpc_context,
router_context, log_manager, singleton_manager, options),
const Server::Options& options, Quic::QuicStatNames& quic_stat_names)
: ProdClusterManagerFactory(
admin, runtime, stats, tls, dns_resolver, ssl_context_manager, main_thread_dispatcher,
local_info, secret_manager, validation_context, api, http_context, grpc_context,
router_context, log_manager, singleton_manager, options, quic_stat_names),
grpc_context_(grpc_context), router_context_(router_context) {}

ClusterManagerPtr
Expand Down
Loading