aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-09-24 17:14:11 +0000
committerUlrich Drepper <drepper@redhat.com>2006-09-24 17:14:11 +0000
commit457b559e2ec7bd66c6da9e99d27f0d1723da4874 (patch)
tree7cef3d8309f8ce3b683daeed319918a25ea03ce0 /sysdeps
parent[BZ #3225] (diff)
downloadglibc-457b559e2ec7bd66c6da9e99d27f0d1723da4874.tar.gz
glibc-457b559e2ec7bd66c6da9e99d27f0d1723da4874.tar.bz2
glibc-457b559e2ec7bd66c6da9e99d27f0d1723da4874.zip
* sysdeps/posix/getaddrinfo.c (rfc3484_sort): Implement rule 4,
home addresses. * sysdeps/unix/sysv/linux/check_pf.c (make_request): Recognize IFA_F_HOMEADDRESS flag for interfaces. * include/ifaddrs.h (struct in6addrinfo): Define in6ai_homeaddress.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/posix/getaddrinfo.c12
-rw-r--r--sysdeps/unix/sysv/linux/check_pf.c12
2 files changed, 20 insertions, 4 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 185957be6a..dd5a57d9e0 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -1390,8 +1390,16 @@ rfc3484_sort (const void *p1, const void *p2)
return 1;
}
- /* Rule 4: Prefer home addresses.
- Another thing only the kernel can decide. */
+ /* Rule 4: Prefer home addresses. */
+ if (a1->got_source_addr)
+ {
+ if (!(a1->source_addr_flags & in6ai_homeaddress)
+ && (a2->source_addr_flags & in6ai_homeaddress))
+ return -1;
+ if ((a1->source_addr_flags & in6ai_homeaddress)
+ && !(a2->source_addr_flags & in6ai_homeaddress))
+ return 1;
+ }
/* Rule 5: Prefer matching label. */
if (a1->got_source_addr)
diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c
index 7fbb7543d6..13ccd7acb4 100644
--- a/sysdeps/unix/sysv/linux/check_pf.c
+++ b/sysdeps/unix/sysv/linux/check_pf.c
@@ -38,6 +38,9 @@
#ifndef IFA_F_TEMPORARY
# define IFA_F_TEMPORARY IFA_F_SECONDARY
#endif
+#ifndef IFA_F_HOMEADDRESS
+# define IFA_F_HOMEADDRESS 0
+#endif
static int
@@ -124,7 +127,9 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6,
case AF_INET6:
*seen_ipv6 = true;
- if (ifam->ifa_flags & (IFA_F_DEPRECATED | IFA_F_TEMPORARY))
+ 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
@@ -152,7 +157,10 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6,
? in6ai_deprecated : 0)
| ((ifam->ifa_flags
& IFA_F_TEMPORARY)
- ? in6ai_temporary : 0));
+ ? in6ai_temporary : 0)
+ | ((ifam->ifa_flags
+ & IFA_F_HOMEADDRESS)
+ ? in6ai_homeaddress : 0));
memcpy (newp->info.addr, address ?: local,
sizeof (newp->info.addr));
newp->next = in6ailist;