diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-07-31 17:46:17 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-07-31 17:46:17 +0000 |
commit | 8833066b122427710a9e14a888ce6cfa862332d3 (patch) | |
tree | 29591019d695919417b3698618d6a342e97381d6 /sysdeps/unix/sysv/linux/check_pf.c | |
parent | fedca46896bdb702cb988837a0c2c5447e72ba2b (diff) | |
download | glibc-8833066b122427710a9e14a888ce6cfa862332d3.tar.gz glibc-8833066b122427710a9e14a888ce6cfa862332d3.tar.xz glibc-8833066b122427710a9e14a888ce6cfa862332d3.zip |
Updated to fedora-glibc-20070731T1624 cvs/fedora-glibc-2_6_90-1
Diffstat (limited to 'sysdeps/unix/sysv/linux/check_pf.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/check_pf.c | 80 |
1 files changed, 56 insertions, 24 deletions
diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c index 3312da3af8..fbe805bf3b 100644 --- a/sysdeps/unix/sysv/linux/check_pf.c +++ b/sysdeps/unix/sysv/linux/check_pf.c @@ -136,40 +136,72 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6, if (nlmh->nlmsg_type == RTM_NEWADDR) { struct ifaddrmsg *ifam = (struct ifaddrmsg *) NLMSG_DATA (nlmh); + struct rtattr *rta = IFA_RTA (ifam); + size_t len = nlmh->nlmsg_len - NLMSG_LENGTH (sizeof (*ifam)); switch (ifam->ifa_family) { + const void *local; + const void *address; + case AF_INET: - *seen_ipv4 = true; + local = NULL; + address = NULL; + while (RTA_OK (rta, len)) + { + switch (rta->rta_type) + { + case IFA_LOCAL: + local = RTA_DATA (rta); + break; + + case IFA_ADDRESS: + address = RTA_DATA (rta); + goto out_v4; + } + + rta = RTA_NEXT (rta, len); + } + + if (local != NULL) + { + out_v4: + if (*(const in_addr_t *) (address ?: local) + != htonl (INADDR_LOOPBACK)) + *seen_ipv4 = true; + } break; + case AF_INET6: - *seen_ipv6 = true; + local = NULL; + address = NULL; + while (RTA_OK (rta, len)) + { + switch (rta->rta_type) + { + case IFA_LOCAL: + local = RTA_DATA (rta); + break; + + case IFA_ADDRESS: + address = RTA_DATA (rta); + goto out_v6; + } + + rta = RTA_NEXT (rta, len); + } + + if (local != NULL) + { + out_v6: + if (!IN6_IS_ADDR_LOOPBACK (address ?: local)) + *seen_ipv6 = true; + } if (ifam->ifa_flags & (IFA_F_DEPRECATED | IFA_F_TEMPORARY | IFA_F_HOMEADDRESS)) { - struct rtattr *rta = IFA_RTA (ifam); - size_t len = (nlmh->nlmsg_len - - NLMSG_LENGTH (sizeof (*ifam))); - void *local = NULL; - void *address = NULL; - while (RTA_OK (rta, len)) - { - switch (rta->rta_type) - { - case IFA_LOCAL: - local = RTA_DATA (rta); - break; - - case IFA_ADDRESS: - address = RTA_DATA (rta); - break; - } - - rta = RTA_NEXT (rta, len); - } - struct in6ailist *newp = alloca (sizeof (*newp)); newp->info.flags = (((ifam->ifa_flags & IFA_F_DEPRECATED) ? in6ai_deprecated : 0) @@ -200,7 +232,7 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6, close_not_cancel_no_status (fd); - if (in6ailist != NULL) + if (*seen_ipv6 && in6ailist != NULL) { *in6ai = malloc (in6ailistlen * sizeof (**in6ai)); if (*in6ai == NULL) |