Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
959cd4c
everything build
danzh1989 Aug 7, 2024
4b969c9
Merge branch 'main' into networkchange
danzh1989 Aug 8, 2024
242dc5e
finish plumbing
danzh1989 Aug 8, 2024
28e805a
add tests
danzh1989 Aug 20, 2024
a582d79
comments
danzh1989 Aug 20, 2024
1e57860
add runtime guard
danzh1989 Aug 21, 2024
e3663b2
change log
danzh1989 Aug 21, 2024
ccd0dd2
fix build
danzh1989 Aug 21, 2024
7e8e3d3
fix build again
danzh1989 Aug 21, 2024
84eeb68
more fix
danzh1989 Aug 21, 2024
2337129
fix compile option build
danzh1989 Aug 22, 2024
9725172
Merge branch 'main' into networkchange
danzh1989 Aug 22, 2024
845c19d
test coverage
danzh1989 Aug 22, 2024
462e7bd
fix build
danzh1989 Aug 22, 2024
76e0894
fix compile option build
danzh1989 Aug 23, 2024
e47c408
Merge branch 'main' into networkchange
danzh1989 Aug 27, 2024
c239b59
Merge branch 'main' into networkchange
danzh1989 Sep 4, 2024
2bf31a3
more merge fix
danzh1989 Sep 4, 2024
27058bc
comment
danzh1989 Sep 4, 2024
fe5b171
Merge branch 'main' into networkchange
danzh1989 Sep 6, 2024
2d78be5
new callback interface
danzh1989 Sep 7, 2024
f883a1c
Merge branch 'main' into networkchange
danzh1989 Sep 7, 2024
2af5cfb
dedup dispatcher post
danzh1989 Sep 11, 2024
471b7bb
Merge branch 'main' into networkchange
danzh1989 Sep 11, 2024
5ad0e26
fix unit test
danzh1989 Sep 11, 2024
ddd3739
revert some changes
danzh1989 Sep 8, 2025
c2c3909
Merge branch 'main' into networkchange
danzh1989 Sep 9, 2025
225d362
revert release note
danzh1989 Sep 9, 2025
eae7c9e
Merge branch 'main' into networkchange
danzh1989 Sep 12, 2025
ee6a0b4
observer interface change
danzh1989 Sep 12, 2025
bd3fd65
more interface changes
danzh1989 Sep 12, 2025
6815335
Merge branch 'main' into networkchange
danzh1989 Oct 3, 2025
cdc290d
revert transient connect failure handling
danzh1989 Oct 3, 2025
f668a04
remove quic_network_connectivity_observer_impl_lib
danzh1989 Oct 3, 2025
73d0b0e
build target
danzh1989 Oct 3, 2025
47d708f
revert tests
danzh1989 Oct 9, 2025
8c576fa
revert upstream BUILD
danzh1989 Oct 9, 2025
6ab8b05
revert mobile changes
danzh1989 Oct 9, 2025
3dba5e6
a disconnect interface
danzh1989 Oct 9, 2025
809ee7e
revert runtime
danzh1989 Oct 9, 2025
7c31d1e
fix build
danzh1989 Oct 9, 2025
f22a3d9
test coverage
danzh1989 Oct 9, 2025
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
24 changes: 18 additions & 6 deletions source/common/quic/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,12 @@ envoy_cc_library(
srcs = envoy_select_enable_http3([
"envoy_quic_client_session.cc",
"envoy_quic_client_stream.cc",
"quic_network_connectivity_observer.cc",
"quic_network_connectivity_observer_impl.cc",
]),
hdrs = envoy_select_enable_http3([
"envoy_quic_client_session.h",
"envoy_quic_client_stream.h",
"envoy_quic_network_observer_registry_factory.h",
"quic_network_connectivity_observer.h",
"quic_network_connectivity_observer_impl.h",
]),
deps = envoy_select_enable_http3([
":envoy_quic_client_connection_lib",
Expand All @@ -325,6 +324,8 @@ envoy_cc_library(
":envoy_quic_stream_lib",
":envoy_quic_utils_lib",
":quic_filter_manager_connection_lib",
":quic_network_connectivity_observer_interface",
":envoy_quic_network_observer_registry_factory_lib",
":quic_stat_names_lib",
":quic_transport_socket_factory_lib",
"//envoy/http:http_server_properties_cache_interface",
Expand All @@ -340,15 +341,26 @@ envoy_cc_library(
)

envoy_cc_library(
name = "envoy_quic_network_observer_registry_factory_lib",
name = "quic_network_connectivity_observer_interface",
hdrs = [
"envoy_quic_network_observer_registry_factory.h",
"quic_network_connectivity_observer.h",
],
deps = envoy_select_enable_http3([
":envoy_quic_client_session_lib",
"//source/common/common:logger_lib",
]),
)

envoy_cc_library(
name = "envoy_quic_network_observer_registry_factory_lib",
hdrs = [
"envoy_quic_network_observer_registry_factory.h",
],
deps = [
":quic_network_connectivity_observer_interface",
"//envoy/event:dispatcher_interface",
],
)

envoy_cc_library(
name = "quic_io_handle_wrapper_lib",
hdrs = envoy_select_enable_http3(["quic_io_handle_wrapper.h"]),
Expand Down
3 changes: 2 additions & 1 deletion source/common/quic/envoy_quic_client_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "source/common/quic/envoy_quic_proof_verifier.h"
#include "source/common/quic/envoy_quic_utils.h"
#include "source/common/quic/quic_filter_manager_connection_impl.h"
#include "source/common/quic/quic_network_connectivity_observer_impl.h"

namespace Envoy {
namespace Quic {
Expand Down Expand Up @@ -311,7 +312,7 @@ std::vector<std::string> EnvoyQuicClientSession::GetAlpnsToOffer() const {

void EnvoyQuicClientSession::registerNetworkObserver(EnvoyQuicNetworkObserverRegistry& registry) {
if (network_connectivity_observer_ == nullptr) {
network_connectivity_observer_ = std::make_unique<QuicNetworkConnectivityObserver>(*this);
network_connectivity_observer_ = std::make_unique<QuicNetworkConnectivityObserverImpl>(*this);
}
registry.registerObserver(*network_connectivity_observer_);
registry_ = makeOptRef(registry);
Expand Down
11 changes: 0 additions & 11 deletions source/common/quic/envoy_quic_network_observer_registry_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

#include <memory>

#ifdef ENVOY_ENABLE_QUIC
#include "envoy/event/dispatcher.h"

#include "source/common/quic/quic_network_connectivity_observer.h"
#endif

namespace Envoy {
namespace Quic {

#ifdef ENVOY_ENABLE_QUIC
// A registry of network connectivity observers.
class EnvoyQuicNetworkObserverRegistry {
public:
Expand Down Expand Up @@ -44,14 +41,6 @@ class EnvoyQuicNetworkObserverRegistryFactory {
}
};

#else

// Dumb definitions of QUIC classes if QUIC is compiled out.
class EnvoyQuicNetworkObserverRegistry {};
class EnvoyQuicNetworkObserverRegistryFactory {};

#endif

using EnvoyQuicNetworkObserverRegistryPtr = std::unique_ptr<EnvoyQuicNetworkObserverRegistry>;
using EnvoyQuicNetworkObserverRegistryFactoryPtr =
std::unique_ptr<EnvoyQuicNetworkObserverRegistryFactory>;
Expand Down
12 changes: 0 additions & 12 deletions source/common/quic/quic_network_connectivity_observer.cc

This file was deleted.

28 changes: 12 additions & 16 deletions source/common/quic/quic_network_connectivity_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,25 @@

#include <memory>

#include "source/common/common/logger.h"

namespace Envoy {
namespace Quic {

class EnvoyQuicClientSession;
using NetworkHandle = int64_t;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be moved to inside the Envoy::Quic namespace so it is scoped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it into Envoy namespace.


// TODO(danzh) deprecate this class once QUICHE has its own more detailed network observer.
class QuicNetworkConnectivityObserver : protected Logger::Loggable<Logger::Id::connection> {
namespace Quic {

// An interface to get network change notifications from the underlying platform.
class QuicNetworkConnectivityObserver {
public:
// session must outlive this object.
explicit QuicNetworkConnectivityObserver(EnvoyQuicClientSession& session);
QuicNetworkConnectivityObserver(const QuicNetworkConnectivityObserver&) = delete;
QuicNetworkConnectivityObserver& operator=(const QuicNetworkConnectivityObserver&) = delete;
virtual ~QuicNetworkConnectivityObserver() = default;

// Called when the device switches to a different network.
void onNetworkChanged() {
// TODO(danzh) close the connection if it's idle, otherwise mark it as go away.
(void)session_;
}
virtual void onNetworkMadeDefault(NetworkHandle network) PURE;

// Called when a new network is connected.
virtual void onNetworkConnected(NetworkHandle network) PURE;

private:
EnvoyQuicClientSession& session_;
// Called when the given network gets disconnected.
virtual void onNetworkDisconnected(NetworkHandle network) PURE;
};

using QuicNetworkConnectivityObserverPtr = std::unique_ptr<QuicNetworkConnectivityObserver>;
Expand Down
26 changes: 26 additions & 0 deletions source/common/quic/quic_network_connectivity_observer_impl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "source/common/quic/quic_network_connectivity_observer_impl.h"

#include "source/common/quic/envoy_quic_client_session.h"

namespace Envoy {
namespace Quic {

QuicNetworkConnectivityObserverImpl::QuicNetworkConnectivityObserverImpl(
EnvoyQuicClientSession& session)
: session_(session) {}

void QuicNetworkConnectivityObserverImpl::onNetworkMadeDefault(NetworkHandle /*network*/) {
// TODO(danzh) propagate `network` to quic session.
(void)session_;
}

void QuicNetworkConnectivityObserverImpl::onNetworkConnected(NetworkHandle /*network*/) {
(void)session_;
}

void QuicNetworkConnectivityObserverImpl::onNetworkDisconnected(NetworkHandle /*network*/) {
(void)session_;
}

} // namespace Quic
} // namespace Envoy
32 changes: 32 additions & 0 deletions source/common/quic/quic_network_connectivity_observer_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include <memory>

#include "source/common/common/logger.h"
#include "source/common/quic/quic_network_connectivity_observer.h"

namespace Envoy {
namespace Quic {

class EnvoyQuicClientSession;

class QuicNetworkConnectivityObserverImpl : public QuicNetworkConnectivityObserver,
protected Logger::Loggable<Logger::Id::connection> {
public:
// session must outlive this object.
explicit QuicNetworkConnectivityObserverImpl(EnvoyQuicClientSession& session);
QuicNetworkConnectivityObserverImpl(const QuicNetworkConnectivityObserverImpl&) = delete;
QuicNetworkConnectivityObserverImpl&
operator=(const QuicNetworkConnectivityObserverImpl&) = delete;

// QuicNetworkConnectivityObserver
void onNetworkMadeDefault(NetworkHandle network) override;
void onNetworkConnected(NetworkHandle network) override;
void onNetworkDisconnected(NetworkHandle network) override;

private:
EnvoyQuicClientSession& session_;
};

} // namespace Quic
} // namespace Envoy
8 changes: 8 additions & 0 deletions test/common/http/http3/conn_pool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ TEST_F(Http3ConnPoolImplTest, MigrationEnabledNoDrain) {
EXPECT_FALSE(pool_->isIdle());
}

// These are no-op currently. Just test them to have test coverage.
TEST_F(Http3ConnPoolImplTest, GetNetworkChangeEvents) {
createNewStream();
observers_.onNetworkConnected(-1);
observers_.onNetworkMadeDefault(-1);
observers_.onNetworkDisconnected(-1);
}

} // namespace Http3
} // namespace Http
} // namespace Envoy
25 changes: 23 additions & 2 deletions test/common/quic/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,36 @@ REGISTER_FACTORY(TestEnvoyQuicConnectionDebugVisitorFactoryFactory,

class TestNetworkObserverRegistry : public Quic::EnvoyQuicNetworkObserverRegistry {
public:
void onNetworkChanged() {
void onNetworkMadeDefault(NetworkHandle network) {
std::list<Quic::QuicNetworkConnectivityObserver*> existing_observers;
for (Quic::QuicNetworkConnectivityObserver* observer : registeredQuicObservers()) {
existing_observers.push_back(observer);
}
for (auto* observer : existing_observers) {
observer->onNetworkChanged();
observer->onNetworkMadeDefault(network);
}
}

void onNetworkDisconnected(NetworkHandle network) {
std::list<Quic::QuicNetworkConnectivityObserver*> existing_observers;
for (Quic::QuicNetworkConnectivityObserver* observer : registeredQuicObservers()) {
existing_observers.push_back(observer);
}
for (auto* observer : existing_observers) {
observer->onNetworkDisconnected(network);
}
}

void onNetworkConnected(NetworkHandle network) {
std::list<Quic::QuicNetworkConnectivityObserver*> existing_observers;
for (Quic::QuicNetworkConnectivityObserver* observer : registeredQuicObservers()) {
existing_observers.push_back(observer);
}
for (auto* observer : existing_observers) {
observer->onNetworkConnected(network);
}
}

using Quic::EnvoyQuicNetworkObserverRegistry::registeredQuicObservers;
};

Expand Down
Loading