From 6f189dae5eb38800c8ae3e2d5c098d11fb44d7d5 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Thu, 16 Sep 2010 14:17:08 -0400 Subject: [PATCH] exportfs: Enable IPv6 support in matchhostname() To gain IPv6 support in matchhostname(), simply replace the socket address comparison helpers with the generic versions that can handle IPv4 and IPv6. host_addrinfo() (called by matchhostname()) returns IPv6 addresses only if IPv6 support is enabled. Signed-off-by: Chuck Lever Signed-off-by: Steve Dickson --- utils/exportfs/exportfs.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index 8496d82..b78957f 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -26,6 +26,7 @@ #include #include +#include "sockaddr.h" #include "misc.h" #include "nfslib.h" #include "exportfs.h" @@ -443,26 +444,6 @@ is_hostname(const char *sp) return true; } -static _Bool -compare_sockaddrs4(const struct sockaddr *sa1, const struct sockaddr *sa2) -{ - const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sa1; - const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sa2; - return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr; -} - -static _Bool -compare_sockaddrs(const struct sockaddr *sa1, const struct sockaddr *sa2) -{ - if (sa1->sa_family == sa2->sa_family) - switch (sa1->sa_family) { - case AF_INET: - return compare_sockaddrs4(sa1, sa2); - } - - return false; -} - static int matchhostname(const char *hostname1, const char *hostname2) { @@ -493,7 +474,7 @@ matchhostname(const char *hostname1, const char *hostname2) for (ai1 = results1; ai1 != NULL; ai1 = ai1->ai_next) for (ai2 = results2; ai2 != NULL; ai2 = ai2->ai_next) - if (compare_sockaddrs(ai1->ai_addr, ai2->ai_addr)) { + if (nfs_compare_sockaddr(ai1->ai_addr, ai2->ai_addr)) { result = 1; break; } -- 2.39.5