Skip to contentSkip to conversation

NFSd: NFSv4.1 OPEN must use the session-derived client id

PATCH In review Trond Myklebust 2 participants 3 messages Feb 21, 2014

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

PATCH 1/1 NFSd: NFSv4.1 OPEN must use the session-derived client id

RFC5661 states:

The client can set the clientid field to any value and the server MUST ignore it. Instead, the server MUST derive the client ID from the session ID of the SEQUENCE operation of the COMPOUND request

Make it so...

---
 fs/nfsd/nfs4state.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
fs/nfsd/nfs4state.c +17 -0
index 693e1458e2ca..d23f4cdbc891 100644
@@ -2826,6 +2826,21 @@ static __be32 nfsd4_check_seqid(struct nfsd4_compound_state *cstate, struct nfs4
 	return nfserr_bad_seqid;
 }
 
+/*
+ * RFC5661: OPEN MUST ignore the client-supplied clientid argument and
+ * substitute the session clientid
+ */
+static void nfsd41_set_open_clientid(struct nfsd4_compound_state *cstate,
+		struct nfsd4_open *open)
+{
+	struct nfs4_client *clp;
+
+	if (!nfsd4_has_session(cstate))
+		return;
+	clp = cstate->session->se_client;
+	memcpy(&open->op_clientid, &clp->cl_clientid, sizeof(open->op_clientid));
+}
+
 __be32
 nfsd4_process_open1(struct nfsd4_compound_state *cstate,
 		    struct nfsd4_open *open, struct nfsd_net *nn)
@@ -2836,6 +2851,8 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate,
 	struct nfs4_openowner *oo = NULL;
 	__be32 status;
 
+	nfsd41_set_open_clientid(cstate, open);
+
 	if (STALE_CLIENTID(&open->op_clientid, nn))
 		return nfserr_stale_clientid;
 	/*
Signature · 1 line
1.8.5.3
#1 lore raw
Quoted 40 lines · Trond Myklebust

RFC5661 states:

The client can set the clientid field to any value and the server MUST ignore it. Instead, the server MUST derive the client ID from the session ID of the SEQUENCE operation of the COMPOUND request

Make it so...

---
fs/nfsd/nfs4state.c | 17 +++++++++++++++++

1 file changed, 17 insertions(+)
fs/nfsd/nfs4state.c +15 -0
index 693e1458e2ca..d23f4cdbc891 100644
@@ -2826,6 +2826,21 @@ static __be32 nfsd4_check_seqid(struct nfsd4_compound_state *cstate, struct nfs4
 	return nfserr_bad_seqid;
 }
 
+/*
+ * RFC5661: OPEN MUST ignore the client-supplied clientid argument and
+ * substitute the session clientid
+ */
+static void nfsd41_set_open_clientid(struct nfsd4_compound_state *cstate,
+		struct nfsd4_open *open)
+{
+	struct nfs4_client *clp;
+
+	if (!nfsd4_has_session(cstate))
+		return;
+	clp = cstate->session->se_client;
+	memcpy(&open->op_clientid, &clp->cl_clientid, sizeof(open->op_clientid));
+}
+

__be32
nfsd4_process_open1(struct nfsd4_compound_state *cstate,
struct nfsd4_open *open, struct nfsd_net *nn)

fs/nfsd/nfs4state.c nfsd4_process_open1(struct nfsd4_compound_state *cstate, · line 2857

Quoted 7 lines
fs/nfsd/nfs4state.c +2 -0
@@ -2836,6 +2851,8 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate,
 	struct nfs4_openowner *oo = NULL;
 	__be32 status;
 
+	nfsd41_set_open_clientid(cstate, open);
+
 	if (STALE_CLIENTID(&open->op_clientid, nn))
 		return nfserr_stale_clientid;

Never mind. There seems to be code to do this in nfsd4_open()...

_________________________________
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]

#2 lore raw
In reply to Trond Myklebust
Quoted 7 lines · Trond Myklebust

RFC5661 states:

The client can set the clientid field to any value and the server MUST ignore it. Instead, the server MUST derive the client ID from the session ID of the SEQUENCE operation of the COMPOUND request

Make it so...

See fs/nfsd/nfs4proc.c:nfsd4_open():

	if (nfsd4_has_session(cstate))
		copy_clientid(&open->op_clientid, cstate->session);

Do you have an actual test case that's failing?

--b.

Quoted 44 lines
---
 fs/nfsd/nfs4state.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
fs/nfsd/nfs4state.c +17 -0
index 693e1458e2ca..d23f4cdbc891 100644
@@ -2826,6 +2826,21 @@ static __be32 nfsd4_check_seqid(struct nfsd4_compound_state *cstate, struct nfs4
 	return nfserr_bad_seqid;
 }
 
+/*
+ * RFC5661: OPEN MUST ignore the client-supplied clientid argument and
+ * substitute the session clientid
+ */
+static void nfsd41_set_open_clientid(struct nfsd4_compound_state *cstate,
+		struct nfsd4_open *open)
+{
+	struct nfs4_client *clp;
+
+	if (!nfsd4_has_session(cstate))
+		return;
+	clp = cstate->session->se_client;
+	memcpy(&open->op_clientid, &clp->cl_clientid, sizeof(open->op_clientid));
+}
+
 __be32
 nfsd4_process_open1(struct nfsd4_compound_state *cstate,
 		    struct nfsd4_open *open, struct nfsd_net *nn)
@@ -2836,6 +2851,8 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate,
 	struct nfs4_openowner *oo = NULL;
 	__be32 status;
 
+	nfsd41_set_open_clientid(cstate, open);
+
 	if (STALE_CLIENTID(&open->op_clientid, nn))
 		return nfserr_stale_clientid;
 	/*
Signature · 1 line
1.8.5.3