From 6b6beaf3c9973883433228b88564e1b77a2b21d2 Mon Sep 17 00:00:00 2001 From: Mike Schore Date: Thu, 21 Oct 2021 15:25:44 -0700 Subject: [PATCH] network: instrument first active interfaces when switching socket modes (#1889) Description: When switching from the default socket mode to alternate bound interface mode, this change adds extra information to the LOG_EVENT, capturing the first active interface for IPv4 and IPv6 meeting the selection criteria for the alternate network. Risk Level: Low Testing: CI Signed-off-by: Mike Schore Signed-off-by: JP Simard --- mobile/library/common/engine.cc | 4 ++-- mobile/library/common/network/configurator.cc | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mobile/library/common/engine.cc b/mobile/library/common/engine.cc index cd862f1fc68d..0fd27090f1b4 100644 --- a/mobile/library/common/engine.cc +++ b/mobile/library/common/engine.cc @@ -314,8 +314,8 @@ void Engine::logInterfaces() { [](std::string acc, std::string next) { return acc.empty() ? next : std::move(acc) + "," + next; }); - ENVOY_LOG_EVENT(debug, "network_configuration_get_v4_interfaces", v4_names); - ENVOY_LOG_EVENT(debug, "network_configuration_get_v6_interfaces", v6_names); + ENVOY_LOG_EVENT(debug, "netconf_get_v4_interfaces", v4_names); + ENVOY_LOG_EVENT(debug, "netconf_get_v6_interfaces", v6_names); } } // namespace Envoy diff --git a/mobile/library/common/network/configurator.cc b/mobile/library/common/network/configurator.cc index c6087d3c4136..50fb8f57f989 100644 --- a/mobile/library/common/network/configurator.cc +++ b/mobile/library/common/network/configurator.cc @@ -149,10 +149,14 @@ void Configurator::reportNetworkUsage(envoy_netconf_t configuration_key, bool ne ? AlternateBoundInterfaceMode : DefaultPreferredNetworkMode; network_state_.remaining_faults_ = InitialFaultThreshold; - ENVOY_LOG_EVENT(debug, "netconf_mode_switch", - network_state_.socket_mode_ == DefaultPreferredNetworkMode - ? "DefaultPreferredNetworkMode" - : "AlternateBoundInterfaceMode"); + if (network_state_.socket_mode_ == DefaultPreferredNetworkMode) { + ENVOY_LOG_EVENT(debug, "netconf_mode_switch", "DefaultPreferredNetworkMode"); + } else if (network_state_.socket_mode_ == AlternateBoundInterfaceMode) { + auto& v4_interface = getActiveAlternateInterface(network_state_.network_, AF_INET); + auto& v6_interface = getActiveAlternateInterface(network_state_.network_, AF_INET6); + ENVOY_LOG_EVENT(debug, "netconf_mode_switch", "AlternateBoundInterfaceMode [{}|{}]", + v4_interface, v6_interface); + } } } }