]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd if_index: Explicitly use AF_INET for if index discovery
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 17 Oct 2021 23:39:02 +0000 (01:39 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 3 Feb 2022 19:04:31 +0000 (20:04 +0100)
5bf07e1b3a74 ("Linux: Simplify __opensock and fix race condition [BZ #28353]")
made __opensock try NETLINK then UNIX then INET. On the Hurd, only INET
knows about network interfaces, so better actually specify that in
if_index.

(cherry picked from commit 1d3decee997ba2fc24af81803299b2f4f3c47063)

sysdeps/mach/hurd/if_index.c

index 56e63a4a92b50adbdb2ef3154e36ad2f6b115578..5e566da8207ce021efad9c9de93dba7f45916b9a 100644 (file)
@@ -32,7 +32,7 @@ unsigned int
 __if_nametoindex (const char *ifname)
 {
   struct ifreq ifr;
-  int fd = __opensock ();
+  int fd = __socket (AF_INET, SOCK_DGRAM, 0);
 
   if (fd < 0)
     return 0;
@@ -84,7 +84,7 @@ __if_nameindex (void)
   error_t err = 0;
   char data[2048];
   file_t server;
-  int fd = __opensock ();
+  int fd = __socket (AF_INET, SOCK_DGRAM, 0);
   struct ifconf ifc;
   unsigned int nifs, i;
   struct if_nameindex *idx = NULL;
@@ -169,7 +169,7 @@ char *
 __if_indextoname (unsigned int ifindex, char *ifname)
 {
   struct ifreq ifr;
-  int fd = __opensock ();
+  int fd = __socket (AF_INET, SOCK_DGRAM, 0);
 
   if (fd < 0)
     return NULL;