about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/ifaddrs.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-06-03 23:07:39 +0000
committerUlrich Drepper <drepper@redhat.com>2003-06-03 23:07:39 +0000
commit332afd9ecdb835e2d0a9606f311b3d086a00d4e3 (patch)
tree5fd2c8d950ee686059e83e970a552db0f52af353 /sysdeps/unix/sysv/linux/ifaddrs.c
parent7aebf8554c93eb245a410a609db3d91940543e63 (diff)
downloadglibc-332afd9ecdb835e2d0a9606f311b3d086a00d4e3.tar.gz
glibc-332afd9ecdb835e2d0a9606f311b3d086a00d4e3.tar.xz
glibc-332afd9ecdb835e2d0a9606f311b3d086a00d4e3.zip
Update.
	* sysdeps/unix/sysv/linux/ifaddrs.c (netlink_open): Call getsockname
	to get the actual PID value used in the records passed up.
	(getifaddrs): Don't initialize nh.pid here.

2003-06-02  Ulrich Drepper  <drepper@redhat.com>
Diffstat (limited to 'sysdeps/unix/sysv/linux/ifaddrs.c')
-rw-r--r--sysdeps/unix/sysv/linux/ifaddrs.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c
index 6765387bc7..bc1ca8565f 100644
--- a/sysdeps/unix/sysv/linux/ifaddrs.c
+++ b/sysdeps/unix/sysv/linux/ifaddrs.c
@@ -233,9 +233,17 @@ netlink_open (struct netlink_handle *h)
   nladdr.nl_family = AF_NETLINK;
   if (__bind (h->fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) < 0)
     {
+    close_and_out:
       netlink_close (h);
       return -1;
     }
+  /* Determine the ID the kernel assigned for this netlink connection.
+     It is not necessarily the PID if there is more than one socket
+     open.  */
+  socklen_t addr_len = sizeof (nladdr);
+  if (__getsockname (h->fd, (struct sockaddr *) &nladdr, &addr_len) < 0)
+    goto close_and_out;
+  h->pid = nladdr.nl_pid;
   return 0;
 }
 
@@ -303,8 +311,6 @@ getifaddrs (struct ifaddrs **ifap)
     return fallback_getifaddrs (ifap);
 #endif
 
-  nh.pid = getpid ();
-
   /* Tell the kernel that we wish to get a list of all
      active interfaces.  */
   if (netlink_sendreq (&nh, RTM_GETLINK) < 0)