Fix issue where sockets bound to temporary IPv6 addresses are discarded.
Also removing the implicit InterfaceAddress constructor that takes an IPAddress, so that issues like this won't happen in the future. And adding a convenience "Network::AddIP" method that takes an IPAddress, so that code doing that (previously relying on the implicit constructor) will continue to work. Bug: webrtc:8972 Change-Id: Id5cf0fca481cfee3f8ab83412fcb41886535bba2 Reviewed-on: https://webrtc-review.googlesource.com/59461 Reviewed-by: Peter Thatcher <pthatcher@webrtc.org> Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22504}
This commit is contained in:
committed by
Commit Bot
parent
3d976f6066
commit
01cb5f2cee
@ -22,8 +22,8 @@ bool IfAddrsConverter::ConvertIfAddrsToIPAddress(
|
||||
IPAddress* mask) {
|
||||
switch (interface->ifa_addr->sa_family) {
|
||||
case AF_INET: {
|
||||
*ip = IPAddress(
|
||||
reinterpret_cast<sockaddr_in*>(interface->ifa_addr)->sin_addr);
|
||||
*ip = InterfaceAddress(IPAddress(
|
||||
reinterpret_cast<sockaddr_in*>(interface->ifa_addr)->sin_addr));
|
||||
*mask = IPAddress(
|
||||
reinterpret_cast<sockaddr_in*>(interface->ifa_netmask)->sin_addr);
|
||||
return true;
|
||||
|
||||
@ -126,8 +126,8 @@ class InterfaceAddress : public IPAddress {
|
||||
public:
|
||||
InterfaceAddress() : ipv6_flags_(IPV6_ADDRESS_FLAG_NONE) {}
|
||||
|
||||
InterfaceAddress(IPAddress ip)
|
||||
: IPAddress(ip), ipv6_flags_(IPV6_ADDRESS_FLAG_NONE) {}
|
||||
explicit InterfaceAddress(IPAddress ip)
|
||||
: IPAddress(ip), ipv6_flags_(IPV6_ADDRESS_FLAG_NONE) {}
|
||||
|
||||
InterfaceAddress(IPAddress addr, int ipv6_flags)
|
||||
: IPAddress(addr), ipv6_flags_(ipv6_flags) {}
|
||||
|
||||
@ -633,7 +633,7 @@ bool BasicNetworkManager::CreateNetworks(bool include_ignored,
|
||||
scope_id = v6_addr->sin6_scope_id;
|
||||
ip = IPAddress(v6_addr->sin6_addr);
|
||||
|
||||
if (IsIgnoredIPv6(ip)) {
|
||||
if (IsIgnoredIPv6(InterfaceAddress(ip))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -346,6 +346,7 @@ class Network {
|
||||
|
||||
// Adds an active IP address to this network. Does not check for duplicates.
|
||||
void AddIP(const InterfaceAddress& ip) { ips_.push_back(ip); }
|
||||
void AddIP(const IPAddress& ip) { ips_.push_back(rtc::InterfaceAddress(ip)); }
|
||||
|
||||
// Sets the network's IP address list. Returns true if new IP addresses were
|
||||
// detected. Passing true to already_changed skips this check.
|
||||
|
||||
@ -552,19 +552,16 @@ TEST_F(NetworkTest, TestMultipleIPMergeNetworkList) {
|
||||
// But with two addresses now.
|
||||
EXPECT_EQ(2U, (*it)->GetIPs().size());
|
||||
EXPECT_NE((*it)->GetIPs().end(),
|
||||
std::find((*it)->GetIPs().begin(),
|
||||
(*it)->GetIPs().end(),
|
||||
check_ip));
|
||||
std::find((*it)->GetIPs().begin(), (*it)->GetIPs().end(),
|
||||
InterfaceAddress(check_ip)));
|
||||
EXPECT_NE((*it)->GetIPs().end(),
|
||||
std::find((*it)->GetIPs().begin(),
|
||||
(*it)->GetIPs().end(),
|
||||
ip));
|
||||
std::find((*it)->GetIPs().begin(), (*it)->GetIPs().end(),
|
||||
InterfaceAddress(ip)));
|
||||
} else {
|
||||
// Check the IP didn't get added anywhere it wasn't supposed to.
|
||||
EXPECT_EQ((*it)->GetIPs().end(),
|
||||
std::find((*it)->GetIPs().begin(),
|
||||
(*it)->GetIPs().end(),
|
||||
ip));
|
||||
std::find((*it)->GetIPs().begin(), (*it)->GetIPs().end(),
|
||||
InterfaceAddress(ip)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -606,9 +603,8 @@ TEST_F(NetworkTest, TestMultiplePublicNetworksOnOneInterfaceMerge) {
|
||||
} else {
|
||||
// Check the IP didn't get added anywhere it wasn't supposed to.
|
||||
EXPECT_EQ((*it)->GetIPs().end(),
|
||||
std::find((*it)->GetIPs().begin(),
|
||||
(*it)->GetIPs().end(),
|
||||
ip));
|
||||
std::find((*it)->GetIPs().begin(), (*it)->GetIPs().end(),
|
||||
InterfaceAddress(ip)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -962,8 +958,8 @@ TEST_F(NetworkTest, TestMergeNetworkList) {
|
||||
// IPAddresses.
|
||||
EXPECT_EQ(list2.size(), 1uL);
|
||||
EXPECT_EQ(list2[0]->GetIPs().size(), 2uL);
|
||||
EXPECT_EQ(list2[0]->GetIPs()[0], ip1);
|
||||
EXPECT_EQ(list2[0]->GetIPs()[1], ip2);
|
||||
EXPECT_EQ(list2[0]->GetIPs()[0], InterfaceAddress(ip1));
|
||||
EXPECT_EQ(list2[0]->GetIPs()[1], InterfaceAddress(ip2));
|
||||
}
|
||||
|
||||
// Test that MergeNetworkList successfully detects the change if
|
||||
|
||||
Reference in New Issue
Block a user