Skip to contentSkip to conversation

NFS: Add secinfo procedure

PATCH In review Bryan Schumaker 2 participants 2 messages Dec 22, 2010 – Dec 23, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/5 NFS: Add secinfo procedure

This patch adds the nfs4 operation secinfo as a
valid nfs rpc operation.

---
 fs/nfs/nfs3proc.c       |    1 +
 fs/nfs/nfs4proc.c       |   35 +++++++++++++
 fs/nfs/nfs4xdr.c        |  129 +++++++++++++++++++++++++++++++++++++++++++++++
 fs/nfs/proc.c           |    1 +
 include/linux/nfs4.h    |    1 +
 include/linux/nfs_xdr.h |   34 ++++++++++++
 6 files changed, 201 insertions(+), 0 deletions(-)
fs/nfs/nfs3proc.c +1 -0
index 2b0e7c8..1237e04 100644
@@ -885,4 +885,5 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
 	.lock		= nfs3_proc_lock,
 	.clear_acl_cache = nfs3_forget_cached_acls,
 	.close_context	= nfs_close_context,
+	.secinfo	= NULL,
 };
fs/nfs/nfs4proc.c +35 -0
index ccd6adb..37a676f 100644
@@ -4500,6 +4500,40 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
 	return status;
 }
 
+static int _nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, struct nfs4_secinfo_flavors *flavors)
+{
+	int status;
+	struct nfs4_secinfo_arg args = {
+		.dir_fh = NFS_FH(dir),
+		.name   = name,
+	};
+	struct nfs4_secinfo_res res = {
+		.flavors     = flavors,
+	};
+	struct rpc_message msg = {
+		.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SECINFO],
+		.rpc_argp = &args,
+		.rpc_resp = &res,
+	};
+
+	dprintk("NFS call  secinfo %s\n", name->name);
+	status = nfs4_call_sync(NFS_SERVER(dir)->client, NFS_SERVER(dir), &msg, &args.seq_args, &res.seq_res, 0);
+	dprintk("NFS reply  secinfo: %d\n", status);
+	return status;
+}
+
+int nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, struct nfs4_secinfo_flavors *flavors)
+{
+	struct nfs4_exception exception = { };
+	int err;
+	do {
+		err = nfs4_handle_exception(NFS_SERVER(dir),
+				_nfs4_proc_secinfo(dir, name, flavors),
+				&exception);
+	} while (exception.retry);
+	return err;
+}
+
 #ifdef CONFIG_NFS_V4_1
 /*
  * nfs4_proc_exchange_id()
@@ -5565,6 +5599,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
 	.clear_acl_cache = nfs4_zap_acl_attr,
 	.close_context  = nfs4_close_context,
 	.open_context	= nfs4_atomic_open,
+	.secinfo	= nfs4_proc_secinfo,
 };
 
 /*
fs/nfs/nfs4xdr.c +129 -0

177 lines not on this page · raw message

fs/nfs/proc.c +1 -0
index 504dd25..36f482c 100644
@@ -740,4 +740,5 @@ const struct nfs_rpc_ops nfs_v2_clientops = {
 	.lock		= nfs_proc_lock,
 	.lock_check_bounds = nfs_lock_check_bounds,
 	.close_context	= nfs_close_context,
+	.secinfo	= NULL,
 };
include/linux/nfs4.h +1 -0
index 4925b22..b4904b2 100644
@@ -540,6 +540,7 @@ enum {
 	NFSPROC4_CLNT_SETACL,
 	NFSPROC4_CLNT_FS_LOCATIONS,
 	NFSPROC4_CLNT_RELEASE_LOCKOWNER,
+	NFSPROC4_CLNT_SECINFO,
 
 	/* nfs41 */
 	NFSPROC4_CLNT_EXCHANGE_ID,
include/linux/nfs_xdr.h +34 -0
index 8630e66..6ad438c 100644
@@ -3,6 +3,7 @@
 
 #include <linux/nfsacl.h>
 #include <linux/nfs3.h>
+#include <linux/sunrpc/gss_api.h>
 
 /*
  * To change the maximum rsize and wsize supported by the NFS client, adjust
@@ -935,6 +936,38 @@ struct nfs4_fs_locations_res {
 	struct nfs4_sequence_res	seq_res;
 };
 
+struct nfs4_secinfo_oid {
+	unsigned int len;
+	char data[GSS_OID_MAX_LEN];
+};
+
+struct nfs4_secinfo_gss {
+	struct nfs4_secinfo_oid sec_oid4;
+	unsigned int qop4;
+	unsigned int service;
+};
+
+struct nfs4_secinfo_flavor {
+	unsigned int 		flavor;
+	struct nfs4_secinfo_gss	gss;
+};
+
+struct nfs4_secinfo_flavors {
+	unsigned int num_flavors;
+	struct nfs4_secinfo_flavor flavors[0];
+};
+
+struct nfs4_secinfo_arg {
+	const struct nfs_fh		*dir_fh;
+	const struct qstr		*name;
+	struct nfs4_sequence_args	seq_args;
+};
+
+struct nfs4_secinfo_res {
+	struct nfs4_secinfo_flavors	*flavors;
+	struct nfs4_sequence_res	seq_res;
+};
+
 #endif /* CONFIG_NFS_V4 */
 
 struct nfstime4 {
@@ -1105,6 +1138,7 @@ struct nfs_rpc_ops {
 				struct nfs_open_context *ctx,
 				int open_flags,
 				struct iattr *iattr);
+	int	(*secinfo)(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
 };
 
 /*
Signature · 1 line
1.7.3.4
#1 lore raw
Quoted 19 lines · Bryan Schumaker

This patch adds the nfs4 operation secinfo as a
valid nfs rpc operation.

---

fs/nfs/nfs3proc.c       |    1 +
fs/nfs/nfs4proc.c       |   35 +++++++++++++
fs/nfs/nfs4xdr.c        |  129 +++++++++++++++++++++++++++++++++++++++++++++++
fs/nfs/proc.c           |    1 +
include/linux/nfs4.h    |    1 +
include/linux/nfs_xdr.h |   34 ++++++++++++
6 files changed, 201 insertions(+), 0 deletions(-)
fs/nfs/nfs3proc.c +0 -0
index 2b0e7c8..1237e04 100644

fs/nfs/nfs3proc.c const struct nfs_rpc_ops nfs_v3_clientops = { · line 889

Quoted 5 lines
fs/nfs/nfs3proc.c +1 -0
@@ -885,4 +885,5 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
 	.lock		= nfs3_proc_lock,
 	.clear_acl_cache = nfs3_forget_cached_acls,
 	.close_context	= nfs_close_context,
+	.secinfo	= NULL,
 };

I believe the practice of setting global constant function pointer fields such as this one to NULL is frowned upon. C ensures that's their default value.

fs/nfs/proc.c const struct nfs_rpc_ops nfs_v2_clientops = { · line 744

Quoted 10 lines
fs/nfs/proc.c +1 -0
index 504dd25..36f482c 100644
@@ -740,4 +740,5 @@ const struct nfs_rpc_ops nfs_v2_clientops = {
 	.lock		= nfs_proc_lock,
 	.lock_check_bounds = nfs_lock_check_bounds,
 	.close_context	= nfs_close_context,
+	.secinfo	= NULL,
 };

Ditto.

Signature · 2 lines
Chuck Lever
chuck[dot]lever[at]oracle[dot]com