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: using real runtime, not runtime singleton #19983

Merged
merged 1 commit into from
Feb 16, 2022
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
6 changes: 4 additions & 2 deletions envoy/network/connection_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class ActiveUdpListenerFactory {
/**
* Creates an ActiveUdpListener object and a corresponding UdpListener
* according to given config.
* @param runtime the runtime for this server.
* @param worker_index The index of the worker this listener is being created on.
* @param parent is the owner of the created ActiveListener objects.
* @param dispatcher is used to create actual UDP listener.
Expand All @@ -224,8 +225,9 @@ class ActiveUdpListenerFactory {
* @return the ActiveUdpListener created.
*/
virtual ConnectionHandler::ActiveUdpListenerPtr
createActiveUdpListener(uint32_t worker_index, UdpConnectionHandler& parent,
Event::Dispatcher& dispatcher, Network::ListenerConfig& config) PURE;
createActiveUdpListener(Runtime::Loader& runtime, uint32_t worker_index,
UdpConnectionHandler& parent, Event::Dispatcher& dispatcher,
Network::ListenerConfig& config) PURE;

/**
* @return true if the UDP passing through listener doesn't form stateful connections.
Expand Down
36 changes: 19 additions & 17 deletions source/common/quic/active_quic_listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,26 @@ namespace Quic {
bool ActiveQuicListenerFactory::disable_kernel_bpf_packet_routing_for_test_ = false;

ActiveQuicListener::ActiveQuicListener(
uint32_t worker_index, uint32_t concurrency, Event::Dispatcher& dispatcher,
Network::UdpConnectionHandler& parent, Network::ListenerConfig& listener_config,
const quic::QuicConfig& quic_config, bool kernel_worker_routing,
const envoy::config::core::v3::RuntimeFeatureFlag& enabled, QuicStatNames& quic_stat_names,
uint32_t packets_received_to_connection_count_ratio,
Runtime::Loader& runtime, uint32_t worker_index, uint32_t concurrency,
Event::Dispatcher& dispatcher, Network::UdpConnectionHandler& parent,
Network::ListenerConfig& listener_config, const quic::QuicConfig& quic_config,
bool kernel_worker_routing, const envoy::config::core::v3::RuntimeFeatureFlag& enabled,
QuicStatNames& quic_stat_names, uint32_t packets_received_to_connection_count_ratio,
EnvoyQuicCryptoServerStreamFactoryInterface& crypto_server_stream_factory,
EnvoyQuicProofSourceFactoryInterface& proof_source_factory)
: ActiveQuicListener(worker_index, concurrency, dispatcher, parent,
: ActiveQuicListener(runtime, worker_index, concurrency, dispatcher, parent,
listener_config.listenSocketFactory().getListenSocket(worker_index),
listener_config, quic_config, kernel_worker_routing, enabled,
quic_stat_names, packets_received_to_connection_count_ratio,
crypto_server_stream_factory, proof_source_factory) {}

ActiveQuicListener::ActiveQuicListener(
uint32_t worker_index, uint32_t concurrency, Event::Dispatcher& dispatcher,
Network::UdpConnectionHandler& parent, Network::SocketSharedPtr listen_socket,
Network::ListenerConfig& listener_config, const quic::QuicConfig& quic_config,
bool kernel_worker_routing, const envoy::config::core::v3::RuntimeFeatureFlag& enabled,
QuicStatNames& quic_stat_names, uint32_t packets_to_read_to_connection_count_ratio,
Runtime::Loader& runtime, uint32_t worker_index, uint32_t concurrency,
Event::Dispatcher& dispatcher, Network::UdpConnectionHandler& parent,
Network::SocketSharedPtr listen_socket, Network::ListenerConfig& listener_config,
const quic::QuicConfig& quic_config, bool kernel_worker_routing,
const envoy::config::core::v3::RuntimeFeatureFlag& enabled, QuicStatNames& quic_stat_names,
uint32_t packets_to_read_to_connection_count_ratio,
EnvoyQuicCryptoServerStreamFactoryInterface& crypto_server_stream_factory,
EnvoyQuicProofSourceFactoryInterface& proof_source_factory)
: Server::ActiveUdpListenerBase(
Expand All @@ -59,7 +60,7 @@ ActiveQuicListener::ActiveQuicListener(
ASSERT(!GetQuicFlag(FLAGS_quic_header_size_limit_includes_overhead));

if (Runtime::LoaderSingleton::getExisting()) {
enabled_.emplace(Runtime::FeatureFlag(enabled, Runtime::LoaderSingleton::get()));
enabled_.emplace(Runtime::FeatureFlag(enabled, runtime));
}

quic::QuicRandom* const random = quic::QuicRandom::GetInstance();
Expand Down Expand Up @@ -339,13 +340,14 @@ ActiveQuicListenerFactory::ActiveQuicListenerFactory(
}

Network::ConnectionHandler::ActiveUdpListenerPtr ActiveQuicListenerFactory::createActiveUdpListener(
uint32_t worker_index, Network::UdpConnectionHandler& parent, Event::Dispatcher& disptacher,
Network::ListenerConfig& config) {
Runtime::Loader& runtime, uint32_t worker_index, Network::UdpConnectionHandler& parent,
Event::Dispatcher& disptacher, Network::ListenerConfig& config) {
ASSERT(crypto_server_stream_factory_.has_value());
return std::make_unique<ActiveQuicListener>(
worker_index, concurrency_, disptacher, parent, config, quic_config_, kernel_worker_routing_,
enabled_, quic_stat_names_, packets_to_read_to_connection_count_ratio_,
crypto_server_stream_factory_.value(), proof_source_factory_.value());
runtime, worker_index, concurrency_, disptacher, parent, config, quic_config_,
kernel_worker_routing_, enabled_, quic_stat_names_,
packets_to_read_to_connection_count_ratio_, crypto_server_stream_factory_.value(),
proof_source_factory_.value());
}

} // namespace Quic
Expand Down
14 changes: 8 additions & 6 deletions source/common/quic/active_quic_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class ActiveQuicListener : public Envoy::Server::ActiveUdpListenerBase,
// TODO(bencebeky): Tune this value.
static const size_t kNumSessionsToCreatePerLoop = 16;

ActiveQuicListener(uint32_t worker_index, uint32_t concurrency, Event::Dispatcher& dispatcher,
Network::UdpConnectionHandler& parent,
ActiveQuicListener(Runtime::Loader& runtime, uint32_t worker_index, uint32_t concurrency,
Event::Dispatcher& dispatcher, Network::UdpConnectionHandler& parent,
Network::ListenerConfig& listener_config, const quic::QuicConfig& quic_config,
bool kernel_worker_routing,
const envoy::config::core::v3::RuntimeFeatureFlag& enabled,
Expand All @@ -38,8 +38,9 @@ class ActiveQuicListener : public Envoy::Server::ActiveUdpListenerBase,
EnvoyQuicCryptoServerStreamFactoryInterface& crypto_server_stream_factory,
EnvoyQuicProofSourceFactoryInterface& proof_source_factory);

ActiveQuicListener(uint32_t worker_index, uint32_t concurrency, Event::Dispatcher& dispatcher,
Network::UdpConnectionHandler& parent, Network::SocketSharedPtr listen_socket,
ActiveQuicListener(Runtime::Loader& runtime, uint32_t worker_index, uint32_t concurrency,
Event::Dispatcher& dispatcher, Network::UdpConnectionHandler& parent,
Network::SocketSharedPtr listen_socket,
Network::ListenerConfig& listener_config, const quic::QuicConfig& quic_config,
bool kernel_worker_routing,
const envoy::config::core::v3::RuntimeFeatureFlag& enabled,
Expand Down Expand Up @@ -106,8 +107,9 @@ class ActiveQuicListenerFactory : public Network::ActiveUdpListenerFactory,

// Network::ActiveUdpListenerFactory.
Network::ConnectionHandler::ActiveUdpListenerPtr
createActiveUdpListener(uint32_t worker_index, Network::UdpConnectionHandler& parent,
Event::Dispatcher& disptacher, Network::ListenerConfig& config) override;
createActiveUdpListener(Runtime::Loader& runtime, uint32_t worker_index,
Network::UdpConnectionHandler& parent, Event::Dispatcher& disptacher,
Network::ListenerConfig& config) override;
bool isTransportConnectionless() const override { return false; }
const Network::Socket::OptionsSharedPtr& socketOptions() const override { return options_; }

Expand Down
2 changes: 1 addition & 1 deletion source/server/active_raw_udp_listener_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ActiveRawUdpListenerFactory::ActiveRawUdpListenerFactory(uint32_t concurrency)
: concurrency_(concurrency) {}

Network::ConnectionHandler::ActiveUdpListenerPtr
ActiveRawUdpListenerFactory::createActiveUdpListener(uint32_t worker_index,
ActiveRawUdpListenerFactory::createActiveUdpListener(Runtime::Loader&, uint32_t worker_index,
Network::UdpConnectionHandler& parent,
Event::Dispatcher& dispatcher,
Network::ListenerConfig& config) {
Expand Down
5 changes: 3 additions & 2 deletions source/server/active_raw_udp_listener_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ class ActiveRawUdpListenerFactory : public Network::ActiveUdpListenerFactory {
ActiveRawUdpListenerFactory(uint32_t concurrency);

Network::ConnectionHandler::ActiveUdpListenerPtr
createActiveUdpListener(uint32_t worker_index, Network::UdpConnectionHandler& parent,
Event::Dispatcher& disptacher, Network::ListenerConfig& config) override;
createActiveUdpListener(Runtime::Loader&, uint32_t worker_index,
Network::UdpConnectionHandler& parent, Event::Dispatcher& disptacher,
Network::ListenerConfig& config) override;
bool isTransportConnectionless() const override { return true; }
const Network::Socket::OptionsSharedPtr& socketOptions() const override { return options_; }

Expand Down
4 changes: 2 additions & 2 deletions source/server/connection_handler_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ void ConnectionHandlerImpl::addListener(absl::optional<uint64_t> overridden_list
ASSERT(config.udpListenerConfig().has_value(), "UDP listener factory is not initialized.");
ASSERT(worker_index_.has_value());
ConnectionHandler::ActiveUdpListenerPtr udp_listener =
config.udpListenerConfig()->listenerFactory().createActiveUdpListener(*worker_index_, *this,
dispatcher_, config);
config.udpListenerConfig()->listenerFactory().createActiveUdpListener(
runtime, *worker_index_, *this, dispatcher_, config);
details->typed_listener_ = *udp_listener;
details->listener_ = std::move(udp_listener);
}
Expand Down
3 changes: 2 additions & 1 deletion test/common/quic/active_quic_listener_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ class ActiveQuicListenerTest : public testing::TestWithParam<Network::Address::I
.WillRepeatedly(ReturnRef(filter_chain_manager_));
quic_listener_ =
staticUniquePointerCast<ActiveQuicListener>(listener_factory_->createActiveUdpListener(
0, connection_handler_, *dispatcher_, listener_config_));
Runtime::LoaderSingleton::get(), 0, connection_handler_, *dispatcher_,
listener_config_));
quic_dispatcher_ = ActiveQuicListenerPeer::quicDispatcher(*quic_listener_);
quic::QuicCryptoServerConfig& crypto_config =
ActiveQuicListenerPeer::cryptoConfig(*quic_listener_);
Expand Down