|
1 | 1 | #include "source/common/quic/active_quic_listener.h" |
2 | 2 |
|
| 3 | +#include <memory> |
3 | 4 | #include <utility> |
4 | 5 | #include <vector> |
5 | 6 |
|
| 7 | +#include "envoy/common/optref.h" |
6 | 8 | #include "envoy/extensions/quic/connection_id_generator/v3/envoy_deterministic_connection_id_generator.pb.h" |
7 | 9 | #include "envoy/extensions/quic/crypto_stream/v3/crypto_stream.pb.h" |
8 | 10 | #include "envoy/extensions/quic/proof_source/v3/proof_source.pb.h" |
9 | 11 | #include "envoy/network/exception.h" |
| 12 | +#include "envoy/server/overload/overload_manager.h" |
10 | 13 |
|
11 | 14 | #include "source/common/common/logger.h" |
12 | 15 | #include "source/common/config/utility.h" |
| 16 | +#include "source/common/http/session_idle_list.h" |
13 | 17 | #include "source/common/http/utility.h" |
14 | 18 | #include "source/common/network/socket_option_impl.h" |
15 | 19 | #include "source/common/network/udp_listener_impl.h" |
@@ -39,7 +43,7 @@ ActiveQuicListener::ActiveQuicListener( |
39 | 43 | EnvoyQuicProofSourceFactoryInterface& proof_source_factory, |
40 | 44 | QuicConnectionIdGeneratorPtr&& cid_generator, QuicConnectionIdWorkerSelector worker_selector, |
41 | 45 | EnvoyQuicConnectionDebugVisitorFactoryInterfaceOptRef debug_visitor_factory, |
42 | | - bool reject_new_connections) |
| 46 | + bool reject_new_connections, bool enable_session_idle_list) |
43 | 47 | : Server::ActiveUdpListenerBase( |
44 | 48 | worker_index, concurrency, parent, *listen_socket, |
45 | 49 | std::make_unique<Network::UdpListenerImpl>( |
@@ -91,12 +95,12 @@ ActiveQuicListener::ActiveQuicListener( |
91 | 95 | listen_socket_.setSocketOption(IPPROTO_IP, IP_RECVTOS, &optval, optlen); |
92 | 96 | } |
93 | 97 | } |
94 | | - // TODO(panting): Pass in a non-null session_idle_list when configured. |
95 | 98 | quic_dispatcher_ = std::make_unique<EnvoyQuicDispatcher>( |
96 | 99 | crypto_config_.get(), quic_config, &version_manager_, std::move(connection_helper), |
97 | 100 | std::move(alarm_factory), quic::kQuicDefaultConnectionIdLength, parent, *config_, stats_, |
98 | 101 | per_worker_stats_, dispatcher, listen_socket_, quic_stat_names, crypto_server_stream_factory_, |
99 | | - *connection_id_generator_, debug_visitor_factory, /*session_idle_list=*/nullptr); |
| 102 | + *connection_id_generator_, debug_visitor_factory, |
| 103 | + enable_session_idle_list ? std::make_unique<Http::SessionIdleList>(dispatcher) : nullptr); |
100 | 104 |
|
101 | 105 | absl::AnyInvocable<void() &&> on_can_write_cb = [&]() { quic_dispatcher_->OnCanWrite(); }; |
102 | 106 |
|
@@ -272,6 +276,10 @@ void ActiveQuicListener::closeConnectionsWithFilterChain(const Network::FilterCh |
272 | 276 | quic_dispatcher_->closeConnectionsWithFilterChain(filter_chain); |
273 | 277 | } |
274 | 278 |
|
| 279 | +void ActiveQuicListener::onCloseIdleHttpConnections(bool is_saturated) { |
| 280 | + quic_dispatcher_->closeIdleQuicConnections(is_saturated); |
| 281 | +} |
| 282 | + |
275 | 283 | ActiveQuicListenerFactory::ActiveQuicListenerFactory( |
276 | 284 | const envoy::config::listener::v3::QuicProtocolOptions& config, uint32_t concurrency, |
277 | 285 | QuicStatNames& quic_stat_names, ProtobufMessage::ValidationVisitor& validation_visitor, |
@@ -447,12 +455,21 @@ ActiveQuicListenerFactory::createActiveQuicListener( |
447 | 455 | EnvoyQuicCryptoServerStreamFactoryInterface& crypto_server_stream_factory, |
448 | 456 | EnvoyQuicProofSourceFactoryInterface& proof_source_factory, |
449 | 457 | QuicConnectionIdGeneratorPtr&& cid_generator) { |
| 458 | + bool enable_session_idle_list = false; |
| 459 | + for (const auto& action : |
| 460 | + context_.serverFactoryContext().bootstrap().overload_manager().actions()) { |
| 461 | + if (action.name() == Server::OverloadActionNames::get().CloseIdleHttpConnections) { |
| 462 | + enable_session_idle_list = true; |
| 463 | + break; |
| 464 | + } |
| 465 | + } |
450 | 466 | return std::make_unique<ActiveQuicListener>( |
451 | 467 | runtime, worker_index, concurrency, dispatcher, parent, std::move(listen_socket), |
452 | 468 | listener_config, quic_config, kernel_worker_routing, enabled, quic_stat_names, |
453 | 469 | packets_to_read_to_connection_count_ratio, crypto_server_stream_factory, proof_source_factory, |
454 | 470 | std::move(cid_generator), worker_selector_, |
455 | | - makeOptRefFromPtr(connection_debug_visitor_factory_.get()), reject_new_connections_); |
| 471 | + makeOptRefFromPtr(connection_debug_visitor_factory_.get()), reject_new_connections_, |
| 472 | + enable_session_idle_list); |
456 | 473 | } |
457 | 474 |
|
458 | 475 | } // namespace Quic |
|
0 commit comments