aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/lockd/lockd.h
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2008-09-03 14:36:01 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-09-29 18:13:39 -0400
commit781b61a6f4ff94cb8c14cf598b547f5d5c490969 (patch)
tree166288be121563b77c3672b311bbbe2541de3bd3 /include/linux/lockd/lockd.h
parent7e9d7746bfd40121438b155023793796499497d8 (diff)
lockd: Teach nlm_cmp_addr() to support AF_INET6 addresses
Update the nlm_cmp_addr() helper to support AF_INET6 as well as AF_INET addresses. New version takes two "struct sockaddr *" arguments instead of "struct sockaddr_in *" arguments. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'include/linux/lockd/lockd.h')
-rw-r--r--include/linux/lockd/lockd.h36
1 files changed, 32 insertions, 4 deletions
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/*