summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/ifaddrs.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/ifaddrs.c')
-rw-r--r--sysdeps/unix/sysv/linux/ifaddrs.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c
index ca38d1a243..ac0e1e5738 100644
--- a/sysdeps/unix/sysv/linux/ifaddrs.c
+++ b/sysdeps/unix/sysv/linux/ifaddrs.c
@@ -1,5 +1,5 @@
/* getifaddrs -- get names and addresses of all network interfaces
- Copyright (C) 2003-2016 Free Software Foundation, Inc.
+ Copyright (C) 2003-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -161,10 +161,13 @@ __netlink_request (struct netlink_handle *h, int type)
{
struct msghdr msg =
{
- (void *) &nladdr, sizeof (nladdr),
- &iov, 1,
- NULL, 0,
- 0
+ .msg_name = (void *) &nladdr,
+ .msg_namelen = sizeof (nladdr),
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
+ .msg_control = NULL,
+ .msg_controllen = 0,
+ .msg_flags = 0
};
read_len = TEMP_FAILURE_RETRY (__recvmsg (h->fd, &msg, 0));
@@ -252,7 +255,7 @@ __netlink_open (struct netlink_handle *h)
{
struct sockaddr_nl nladdr;
- h->fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+ h->fd = __socket (PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
if (h->fd < 0)
goto out;
@@ -283,7 +286,6 @@ __netlink_open (struct netlink_handle *h)
Since we get at first all RTM_NEWLINK entries, it can never happen
that a RTM_NEWADDR index is not known to this map. */
static int
-internal_function
map_newlink (int index, struct ifaddrs_storage *ifas, int *map, int max)
{
int i;
@@ -368,6 +370,14 @@ getifaddrs_internal (struct ifaddrs **ifap)
if ((pid_t) nlh->nlmsg_pid != nh.pid || nlh->nlmsg_seq != nlp->seq)
continue;
+ /* If the dump got interrupted, we can't rely on the results
+ so try again. */
+ if (nlh->nlmsg_flags & NLM_F_DUMP_INTR)
+ {
+ result = -EAGAIN;
+ goto exit_free;
+ }
+
if (nlh->nlmsg_type == NLMSG_DONE)
break; /* ok */
@@ -831,6 +841,7 @@ __getifaddrs (struct ifaddrs **ifap)
return res;
}
weak_alias (__getifaddrs, getifaddrs)
+libc_hidden_def (__getifaddrs)
libc_hidden_weak (getifaddrs)
@@ -840,4 +851,5 @@ __freeifaddrs (struct ifaddrs *ifa)
free (ifa);
}
weak_alias (__freeifaddrs, freeifaddrs)
+libc_hidden_def (__freeifaddrs)
libc_hidden_weak (freeifaddrs)