Commit 79123444 authored by J. Bruce Fields's avatar J. Bruce Fields

nfsd: decode implementation id

Decode the implementation ID and display in nfsd/clients/#/info.  It may
be help identify the client.  It won't be used otherwise.

(When this went into the protocol, I thought the implementation ID would
be a slippery slope towards implementation-specific workarounds as with
the http user-agent.  But I guess I was wrong, the risk seems pretty low
now.)
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 6f4859b8
...@@ -1899,6 +1899,8 @@ static void __free_client(struct kref *k) ...@@ -1899,6 +1899,8 @@ static void __free_client(struct kref *k)
free_svc_cred(&clp->cl_cred); free_svc_cred(&clp->cl_cred);
kfree(clp->cl_ownerstr_hashtbl); kfree(clp->cl_ownerstr_hashtbl);
kfree(clp->cl_name.data); kfree(clp->cl_name.data);
kfree(clp->cl_nii_domain.data);
kfree(clp->cl_nii_name.data);
idr_destroy(&clp->cl_stateids); idr_destroy(&clp->cl_stateids);
kmem_cache_free(client_slab, clp); kmem_cache_free(client_slab, clp);
} }
...@@ -2261,6 +2263,15 @@ static int client_info_show(struct seq_file *m, void *v) ...@@ -2261,6 +2263,15 @@ static int client_info_show(struct seq_file *m, void *v)
seq_printf(m, "name: "); seq_printf(m, "name: ");
seq_quote_mem(m, clp->cl_name.data, clp->cl_name.len); seq_quote_mem(m, clp->cl_name.data, clp->cl_name.len);
seq_printf(m, "\nminor version: %d\n", clp->cl_minorversion); seq_printf(m, "\nminor version: %d\n", clp->cl_minorversion);
if (clp->cl_nii_domain.data) {
seq_printf(m, "Implementation domain: ");
seq_quote_mem(m, clp->cl_nii_domain.data,
clp->cl_nii_domain.len);
seq_printf(m, "\nImplementation name: ");
seq_quote_mem(m, clp->cl_nii_name.data, clp->cl_nii_name.len);
seq_printf(m, "\nImplementation time: [%ld, %ld]\n",
clp->cl_nii_time.tv_sec, clp->cl_nii_time.tv_nsec);
}
drop_client(clp); drop_client(clp);
return 0; return 0;
...@@ -2901,6 +2912,22 @@ static bool client_has_state(struct nfs4_client *clp) ...@@ -2901,6 +2912,22 @@ static bool client_has_state(struct nfs4_client *clp)
|| !list_empty(&clp->async_copies); || !list_empty(&clp->async_copies);
} }
static __be32 copy_impl_id(struct nfs4_client *clp,
struct nfsd4_exchange_id *exid)
{
if (!exid->nii_domain.data)
return 0;
xdr_netobj_dup(&clp->cl_nii_domain, &exid->nii_domain, GFP_KERNEL);
if (!clp->cl_nii_domain.data)
return nfserr_jukebox;
xdr_netobj_dup(&clp->cl_nii_name, &exid->nii_name, GFP_KERNEL);
if (!clp->cl_nii_name.data)
return nfserr_jukebox;
clp->cl_nii_time.tv_sec = exid->nii_time.tv_sec;
clp->cl_nii_time.tv_nsec = exid->nii_time.tv_nsec;
return 0;
}
__be32 __be32
nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
union nfsd4_op_u *u) union nfsd4_op_u *u)
...@@ -2927,6 +2954,9 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -2927,6 +2954,9 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
new = create_client(exid->clname, rqstp, &verf); new = create_client(exid->clname, rqstp, &verf);
if (new == NULL) if (new == NULL)
return nfserr_jukebox; return nfserr_jukebox;
status = copy_impl_id(new, exid);
if (status)
goto out_nolock;
switch (exid->spa_how) { switch (exid->spa_how) {
case SP4_MACH_CRED: case SP4_MACH_CRED:
......
...@@ -1389,7 +1389,6 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, ...@@ -1389,7 +1389,6 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp,
goto xdr_error; goto xdr_error;
} }
/* Ignore Implementation ID */
READ_BUF(4); /* nfs_impl_id4 array length */ READ_BUF(4); /* nfs_impl_id4 array length */
dummy = be32_to_cpup(p++); dummy = be32_to_cpup(p++);
...@@ -1397,21 +1396,19 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, ...@@ -1397,21 +1396,19 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp,
goto xdr_error; goto xdr_error;
if (dummy == 1) { if (dummy == 1) {
/* nii_domain */ status = nfsd4_decode_opaque(argp, &exid->nii_domain);
READ_BUF(4); if (status)
dummy = be32_to_cpup(p++); goto xdr_error;
READ_BUF(dummy);
p += XDR_QUADLEN(dummy);
/* nii_name */ /* nii_name */
READ_BUF(4); status = nfsd4_decode_opaque(argp, &exid->nii_name);
dummy = be32_to_cpup(p++); if (status)
READ_BUF(dummy); goto xdr_error;
p += XDR_QUADLEN(dummy);
/* nii_date */ /* nii_date */
READ_BUF(12); status = nfsd4_decode_time(argp, &exid->nii_time);
p += 3; if (status)
goto xdr_error;
} }
DECODE_TAIL; DECODE_TAIL;
} }
......
...@@ -317,6 +317,10 @@ struct nfs4_client { ...@@ -317,6 +317,10 @@ struct nfs4_client {
clientid_t cl_clientid; /* generated by server */ clientid_t cl_clientid; /* generated by server */
nfs4_verifier cl_confirm; /* generated by server */ nfs4_verifier cl_confirm; /* generated by server */
u32 cl_minorversion; u32 cl_minorversion;
/* NFSv4.1 client implementation id: */
struct xdr_netobj cl_nii_domain;
struct xdr_netobj cl_nii_name;
struct timespec cl_nii_time;
/* for v4.0 and v4.1 callbacks: */ /* for v4.0 and v4.1 callbacks: */
struct nfs4_cb_conn cl_cb_conn; struct nfs4_cb_conn cl_cb_conn;
......
...@@ -410,6 +410,9 @@ struct nfsd4_exchange_id { ...@@ -410,6 +410,9 @@ struct nfsd4_exchange_id {
int spa_how; int spa_how;
u32 spo_must_enforce[3]; u32 spo_must_enforce[3];
u32 spo_must_allow[3]; u32 spo_must_allow[3];
struct xdr_netobj nii_domain;
struct xdr_netobj nii_name;
struct timespec64 nii_time;
}; };
struct nfsd4_sequence { struct nfsd4_sequence {
......
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