diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2010-05-05 15:41:07 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2010-05-05 15:42:36 -0400 |
commit | 6299a310d77e6495efdf7c50491f0b055fee2cfe (patch) | |
tree | 636a10692ff37c4d7fb65f59d4be8a9c91724409 /support/include/exportfs.h | |
parent | 6ff1fd42db18c657fbc5f81169a566b41d53e731 (diff) | |
download | nfs-utils-6299a310d77e6495efdf7c50491f0b055fee2cfe.tar.gz nfs-utils-6299a310d77e6495efdf7c50491f0b055fee2cfe.tar.xz nfs-utils-6299a310d77e6495efdf7c50491f0b055fee2cfe.zip |
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 <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'support/include/exportfs.h')
-rw-r--r-- | support/include/exportfs.h | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/support/include/exportfs.h b/support/include/exportfs.h index 05891c5..70bdd57 100644 --- a/support/include/exportfs.h +++ b/support/include/exportfs.h @@ -10,6 +10,8 @@ #define EXPORTFS_H #include <netdb.h> + +#include "sockaddr.h" #include "nfslib.h" enum { @@ -35,11 +37,56 @@ typedef struct mclient { char * m_hostname; int m_type; int m_naddr; - struct in_addr m_addrlist[NFSCLNT_ADDRMAX]; + union nfs_sockaddr m_addrlist[NFSCLNT_ADDRMAX]; int m_exported; /* exported to nfsd */ int m_count; } nfs_client; +static inline const struct sockaddr * +get_addrlist(const nfs_client *clp, const int i) +{ + return &clp->m_addrlist[i].sa; +} + +static inline const struct sockaddr_in * +get_addrlist_in(const nfs_client *clp, const int i) +{ + return &clp->m_addrlist[i].s4; +} + +static inline const struct sockaddr_in6 * +get_addrlist_in6(const nfs_client *clp, const int i) +{ + return &clp->m_addrlist[i].s6; +} + +static inline void +set_addrlist_in(nfs_client *clp, const int i, const struct sockaddr_in *sin) +{ + memcpy(&clp->m_addrlist[i].s4, sin, sizeof(*sin)); +} + +static inline void +set_addrlist_in6(nfs_client *clp, const int i, const struct sockaddr_in6 *sin6) +{ + memcpy(&clp->m_addrlist[i].s6, sin6, sizeof(*sin6)); +} + +static inline void +set_addrlist(nfs_client *clp, const int i, const struct sockaddr *sap) +{ + switch (sap->sa_family) { + case AF_INET: + memcpy(&clp->m_addrlist[i].s4, sap, sizeof(struct sockaddr_in)); + break; +#ifdef IPV6_SUPPORTED + case AF_INET6: + memcpy(&clp->m_addrlist[i].s6, sap, sizeof(struct sockaddr_in6)); + break; +#endif + } +} + typedef struct mexport { struct mexport * m_next; struct mclient * m_client; |