mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
NFSD: Support IPv6 addresses in write_failover_ip()
In write_failover_ip(), replace the sscanf() with a call to the common sunrpc.ko presentation address parser. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
c15128c5e4
commit
4116092b92
1 changed files with 7 additions and 14 deletions
|
@ -37,6 +37,7 @@
|
||||||
#include <linux/nfsd/xdr.h>
|
#include <linux/nfsd/xdr.h>
|
||||||
#include <linux/nfsd/syscall.h>
|
#include <linux/nfsd/syscall.h>
|
||||||
#include <linux/lockd/lockd.h>
|
#include <linux/lockd/lockd.h>
|
||||||
|
#include <linux/sunrpc/clnt.h>
|
||||||
|
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include <net/ipv6.h>
|
#include <net/ipv6.h>
|
||||||
|
@ -490,22 +491,18 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size)
|
||||||
*
|
*
|
||||||
* Input:
|
* Input:
|
||||||
* buf: '\n'-terminated C string containing a
|
* buf: '\n'-terminated C string containing a
|
||||||
* presentation format IPv4 address
|
* presentation format IP address
|
||||||
* size: length of C string in @buf
|
* size: length of C string in @buf
|
||||||
* Output:
|
* Output:
|
||||||
* On success: returns zero if all specified locks were released;
|
* On success: returns zero if all specified locks were released;
|
||||||
* returns one if one or more locks were not released
|
* returns one if one or more locks were not released
|
||||||
* On error: return code is negative errno value
|
* On error: return code is negative errno value
|
||||||
*
|
|
||||||
* Note: Only AF_INET client addresses are passed in
|
|
||||||
*/
|
*/
|
||||||
static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size)
|
static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size)
|
||||||
{
|
{
|
||||||
struct sockaddr_in sin = {
|
struct sockaddr_storage address;
|
||||||
.sin_family = AF_INET,
|
struct sockaddr *sap = (struct sockaddr *)&address;
|
||||||
};
|
size_t salen = sizeof(address);
|
||||||
int b1, b2, b3, b4;
|
|
||||||
char c;
|
|
||||||
char *fo_path;
|
char *fo_path;
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
|
@ -519,14 +516,10 @@ static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size)
|
||||||
if (qword_get(&buf, fo_path, size) < 0)
|
if (qword_get(&buf, fo_path, size) < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* get ipv4 address */
|
if (rpc_pton(fo_path, size, sap, salen) == 0)
|
||||||
if (sscanf(fo_path, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (b1 > 255 || b2 > 255 || b3 > 255 || b4 > 255)
|
|
||||||
return -EINVAL;
|
|
||||||
sin.sin_addr.s_addr = htonl((b1 << 24) | (b2 << 16) | (b3 << 8) | b4);
|
|
||||||
|
|
||||||
return nlmsvc_unlock_all_by_ip((struct sockaddr *)&sin);
|
return nlmsvc_unlock_all_by_ip(sap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue