Add PreferGlobalIPv6Address param to IPv6NetworkResolutionFixes field trial string.
Bug: webrtc:14334 Change-Id: Iedbc18d2ebd77b4fedd4e7936a5aa4da35279328 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/273101 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Per Kjellander <perkj@webrtc.org> Reviewed-by: Sameer Vijaykar <samvi@google.com> Reviewed-by: Diep Bui <diepbp@webrtc.org> Commit-Queue: Diep Bui <diepbp@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37991}
This commit is contained in:
@ -1759,7 +1759,8 @@ TEST_F(PortTest, TestUdpSingleAddressV6CrossTypePorts) {
|
||||
|
||||
TEST_F(PortTest, TestUdpMultipleAddressesV6CrossTypePorts) {
|
||||
webrtc::test::ScopedKeyValueConfig field_trials(
|
||||
"WebRTC-IPv6NetworkResolutionFixes/Enabled/");
|
||||
"WebRTC-IPv6NetworkResolutionFixes/"
|
||||
"Enabled,PreferGlobalIPv6Address:true/");
|
||||
FakePacketSocketFactory factory;
|
||||
std::unique_ptr<Port> ports[5];
|
||||
SocketAddress addresses[5] = {
|
||||
|
||||
@ -1118,6 +1118,7 @@ rtc_library("rtc_base") {
|
||||
"../api/task_queue:pending_task_safety_flag",
|
||||
"../api/transport:field_trial_based_config",
|
||||
"../api/units:time_delta",
|
||||
"../rtc_base/experiments:field_trial_parser",
|
||||
"../system_wrappers:field_trial",
|
||||
"memory:always_valid_pointer",
|
||||
"network:sent_packet",
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include "rtc_base/network.h"
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "rtc_base/experiments/field_trial_parser.h"
|
||||
|
||||
#if defined(WEBRTC_POSIX)
|
||||
#include <net/if.h>
|
||||
@ -180,6 +181,21 @@ bool ShouldAdapterChangeTriggerNetworkChange(rtc::AdapterType old_type,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PreferGlobalIPv6Address(const webrtc::FieldTrialsView* field_trials) {
|
||||
// Bug fix to prefer global IPv6 address over link local.
|
||||
// Field trial key reserved in bugs.webrtc.org/14334
|
||||
if (field_trials &&
|
||||
field_trials->IsEnabled("WebRTC-IPv6NetworkResolutionFixes")) {
|
||||
webrtc::FieldTrialParameter<bool> prefer_global_ipv6_address_enabled(
|
||||
"PreferGlobalIPv6Address", false);
|
||||
webrtc::ParseFieldTrial(
|
||||
{&prefer_global_ipv6_address_enabled},
|
||||
field_trials->Lookup("WebRTC-IPv6NetworkResolutionFixes"));
|
||||
return prefer_global_ipv6_address_enabled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// These addresses are used as the targets to find out the default local address
|
||||
@ -1111,12 +1127,9 @@ IPAddress Network::GetBestIP() const {
|
||||
}
|
||||
|
||||
InterfaceAddress selected_ip, link_local_ip, ula_ip;
|
||||
// Bug fix to prefer global IPv6 address over link local.
|
||||
// Field trial key reserved in bugs.webrtc.org/14334
|
||||
const bool prefer_global_ipv6_to_link_local =
|
||||
field_trials_
|
||||
? field_trials_->IsEnabled("WebRTC-IPv6NetworkResolutionFixes")
|
||||
: false;
|
||||
PreferGlobalIPv6Address(field_trials_);
|
||||
|
||||
for (const InterfaceAddress& ip : ips_) {
|
||||
// Ignore any address which has been deprecated already.
|
||||
if (ip.ipv6_flags() & IPV6_ADDRESS_FLAG_DEPRECATED)
|
||||
|
||||
@ -1160,7 +1160,8 @@ TEST_F(NetworkTest, TestIPv6Selection) {
|
||||
// Test that the filtering logic follows the defined ruleset in network.h.
|
||||
TEST_F(NetworkTest, TestGetBestIPWithPreferGlobalIPv6ToLinkLocalEnabled) {
|
||||
webrtc::test::ScopedKeyValueConfig field_trials(
|
||||
"WebRTC-IPv6NetworkResolutionFixes/Enabled/");
|
||||
"WebRTC-IPv6NetworkResolutionFixes/"
|
||||
"Enabled,PreferGlobalIPv6Address:true/");
|
||||
InterfaceAddress ip, link_local;
|
||||
std::string ipstr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user