Add Ethernet and loopback entries to GetAdapterTypeFromName.

GetAdapterTypeFromName determines the adapter type of a network
interface based on the string matching of the interface name. It however
does not have an entry to map the well-known "eth" name to the common
Ethernet type. This introduces subtle bugs when GetAdapterTypeFromName
is used as the only method to determine a network type and Ethernet is
thus identified as an unknown network, which affects the network
filtering and network path selection that rely on the network type.

Bug: webrtc:9235
Change-Id: Ifc3269d191382f3b3a041de1c9755c09994b31b2
Reviewed-on: https://webrtc-review.googlesource.com/74263
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Qingsi Wang <qingsi@google.com>
Cr-Commit-Position: refs/heads/master@{#23195}
This commit is contained in:
Qingsi Wang
2018-05-08 11:55:07 -07:00
committed by Commit Bot
parent e1f222e5c5
commit e53ac0463d
3 changed files with 130 additions and 68 deletions

View File

@ -837,6 +837,18 @@ TEST_F(NetworkTest, TestGetAdapterTypeFromNameMatching) {
ClearNetworks(manager);
ReleaseIfAddrs(addr_list);
strcpy(if_name, "lo0");
addr_list = InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager);
EXPECT_EQ(ADAPTER_TYPE_LOOPBACK, GetAdapterType(manager));
ClearNetworks(manager);
ReleaseIfAddrs(addr_list);
strcpy(if_name, "eth0");
addr_list = InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager);
EXPECT_EQ(ADAPTER_TYPE_ETHERNET, GetAdapterType(manager));
ClearNetworks(manager);
ReleaseIfAddrs(addr_list);
#if defined(WEBRTC_IOS)
strcpy(if_name, "pdp_ip0");
addr_list = InstallIpv6Network(if_name, ipv6_address1, ipv6_mask, manager);