linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org
Cc: dwysocha@redhat.com, bfields@fieldses.org, rostedt@goodmis.org
Subject: [PATCH v2 03/25] NFSD: Add nfsd_clid_cred_mismatch tracepoint
Date: Wed, 12 May 2021 11:35:15 -0400	[thread overview]
Message-ID: <162083371563.3108.13309642693256783022.stgit@klimt.1015granger.net> (raw)
In-Reply-To: <162083366966.3108.12581818416105328952.stgit@klimt.1015granger.net>

Record when a client tries to establish a lease record but uses an
unexpected credential. This is often a sign of a configuration
problem.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfsd/nfs4state.c |   14 ++++++++++----
 fs/nfsd/trace.h     |   28 ++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 6abe48dee6ed..84c4021b3826 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3181,6 +3181,7 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 		if (!creds_match) { /* case 3 */
 			if (client_has_state(conf)) {
 				status = nfserr_clid_inuse;
+				trace_nfsd_clid_cred_mismatch(conf, rqstp);
 				goto out;
 			}
 			goto out_new;
@@ -3425,9 +3426,10 @@ nfsd4_create_session(struct svc_rqst *rqstp,
 			goto out_free_conn;
 		}
 	} else if (unconf) {
+		status = nfserr_clid_inuse;
 		if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred) ||
 		    !rpc_cmp_addr(sa, (struct sockaddr *) &unconf->cl_addr)) {
-			status = nfserr_clid_inuse;
+			trace_nfsd_clid_cred_mismatch(unconf, rqstp);
 			goto out_free_conn;
 		}
 		status = nfserr_wrong_cred;
@@ -3976,7 +3978,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 		if (clp_used_exchangeid(conf))
 			goto out;
 		if (!same_creds(&conf->cl_cred, &rqstp->rq_cred)) {
-			trace_nfsd_clid_inuse_err(conf);
+			trace_nfsd_clid_cred_mismatch(conf, rqstp);
 			goto out;
 		}
 	}
@@ -4034,10 +4036,14 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
 	 * Nevertheless, RFC 7530 recommends INUSE for this case:
 	 */
 	status = nfserr_clid_inuse;
-	if (unconf && !same_creds(&unconf->cl_cred, &rqstp->rq_cred))
+	if (unconf && !same_creds(&unconf->cl_cred, &rqstp->rq_cred)) {
+		trace_nfsd_clid_cred_mismatch(unconf, rqstp);
 		goto out;
-	if (conf && !same_creds(&conf->cl_cred, &rqstp->rq_cred))
+	}
+	if (conf && !same_creds(&conf->cl_cred, &rqstp->rq_cred)) {
+		trace_nfsd_clid_cred_mismatch(conf, rqstp);
 		goto out;
+	}
 	/* cases below refer to rfc 3530 section 14.2.34: */
 	if (!unconf || !same_verf(&confirm, &unconf->cl_confirm)) {
 		if (conf && same_verf(&confirm, &conf->cl_confirm)) {
diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
index f0ee18202de0..25ed99220c7b 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -534,6 +534,34 @@ DEFINE_EVENT(nfsd_net_class, nfsd_##name, \
 DEFINE_NET_EVENT(grace_start);
 DEFINE_NET_EVENT(grace_complete);
 
+TRACE_EVENT(nfsd_clid_cred_mismatch,
+	TP_PROTO(
+		const struct nfs4_client *clp,
+		const struct svc_rqst *rqstp
+	),
+	TP_ARGS(clp, rqstp),
+	TP_STRUCT__entry(
+		__field(u32, cl_boot)
+		__field(u32, cl_id)
+		__field(unsigned long, cl_flavor)
+		__field(unsigned long, new_flavor)
+		__array(unsigned char, addr, sizeof(struct sockaddr_in6))
+	),
+	TP_fast_assign(
+		__entry->cl_boot = clp->cl_clientid.cl_boot;
+		__entry->cl_id = clp->cl_clientid.cl_id;
+		__entry->cl_flavor = clp->cl_cred.cr_flavor;
+		__entry->new_flavor = rqstp->rq_cred.cr_flavor;
+		memcpy(__entry->addr, &rqstp->rq_xprt->xpt_remote,
+			sizeof(struct sockaddr_in6));
+	),
+	TP_printk("client %08x:%08x flavor=%s, conflict=%s from addr=%pISpc",
+		__entry->cl_boot, __entry->cl_id,
+		show_nfsd_authflavor(__entry->cl_flavor),
+		show_nfsd_authflavor(__entry->new_flavor), __entry->addr
+	)
+)
+
 TRACE_EVENT(nfsd_clid_inuse_err,
 	TP_PROTO(const struct nfs4_client *clp),
 	TP_ARGS(clp),



  parent reply	other threads:[~2021-05-12 16:31 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 15:34 [PATCH v2 00/25] NFSD callback and lease management observability Chuck Lever
2021-05-12 15:35 ` [PATCH v2 01/25] NFSD: Fix TP_printk() format specifier in trace_nfsd_dirent() Chuck Lever
2021-05-12 16:26   ` Steven Rostedt
2021-05-12 16:52     ` Chuck Lever III
2021-05-13 14:50       ` Steven Rostedt
2021-05-13 14:53         ` Chuck Lever III
2021-05-13 15:02           ` Steven Rostedt
2021-05-13 15:10         ` Chuck Lever III
2021-05-13 18:43           ` Chuck Lever III
2021-05-13 19:00             ` Steven Rostedt
2021-05-13 19:08               ` Chuck Lever III
2021-05-13 19:17                 ` Steven Rostedt
2021-05-13 20:01                   ` Chuck Lever III
2021-07-12 15:18         ` Chuck Lever III
2021-07-12 17:09           ` Steven Rostedt
2021-05-12 16:53     ` Steven Rostedt
2021-05-12 15:35 ` [PATCH v2 02/25] NFSD: Fix TP_printk() format specifier in nfsd_clid_class Chuck Lever
2021-05-12 15:35 ` Chuck Lever [this message]
2021-05-12 15:35 ` [PATCH v2 04/25] NFSD: Add nfsd_clid_verf_mismatch tracepoint Chuck Lever
2021-05-12 15:35 ` [PATCH v2 05/25] NFSD: Remove trace_nfsd_clid_inuse_err Chuck Lever
2021-05-12 15:35 ` [PATCH v2 06/25] NFSD: Add nfsd_clid_confirmed tracepoint Chuck Lever
2021-05-12 15:35 ` [PATCH v2 07/25] NFSD: Add nfsd_clid_reclaim_complete tracepoint Chuck Lever
2021-05-12 15:35 ` [PATCH v2 08/25] NFSD: Add nfsd_clid_destroyed tracepoint Chuck Lever
2021-05-12 15:35 ` [PATCH v2 09/25] NFSD: Add a couple more nfsd_clid_expired call sites Chuck Lever
2021-05-13 16:42   ` David Wysochanski
2021-05-13 17:05     ` Chuck Lever III
2021-05-12 15:36 ` [PATCH v2 10/25] NFSD: Add an RPC authflavor tracepoint display helper Chuck Lever
2021-05-12 15:36 ` [PATCH v2 11/25] NFSD: Add tracepoints for SETCLIENTID edge cases Chuck Lever
2021-05-12 15:36 ` [PATCH v2 12/25] NFSD: Add tracepoints for EXCHANGEID " Chuck Lever
2021-05-12 15:36 ` [PATCH v2 13/25] NFSD: Constify @fh argument of knfsd_fh_hash() Chuck Lever
2021-05-12 15:36 ` [PATCH v2 14/25] NFSD: Capture every CB state transition Chuck Lever
2021-05-12 15:36 ` [PATCH v2 15/25] NFSD: Drop TRACE_DEFINE_ENUM for NFSD4_CB_<state> macros Chuck Lever
2021-05-12 15:36 ` [PATCH v2 16/25] NFSD: Add cb_lost tracepoint Chuck Lever
2021-05-12 15:36 ` [PATCH v2 17/25] NFSD: Adjust cb_shutdown tracepoint Chuck Lever
2021-05-12 15:36 ` [PATCH v2 18/25] NFSD: Remove spurious cb_setup_err tracepoint Chuck Lever
2021-05-12 15:37 ` [PATCH v2 19/25] NFSD: Enhance the nfsd_cb_setup tracepoint Chuck Lever
2021-05-12 15:37 ` [PATCH v2 20/25] NFSD: Add an nfsd_cb_lm_notify tracepoint Chuck Lever
2021-05-12 15:37 ` [PATCH v2 21/25] NFSD: Add an nfsd_cb_offload tracepoint Chuck Lever
2021-05-12 15:37 ` [PATCH v2 22/25] NFSD: Replace the nfsd_deleg_break tracepoint Chuck Lever
2021-05-12 15:37 ` [PATCH v2 23/25] NFSD: Add an nfsd_cb_probe tracepoint Chuck Lever
2021-05-12 15:37 ` [PATCH v2 24/25] NFSD: Remove the nfsd_cb_work and nfsd_cb_done tracepoints Chuck Lever
2021-05-12 15:37 ` [PATCH v2 25/25] NFSD: Update nfsd_cb_args tracepoint Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=162083371563.3108.13309642693256783022.stgit@klimt.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=bfields@fieldses.org \
    --cc=dwysocha@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).