Index: net/base/network_interfaces_linux.cc |
diff --git a/net/base/network_interfaces_linux.cc b/net/base/network_interfaces_linux.cc |
index 3c460be2871952a2485326894123ad874d0d4c73..1e506df642566aad88c1f8962e741c75ce560d83 100644 |
--- a/net/base/network_interfaces_linux.cc |
+++ b/net/base/network_interfaces_linux.cc |
@@ -76,7 +76,7 @@ namespace internal { |
// or ethtool extensions. |
NetworkChangeNotifier::ConnectionType GetInterfaceConnectionType( |
const std::string& ifname) { |
- base::ScopedFD s(socket(AF_INET, SOCK_STREAM, 0)); |
+ base::ScopedFD s = GetSocketForIoctl(); |
if (!s.is_valid()) |
return NetworkChangeNotifier::CONNECTION_UNKNOWN; |
@@ -101,7 +101,7 @@ NetworkChangeNotifier::ConnectionType GetInterfaceConnectionType( |
} |
std::string GetInterfaceSSID(const std::string& ifname) { |
- base::ScopedFD ioctl_socket(socket(AF_INET, SOCK_DGRAM, 0)); |
+ base::ScopedFD ioctl_socket = GetSocketForIoctl(); |
if (!ioctl_socket.is_valid()) |
return ""; |
struct iwreq wreq = {}; |
@@ -201,6 +201,13 @@ std::string GetWifiSSIDFromInterfaceListInternal( |
return connected_ssid; |
} |
+base::ScopedFD GetSocketForIoctl() { |
+ base::ScopedFD ioctl_socket(socket(AF_INET6, SOCK_DGRAM, 0)); |
+ if (ioctl_socket.is_valid()) |
+ return ioctl_socket; |
+ return base::ScopedFD(socket(AF_INET, SOCK_DGRAM, 0)); |
+} |
+ |
} // namespace internal |
bool GetNetworkList(NetworkInterfaceList* networks, int policy) { |