aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/lockd/clntlock.c3
-rw-r--r--fs/lockd/host.c6
-rw-r--r--fs/lockd/svcsubs.c2
-rw-r--r--include/linux/lockd/lockd.h36
4 files changed, 38 insertions, 9 deletions
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index 0df5587f804e..237224a3c420 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -166,7 +166,8 @@ __be32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock
166 */ 166 */
167 if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid) 167 if (fl_blocked->fl_u.nfs_fl.owner->pid != lock->svid)
168 continue; 168 continue;
169 if (!nlm_cmp_addr(nlm_addr_in(block->b_host), addr)) 169 if (!nlm_cmp_addr(nlm_addr(block->b_host),
170 (struct sockaddr *)addr))
170 continue; 171 continue;
171 if (nfs_compare_fh(NFS_FH(fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) != 0) 172 if (nfs_compare_fh(NFS_FH(fl_blocked->fl_file->f_path.dentry->d_inode) ,fh) != 0)
172 continue; 173 continue;
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 510ebcf485f0..dbf3fe620a0c 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -116,7 +116,7 @@ static struct nlm_host *nlm_lookup_host(int server,
116 */ 116 */
117 chain = &nlm_hosts[hash]; 117 chain = &nlm_hosts[hash];
118 hlist_for_each_entry(host, pos, chain, h_hash) { 118 hlist_for_each_entry(host, pos, chain, h_hash) {
119 if (!nlm_cmp_addr(nlm_addr_in(host), sin)) 119 if (!nlm_cmp_addr(nlm_addr(host), (struct sockaddr *)sin))
120 continue; 120 continue;
121 121
122 /* See if we have an NSM handle for this client */ 122 /* See if we have an NSM handle for this client */
@@ -129,7 +129,7 @@ static struct nlm_host *nlm_lookup_host(int server,
129 continue; 129 continue;
130 if (host->h_server != server) 130 if (host->h_server != server)
131 continue; 131 continue;
132 if (!nlm_cmp_addr(nlm_srcaddr_in(host), ssin)) 132 if (!nlm_cmp_addr(nlm_srcaddr(host), (struct sockaddr *)ssin))
133 continue; 133 continue;
134 134
135 /* Move to head of hash chain. */ 135 /* Move to head of hash chain. */
@@ -551,7 +551,7 @@ retry:
551 if (strlen(pos->sm_name) != hostname_len 551 if (strlen(pos->sm_name) != hostname_len
552 || memcmp(pos->sm_name, hostname, hostname_len)) 552 || memcmp(pos->sm_name, hostname, hostname_len))
553 continue; 553 continue;
554 } else if (!nlm_cmp_addr(nsm_addr_in(pos), sin)) 554 } else if (!nlm_cmp_addr(nsm_addr(pos), (struct sockaddr *)sin))
555 continue; 555 continue;
556 atomic_inc(&pos->sm_count); 556 atomic_inc(&pos->sm_count);
557 kfree(nsm); 557 kfree(nsm);
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index d3d1330d7c27..34c2766e27c7 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -418,7 +418,7 @@ EXPORT_SYMBOL_GPL(nlmsvc_unlock_all_by_sb);
418static int 418static int
419nlmsvc_match_ip(void *datap, struct nlm_host *host) 419nlmsvc_match_ip(void *datap, struct nlm_host *host)
420{ 420{
421 return nlm_cmp_addr(nlm_srcaddr_in(host), datap); 421 return nlm_cmp_addr(nlm_srcaddr(host), datap);
422} 422}
423 423
424/** 424/**
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index b1dfa0b1d1bc..ec8af115843d 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -12,6 +12,8 @@
12#ifdef __KERNEL__ 12#ifdef __KERNEL__
13 13
14#include <linux/in.h> 14#include <linux/in.h>
15#include <linux/in6.h>
16#include <net/ipv6.h>
15#include <linux/fs.h> 17#include <linux/fs.h>
16#include <linux/kref.h> 18#include <linux/kref.h>
17#include <linux/utsname.h> 19#include <linux/utsname.h>
@@ -272,13 +274,39 @@ static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)
272 return file->f_file->f_path.dentry->d_inode; 274 return file->f_file->f_path.dentry->d_inode;
273} 275}
274 276
277static inline int __nlm_cmp_addr4(const struct sockaddr *sap1,
278 const struct sockaddr *sap2)
279{
280 const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sap1;
281 const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sap2;
282 return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr;
283}
284
285static inline int __nlm_cmp_addr6(const struct sockaddr *sap1,
286 const struct sockaddr *sap2)
287{
288 const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sap1;
289 const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sap2;
290 return ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr);
291}
292
275/* 293/*
276 * Compare two host addresses (needs modifying for ipv6) 294 * Compare two host addresses
295 *
296 * Return TRUE if the addresses are the same; otherwise FALSE.
277 */ 297 */
278static inline int nlm_cmp_addr(const struct sockaddr_in *sin1, 298static inline int nlm_cmp_addr(const struct sockaddr *sap1,
279 const struct sockaddr_in *sin2) 299 const struct sockaddr *sap2)
280{ 300{
281 return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr; 301 if (sap1->sa_family == sap2->sa_family) {
302 switch (sap1->sa_family) {
303 case AF_INET:
304 return __nlm_cmp_addr4(sap1, sap2);
305 case AF_INET6:
306 return __nlm_cmp_addr6(sap1, sap2);
307 }
308 }
309 return 0;
282} 310}
283 311
284/* 312/*