Commit b4ed58fd authored by Chuck Lever's avatar Chuck Lever Committed by J. Bruce Fields

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: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent 5344b12d
...@@ -166,7 +166,7 @@ __be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock ...@@ -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) if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid)
continue; continue;
if (!nlm_cmp_addr(&block->b_host->h_addr, addr)) if (!nlm_cmp_addr(nlm_addr_in(block->b_host), addr))
continue; continue;
if (nfs_compare_fh(NFS_FH(fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) != 0) if (nfs_compare_fh(NFS_FH(fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) != 0)
continue; continue;
......
...@@ -116,7 +116,7 @@ static struct nlm_host *nlm_lookup_host(int server, ...@@ -116,7 +116,7 @@ static struct nlm_host *nlm_lookup_host(int server,
*/ */
chain = &nlm_hosts[hash]; chain = &nlm_hosts[hash];
hlist_for_each_entry(host, pos, chain, h_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; continue;
/* See if we have an NSM handle for this client */ /* See if we have an NSM handle for this client */
...@@ -165,8 +165,9 @@ static struct nlm_host *nlm_lookup_host(int server, ...@@ -165,8 +165,9 @@ static struct nlm_host *nlm_lookup_host(int server,
goto out; goto out;
} }
host->h_name = nsm->sm_name; host->h_name = nsm->sm_name;
host->h_addr = *sin; memcpy(nlm_addr(host), sin, sizeof(*sin));
nlm_clear_port((struct sockaddr *)&host->h_addr); host->h_addrlen = sizeof(*sin);
nlm_clear_port(nlm_addr(host));
host->h_saddr = *ssin; host->h_saddr = *ssin;
host->h_version = version; host->h_version = version;
host->h_proto = proto; host->h_proto = proto;
...@@ -291,8 +292,8 @@ nlm_bind_host(struct nlm_host *host) ...@@ -291,8 +292,8 @@ nlm_bind_host(struct nlm_host *host)
}; };
struct rpc_create_args args = { struct rpc_create_args args = {
.protocol = host->h_proto, .protocol = host->h_proto,
.address = (struct sockaddr *)&host->h_addr, .address = nlm_addr(host),
.addrsize = sizeof(host->h_addr), .addrsize = host->h_addrlen,
.saddress = (struct sockaddr *)&host->h_saddr, .saddress = (struct sockaddr *)&host->h_saddr,
.timeout = &timeparms, .timeout = &timeparms,
.servername = host->h_name, .servername = host->h_name,
......
...@@ -38,7 +38,8 @@ ...@@ -38,7 +38,8 @@
*/ */
struct nlm_host { struct nlm_host {
struct hlist_node h_hash; /* doubly linked list */ 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 sockaddr_in h_saddr; /* our address (optional) */
struct rpc_clnt * h_rpcclnt; /* RPC client to talk to peer */ struct rpc_clnt * h_rpcclnt; /* RPC client to talk to peer */
char * h_name; /* remote hostname */ char * h_name; /* remote hostname */
...@@ -76,6 +77,19 @@ struct nsm_handle { ...@@ -76,6 +77,19 @@ struct nsm_handle {
char sm_addrbuf[48]; /* address eyecatcher */ char sm_addrbuf[48]; /* address eyecatcher */
}; };
/*
* 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" * Map an fl_owner_t into a unique 32-bit "pid"
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment