Commit d251d57b authored by Wez's avatar Wez Committed by Commit Bot

[fuchsia] Fix NetInterfaceToNetworkInterfaces() for lack of IPv4 address.

It is possible for a network interface to have only IPv6 addresses, but
NetInterfaceToNetworkInterfaces() was assuming that the non-optional
|addr| field in the fuchsia.netstack.NetInterface would always contain a
valid address, resulting in a net::NetworkInterface with INADDR_ANY
being returned in the interfaces list.

Fix the call to omit the IPv4 NetworkInterface if the |address| IsZero().

Bug: 1052410
Change-Id: I66dc50fcac4911416399210558484130fbfe571c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2060072
Auto-Submit: Wez <wez@chromium.org>
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742067}
parent f25f45ff
......@@ -88,7 +88,10 @@ std::vector<NetworkInterface> NetInterfaceToNetworkInterfaces(
return output;
}
output.push_back(NetworkInterfaceFromAddress(iface_in, 0));
// It is possible for the interface not to have an IPv4 address.
NetworkInterface ipv4_interface = NetworkInterfaceFromAddress(iface_in, 0);
if (!ipv4_interface.address.IsZero())
output.push_back(std::move(ipv4_interface));
// Append interface entries for all additional IPv6 addresses.
for (size_t i = 0; i < iface_in.ipv6addrs.size(); ++i) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment