From 6299a310d77e6495efdf7c50491f0b055fee2cfe Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Wed, 5 May 2010 15:41:07 -0400 Subject: mountd/exportfs: Make m_addrlist field a nfs_sockaddr To store non-AF_INET addresses in the nfs_client structure, we need to use more than in_addr for the m_addrlist field. Make m_addrlist larger, then add a few helper functions to handle type casting and array indexing cleanly. We could treat the nfs_client address list as if all the addresses in the list were the same family. This might work for MCL_SUBNETWORK type nfs_clients. However, during the transition to IPv6, most hosts will have at least one IPv4 and one IPv6 address. For MCL_FQDN, I think we need to have the ability to store addresses from both families in one nfs_client. Additionally, IPv6 scope IDs are not part of struct sin6_addr. To support link-local IPv6 addresses and the like, a scope ID must be stored. Thus, each slot in the address list needs to be capable of storing an entire socket address, and not simply the network address part. Signed-off-by: Chuck Lever Signed-off-by: Steve Dickson --- support/export/nfsctl.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'support/export/nfsctl.c') diff --git a/support/export/nfsctl.c b/support/export/nfsctl.c index e2877b9..ae357c7 100644 --- a/support/export/nfsctl.c +++ b/support/export/nfsctl.c @@ -66,7 +66,7 @@ str_tolower(char *s) static int cltsetup(struct nfsctl_client *cltarg, nfs_client *clp) { - int i; + int i, j; if (clp->m_type != MCL_FQDN) { xlog(L_ERROR, "internal: can't export non-FQDN host"); @@ -76,10 +76,19 @@ cltsetup(struct nfsctl_client *cltarg, nfs_client *clp) strncpy(cltarg->cl_ident, clp->m_hostname, sizeof (cltarg->cl_ident) - 1); str_tolower(cltarg->cl_ident); - cltarg->cl_naddr = clp->m_naddr; - for (i = 0; i < cltarg->cl_naddr && i < NFSCLNT_ADDRMAX; i++) - cltarg->cl_addrlist[i] = clp->m_addrlist[i]; + j = 0; + for (i = 0; i < cltarg->cl_naddr && i < NFSCLNT_ADDRMAX; i++) { + struct sockaddr_in *sin = get_addrlist_in(clp, i); + if (sin->sin_family == AF_INET) + cltarg->cl_addrlist[j++] = sin->sin_addr; + } + if (j == 0) { + xlog(L_ERROR, "internal: no supported addresses in nfs_client"); + return 0; + } + + cltarg->cl_naddr = j; return 1; } -- cgit