mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-06 22:42:10 +00:00
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>
This commit is contained in:
parent
7e9d7746bf
commit
781b61a6f4
4 changed files with 39 additions and 10 deletions
|
@ -12,6 +12,8 @@
|
|||
#ifdef __KERNEL__
|
||||
|
||||
#include <linux/in.h>
|
||||
#include <linux/in6.h>
|
||||
#include <net/ipv6.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/kref.h>
|
||||
#include <linux/utsname.h>
|
||||
|
@ -272,15 +274,41 @@ static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)
|
|||
return file->f_file->f_path.dentry->d_inode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare two host addresses (needs modifying for ipv6)
|
||||
*/
|
||||
static inline int nlm_cmp_addr(const struct sockaddr_in *sin1,
|
||||
const struct sockaddr_in *sin2)
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue