summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2008-09-03 22:35:39 +0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-09-30 02:13:39 +0400
commitb4ed58fd34d4def88bda59f9cc566ec9fca6a096 (patch)
treece377f9ec8773a26e4a967e7d73d42e99d39b0ea
parent5344b12d4f97d4a9a62d806425977a6ff64b6baf (diff)
downloadlinux-b4ed58fd34d4def88bda59f9cc566ec9fca6a096.tar.xz
lockd: Use sockaddr_storage + length for h_addr field
To store larger addresses in the nlm_host structure, make h_addr a sockaddr_storage, and add an address length field. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r--fs/lockd/clntlock.c2
-rw-r--r--fs/lockd/host.c11
-rw-r--r--include/linux/lockd/lockd.h16
3 files changed, 22 insertions, 7 deletions
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index 0b45fd3a4bfd..0df5587f804e 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -166,7 +166,7 @@ __be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock
*/
if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid)
continue;
- if (!nlm_cmp_addr(&block->b_host->h_addr, addr))
+ if (!nlm_cmp_addr(nlm_addr_in(block->b_host), addr))
continue;
if (nfs_compare_fh(NFS_FH(fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) != 0)
continue;
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 008e4026f540..8c7022eeae65 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -116,7 +116,7 @@ static struct nlm_host *nlm_lookup_host(int server,
*/
chain = &nlm_hosts[hash];
hlist_for_each_entry(host, pos, chain, h_hash) {
- if (!nlm_cmp_addr(&host->h_addr, sin))
+ if (!nlm_cmp_addr(nlm_addr_in(host), sin))
continue;
/* See if we have an NSM handle for this client */
@@ -165,8 +165,9 @@ static struct nlm_host *nlm_lookup_host(int server,
goto out;
}
host->h_name = nsm->sm_name;
- host->h_addr = *sin;
- nlm_clear_port((struct sockaddr *)&host->h_addr);
+ memcpy(nlm_addr(host), sin, sizeof(*sin));
+ host->h_addrlen = sizeof(*sin);
+ nlm_clear_port(nlm_addr(host));
host->h_saddr = *ssin;
host->h_version = version;
host->h_proto = proto;
@@ -291,8 +292,8 @@ nlm_bind_host(struct nlm_host *host)
};
struct rpc_create_args args = {
.protocol = host->h_proto,
- .address = (struct sockaddr *)&host->h_addr,
- .addrsize = sizeof(host->h_addr),
+ .address = nlm_addr(host),
+ .addrsize = host->h_addrlen,
.saddress = (struct sockaddr *)&host->h_saddr,
.timeout = &timeparms,
.servername = host->h_name,
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 0691efbd0b34..41d7a8e61cea 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -38,7 +38,8 @@
*/
struct nlm_host {
struct hlist_node h_hash; /* doubly linked list */
- struct sockaddr_in h_addr; /* peer address */
+ struct sockaddr_storage h_addr; /* peer address */
+ size_t h_addrlen;
struct sockaddr_in h_saddr; /* our address (optional) */
struct rpc_clnt * h_rpcclnt; /* RPC client to talk to peer */
char * h_name; /* remote hostname */
@@ -77,6 +78,19 @@ struct nsm_handle {
};
/*
+ * Rigorous type checking on sockaddr type conversions
+ */
+static inline struct sockaddr_in *nlm_addr_in(const struct nlm_host *host)
+{
+ return (struct sockaddr_in *)&host->h_addr;
+}
+
+static inline struct sockaddr *nlm_addr(const struct nlm_host *host)
+{
+ return (struct sockaddr *)&host->h_addr;
+}
+
+/*
* Map an fl_owner_t into a unique 32-bit "pid"
*/
struct nlm_lockowner {