Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164607
b: refs/heads/master
c: 4516fc0
h: refs/heads/master
i:
  164605: e4ef7b8
  164603: bf5c2a4
  164599: 6639ef2
  164591: 6b221c5
  164575: 7958b60
  164543: 63174e4
  164479: 59b3f16
  164351: 32bac53
v: v3
  • Loading branch information
Jeff Layton authored and J. Bruce Fields committed Aug 21, 2009
1 parent e9df9f5 commit 3b7227b
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 49 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: e9dc122166b8d863d3057a66ada04838e5548e52
refs/heads/master: 4516fc0454e7ffe2f369e80045b23c2b32155004
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 *addr, const struct nlm_lock *lock)
*/
if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid)
continue;
if (!nlm_cmp_addr(nlm_addr(block->b_host), addr))
if (!rpc_cmp_addr(nlm_addr(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
4 changes: 2 additions & 2 deletions trunk/fs/lockd/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni)
*/
chain = &nlm_hosts[nlm_hash_address(ni->sap)];
hlist_for_each_entry(host, pos, chain, h_hash) {
if (!nlm_cmp_addr(nlm_addr(host), ni->sap))
if (!rpc_cmp_addr(nlm_addr(host), ni->sap))
continue;

/* See if we have an NSM handle for this client */
Expand All @@ -125,7 +125,7 @@ static struct nlm_host *nlm_lookup_host(struct nlm_lookup_host_info *ni)
if (host->h_server != ni->server)
continue;
if (ni->server &&
!nlm_cmp_addr(nlm_srcaddr(host), ni->src_sap))
!rpc_cmp_addr(nlm_srcaddr(host), ni->src_sap))
continue;

/* Move to head of hash chain. */
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/lockd/mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static struct nsm_handle *nsm_lookup_addr(const struct sockaddr *sap)
struct nsm_handle *nsm;

list_for_each_entry(nsm, &nsm_handles, sm_link)
if (nlm_cmp_addr(nsm_addr(nsm), sap))
if (rpc_cmp_addr(nsm_addr(nsm), sap))
return nsm;
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/lockd/svcsubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_sb);
static int
nlmsvc_match_ip(void *datap, struct nlm_host *host)
{
return nlm_cmp_addr(nlm_srcaddr(host), datap);
return rpc_cmp_addr(nlm_srcaddr(host), datap);
}

/**
Expand Down
43 changes: 0 additions & 43 deletions trunk/include/linux/lockd/lockd.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,49 +338,6 @@ static inline int nlm_privileged_requester(const struct svc_rqst *rqstp)
}
}

static inline int __nlm_cmp_addr4(const struct sockaddr *sap1,
const struct sockaddr *sap2)
{
const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sap1;
const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sap2;
return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr;
}

#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
static inline int __nlm_cmp_addr6(const struct sockaddr *sap1,
const struct sockaddr *sap2)
{
const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1;
const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2;
return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
}
#else /* !(CONFIG_IPV6 || CONFIG_IPV6_MODULE) */
static inline int __nlm_cmp_addr6(const struct sockaddr *sap1,
const struct sockaddr *sap2)
{
return 0;
}
#endif /* !(CONFIG_IPV6 || CONFIG_IPV6_MODULE) */

/*
* Compare two host addresses
*
* Return TRUE if the addresses are the same; otherwise FALSE.
*/
static inline int nlm_cmp_addr(const struct sockaddr *sap1,
const struct sockaddr *sap2)
{
if (sap1->sa_family == sap2->sa_family) {
switch (sap1->sa_family) {
case AF_INET:
return __nlm_cmp_addr4(sap1, sap2);
case AF_INET6:
return __nlm_cmp_addr6(sap1, sap2);
}
}
return 0;
}

/*
* Compare two NLM locks.
* When the second lock is of type F_UNLCK, this acts like a wildcard.
Expand Down
48 changes: 48 additions & 0 deletions trunk/include/linux/sunrpc/clnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/sunrpc/timer.h>
#include <asm/signal.h>
#include <linux/path.h>
#include <net/ipv6.h>

struct rpc_inode;

Expand Down Expand Up @@ -188,5 +189,52 @@ static inline void rpc_set_port(struct sockaddr *sap,
#define IPV6_SCOPE_DELIMITER '%'
#define IPV6_SCOPE_ID_LEN sizeof("%nnnnnnnnnn")

static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
const struct sockaddr *sap2)
{
const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sap1;
const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sap2;

return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr;
}

#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1,
const struct sockaddr *sap2)
{
const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1;
const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2;
return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
}
#else /* !(CONFIG_IPV6 || CONFIG_IPV6_MODULE) */
static inline bool __rpc_cmp_addr6(const struct sockaddr *sap1,
const struct sockaddr *sap2)
{
return false;
}
#endif /* !(CONFIG_IPV6 || CONFIG_IPV6_MODULE) */

/**
* rpc_cmp_addr - compare the address portion of two sockaddrs.
* @sap1: first sockaddr
* @sap2: second sockaddr
*
* Just compares the family and address portion. Ignores port, scope, etc.
* Returns true if the addrs are equal, false if they aren't.
*/
static inline bool rpc_cmp_addr(const struct sockaddr *sap1,
const struct sockaddr *sap2)
{
if (sap1->sa_family == sap2->sa_family) {
switch (sap1->sa_family) {
case AF_INET:
return __rpc_cmp_addr4(sap1, sap2);
case AF_INET6:
return __rpc_cmp_addr6(sap1, sap2);
}
}
return false;
}

#endif /* __KERNEL__ */
#endif /* _LINUX_SUNRPC_CLNT_H */

0 comments on commit 3b7227b

Please sign in to comment.