Commit 7e44d3be authored by Chuck Lever's avatar Chuck Lever Committed by J. Bruce Fields

NSM: Generate NSMPROC_MON's "priv" argument when nsm_handle is created

Introduce a new data type, used by both the in-kernel NLM and NSM
implementations, that is used to manage the opaque "priv" argument
for the NSMPROC_MON and NLMPROC_SM_NOTIFY calls.

Construct the "priv" cookie when the nsm_handle is created.

The nsm_init_private() function may look a little strange, but it is
roughly equivalent to how the XDR encoder formed the "priv" argument.
It's going to go away soon.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent 05f3a9af
...@@ -201,6 +201,21 @@ void nsm_unmonitor(const struct nlm_host *host) ...@@ -201,6 +201,21 @@ void nsm_unmonitor(const struct nlm_host *host)
} }
} }
/*
* Construct a unique cookie to match this nsm_handle to this monitored
* host. It is passed to the local rpc.statd via NSMPROC_MON, and
* returned via NLMPROC_SM_NOTIFY, in the "priv" field of these
* requests.
*
* Linux provides the raw IP address of the monitored host,
* left in network byte order.
*/
static void nsm_init_private(struct nsm_handle *nsm)
{
__be32 *p = (__be32 *)&nsm->sm_priv.data;
*p = nsm_addr_in(nsm)->sin_addr.s_addr;
}
/** /**
* nsm_find - Find or create a cached nsm_handle * nsm_find - Find or create a cached nsm_handle
* @sap: pointer to socket address of handle to find * @sap: pointer to socket address of handle to find
...@@ -271,6 +286,7 @@ struct nsm_handle *nsm_find(const struct sockaddr *sap, const size_t salen, ...@@ -271,6 +286,7 @@ struct nsm_handle *nsm_find(const struct sockaddr *sap, const size_t salen,
nsm->sm_name = (char *) (nsm + 1); nsm->sm_name = (char *) (nsm + 1);
memcpy(nsm->sm_name, hostname, hostname_len); memcpy(nsm->sm_name, hostname, hostname_len);
nsm->sm_name[hostname_len] = '\0'; nsm->sm_name[hostname_len] = '\0';
nsm_init_private(nsm);
nsm_display_address((struct sockaddr *)&nsm->sm_addr, nsm_display_address((struct sockaddr *)&nsm->sm_addr,
nsm->sm_addrbuf, sizeof(nsm->sm_addrbuf)); nsm->sm_addrbuf, sizeof(nsm->sm_addrbuf));
atomic_set(&nsm->sm_count, 1); atomic_set(&nsm->sm_count, 1);
......
...@@ -85,6 +85,7 @@ struct nsm_handle { ...@@ -85,6 +85,7 @@ struct nsm_handle {
size_t sm_addrlen; size_t sm_addrlen;
unsigned int sm_monitored : 1, unsigned int sm_monitored : 1,
sm_sticky : 1; /* don't unmonitor */ sm_sticky : 1; /* don't unmonitor */
struct nsm_private sm_priv;
char sm_addrbuf[NSM_ADDRBUF]; char sm_addrbuf[NSM_ADDRBUF];
}; };
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#define LINUX_LOCKD_SM_INTER_H #define LINUX_LOCKD_SM_INTER_H
#define SM_MAXSTRLEN 1024 #define SM_MAXSTRLEN 1024
#define SM_PRIV_SIZE 16
extern int nsm_local_state; extern int nsm_local_state;
......
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
#include <linux/nfs.h> #include <linux/nfs.h>
#include <linux/sunrpc/xdr.h> #include <linux/sunrpc/xdr.h>
#define SM_PRIV_SIZE 16
struct nsm_private {
unsigned char data[SM_PRIV_SIZE];
};
struct svc_rqst; struct svc_rqst;
#define NLM_MAXCOOKIELEN 32 #define NLM_MAXCOOKIELEN 32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment