NSM: Generate NSMPROC_MON's "priv" argument when nsm_handle is created
authorChuck Lever <chuck.lever@oracle.com>
Sat, 6 Dec 2008 00:03:16 +0000 (19:03 -0500)
committerJ. Bruce Fields <bfields@citi.umich.edu>
Tue, 6 Jan 2009 16:53:53 +0000 (11:53 -0500)
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: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
fs/lockd/mon.c
include/linux/lockd/lockd.h
include/linux/lockd/sm_inter.h
include/linux/lockd/xdr.h

index 0792900b628127ee75a10ec78c679158850be56c..c8d18cd22b8a0f7c9b67bc8dfd5f6221f1b73b46 100644 (file)
@@ -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
  * @sap: pointer to socket address of handle to find
@@ -271,6 +286,7 @@ retry:
        nsm->sm_name = (char *) (nsm + 1);
        memcpy(nsm->sm_name, hostname, hostname_len);
        nsm->sm_name[hostname_len] = '\0';
+       nsm_init_private(nsm);
        nsm_display_address((struct sockaddr *)&nsm->sm_addr,
                                nsm->sm_addrbuf, sizeof(nsm->sm_addrbuf));
        atomic_set(&nsm->sm_count, 1);
index 8d715363c6ac97696b2d6883c0ca33304357a2ef..194fa8a663986a8b12a21ad3c4a838c8086b02ec 100644 (file)
@@ -85,6 +85,7 @@ struct nsm_handle {
        size_t                  sm_addrlen;
        unsigned int            sm_monitored : 1,
                                sm_sticky : 1;  /* don't unmonitor */
+       struct nsm_private      sm_priv;
        char                    sm_addrbuf[NSM_ADDRBUF];
 };
 
index 116bf38535a040fd32377cf56b980555cce804a8..5cef5a79dd940fe7e16e54bc7fb933b978f65d10 100644 (file)
@@ -10,7 +10,6 @@
 #define LINUX_LOCKD_SM_INTER_H
 
 #define SM_MAXSTRLEN   1024
-#define SM_PRIV_SIZE   16
 
 extern int     nsm_local_state;
 
index d6b3a802c0469a8e65311058167b6e2d5bacd76c..6b51992638585296b68748ced6b1d26632aaa293 100644 (file)
 #include <linux/nfs.h>
 #include <linux/sunrpc/xdr.h>
 
+#define SM_PRIV_SIZE           16
+
+struct nsm_private {
+       unsigned char           data[SM_PRIV_SIZE];
+};
+
 struct svc_rqst;
 
 #define NLM_MAXCOOKIELEN       32
This page took 0.037369 seconds and 5 git commands to generate.