Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 114322
b: refs/heads/master
c: b4ed58f
h: refs/heads/master
v: v3
  • Loading branch information
Chuck Lever authored and J. Bruce Fields committed Sep 29, 2008
1 parent a9690fe commit 7c09e78
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5344b12d4f97d4a9a62d806425977a6ff64b6baf
refs/heads/master: b4ed58fd34d4def88bda59f9cc566ec9fca6a096
2 changes: 1 addition & 1 deletion trunk/fs/lockd/clntlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 6 additions & 5 deletions trunk/fs/lockd/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 15 additions & 1 deletion trunk/include/linux/lockd/lockd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -76,6 +77,19 @@ struct nsm_handle {
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"
*/
Expand Down

0 comments on commit 7c09e78

Please sign in to comment.