Add logs to see if network is ignored because flag IFF_RUNNING is not set.

Some chrome os endpoints get ICE NEVER CONNECTED because their wireless interfaces are ignored. One possible explanation is that result from getifaddrs is incorrect because some interfaces can work even if IFF_RUNNING is not set. Comparing to chromium code, not all messages with IFF_RUNNING on wireless interface are considered (https://chromium.googlesource.com/chromium/src/+/refs/heads/main/net/base/address_tracker_linux.cc#539). Thus the log print helps us to verify our explanation.

Chrome log: https://screenshot.googleplex.com/8SnDn66F56HAKfQ
Webrtc log: https://screenshot.googleplex.com/4jKxPsTHxExNBgz

Bug: webrtc:14334
Change-Id: Icd67dbe4e8ddcaed8b583f2fdb5f1fadfd7bac60
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/304460
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Diep Bui <diepbp@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40020}
This commit is contained in:
Diep Bui 2023-05-08 14:46:09 +00:00 committed by WebRTC LUCI CQ
parent 301e546a68
commit 7e2aa7d70a
2 changed files with 22 additions and 4 deletions

View file

@ -619,10 +619,6 @@ void BasicNetworkManager::ConvertIfAddrs(
if (!cursor->ifa_addr || !cursor->ifa_netmask) {
continue;
}
// Skip ones which are down.
if (!(cursor->ifa_flags & IFF_RUNNING)) {
continue;
}
// Skip unknown family.
if (cursor->ifa_addr->sa_family != AF_INET &&
cursor->ifa_addr->sa_family != AF_INET6) {
@ -633,6 +629,12 @@ void BasicNetworkManager::ConvertIfAddrs(
if (!ifaddrs_converter->ConvertIfAddrsToIPAddress(cursor, &ip, &mask)) {
continue;
}
// Skip ones which are down.
if (!(cursor->ifa_flags & IFF_RUNNING)) {
RTC_LOG(LS_INFO) << "Skip interface because of not IFF_RUNNING: "
<< ip.ToSensitiveString();
continue;
}
// Special case for IPv6 address.
if (cursor->ifa_addr->sa_family == AF_INET6) {

View file

@ -879,6 +879,7 @@ TEST_F(NetworkTest, TestConvertIfAddrsNotRunning) {
memset(&list, 0, sizeof(list));
list.ifa_name = const_cast<char*>("test_iface");
sockaddr ifa_addr;
ifa_addr.sa_family = AF_UNSPEC;
sockaddr ifa_netmask;
list.ifa_addr = &ifa_addr;
list.ifa_netmask = &ifa_netmask;
@ -891,6 +892,21 @@ TEST_F(NetworkTest, TestConvertIfAddrsNotRunning) {
EXPECT_TRUE(result.empty());
}
TEST_F(NetworkTest, TestConvertIfAddrsGetsNullAddr) {
ifaddrs list;
memset(&list, 0, sizeof(list));
list.ifa_name = const_cast<char*>("test_iface");
list.ifa_addr = nullptr;
list.ifa_netmask = nullptr;
std::vector<std::unique_ptr<Network>> result;
PhysicalSocketServer socket_server;
BasicNetworkManager manager(&socket_server);
manager.StartUpdating();
CallConvertIfAddrs(manager, &list, true, &result);
EXPECT_TRUE(result.empty());
}
// Tests that the network type can be determined from the network monitor when
// it would otherwise be unknown.
TEST_F(NetworkTest, TestGetAdapterTypeFromNetworkMonitor) {