Skip to content

Commit ff27e9f

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
SUNRPC: Trace gssproxy upcall results
Record results of a GSS proxy ACCEPT_SEC_CONTEXT upcall and the svc_authenticate() function to make field debugging of NFS server Kerberos issues easier. Signed-off-by: Chuck Lever <[email protected]> Reviewed-by: Bill Baker <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 5fcaf69 commit ff27e9f

File tree

6 files changed

+112
-4
lines changed

6 files changed

+112
-4
lines changed

include/trace/events/rpcgss.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,34 @@ DEFINE_GSSAPI_EVENT(verify_mic);
126126
DEFINE_GSSAPI_EVENT(wrap);
127127
DEFINE_GSSAPI_EVENT(unwrap);
128128

129+
TRACE_EVENT(rpcgss_accept_upcall,
130+
TP_PROTO(
131+
__be32 xid,
132+
u32 major_status,
133+
u32 minor_status
134+
),
135+
136+
TP_ARGS(xid, major_status, minor_status),
137+
138+
TP_STRUCT__entry(
139+
__field(u32, xid)
140+
__field(u32, minor_status)
141+
__field(unsigned long, major_status)
142+
),
143+
144+
TP_fast_assign(
145+
__entry->xid = be32_to_cpu(xid);
146+
__entry->minor_status = minor_status;
147+
__entry->major_status = major_status;
148+
),
149+
150+
TP_printk("xid=0x%08x major_status=%s (0x%08lx) minor_status=%u",
151+
__entry->xid, __entry->major_status == 0 ? "GSS_S_COMPLETE" :
152+
show_gss_status(__entry->major_status),
153+
__entry->major_status, __entry->minor_status
154+
)
155+
);
156+
129157

130158
/**
131159
** GSS auth unwrap failures
@@ -355,6 +383,23 @@ TRACE_EVENT(rpcgss_createauth,
355383
show_pseudoflavor(__entry->flavor), __entry->error)
356384
);
357385

386+
TRACE_EVENT(rpcgss_oid_to_mech,
387+
TP_PROTO(
388+
const char *oid
389+
),
390+
391+
TP_ARGS(oid),
392+
393+
TP_STRUCT__entry(
394+
__string(oid, oid)
395+
),
396+
397+
TP_fast_assign(
398+
__assign_str(oid, oid);
399+
),
400+
401+
TP_printk("mech for oid %s was not found", __get_str(oid))
402+
);
358403

359404
#endif /* _TRACE_RPCGSS_H */
360405

include/trace/events/sunrpc.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,26 @@
1414
#include <linux/net.h>
1515
#include <linux/tracepoint.h>
1616

17+
TRACE_DEFINE_ENUM(RPC_AUTH_OK);
18+
TRACE_DEFINE_ENUM(RPC_AUTH_BADCRED);
19+
TRACE_DEFINE_ENUM(RPC_AUTH_REJECTEDCRED);
20+
TRACE_DEFINE_ENUM(RPC_AUTH_BADVERF);
21+
TRACE_DEFINE_ENUM(RPC_AUTH_REJECTEDVERF);
22+
TRACE_DEFINE_ENUM(RPC_AUTH_TOOWEAK);
23+
TRACE_DEFINE_ENUM(RPCSEC_GSS_CREDPROBLEM);
24+
TRACE_DEFINE_ENUM(RPCSEC_GSS_CTXPROBLEM);
25+
26+
#define rpc_show_auth_stat(status) \
27+
__print_symbolic(status, \
28+
{ RPC_AUTH_OK, "AUTH_OK" }, \
29+
{ RPC_AUTH_BADCRED, "BADCRED" }, \
30+
{ RPC_AUTH_REJECTEDCRED, "REJECTEDCRED" }, \
31+
{ RPC_AUTH_BADVERF, "BADVERF" }, \
32+
{ RPC_AUTH_REJECTEDVERF, "REJECTEDVERF" }, \
33+
{ RPC_AUTH_TOOWEAK, "TOOWEAK" }, \
34+
{ RPCSEC_GSS_CREDPROBLEM, "GSS_CREDPROBLEM" }, \
35+
{ RPCSEC_GSS_CTXPROBLEM, "GSS_CTXPROBLEM" }) \
36+
1737
DECLARE_EVENT_CLASS(rpc_task_status,
1838

1939
TP_PROTO(const struct rpc_task *task),
@@ -866,6 +886,41 @@ TRACE_EVENT(svc_recv,
866886
show_rqstp_flags(__entry->flags))
867887
);
868888

889+
#define svc_show_status(status) \
890+
__print_symbolic(status, \
891+
{ SVC_GARBAGE, "SVC_GARBAGE" }, \
892+
{ SVC_SYSERR, "SVC_SYSERR" }, \
893+
{ SVC_VALID, "SVC_VALID" }, \
894+
{ SVC_NEGATIVE, "SVC_NEGATIVE" }, \
895+
{ SVC_OK, "SVC_OK" }, \
896+
{ SVC_DROP, "SVC_DROP" }, \
897+
{ SVC_CLOSE, "SVC_CLOSE" }, \
898+
{ SVC_DENIED, "SVC_DENIED" }, \
899+
{ SVC_PENDING, "SVC_PENDING" }, \
900+
{ SVC_COMPLETE, "SVC_COMPLETE" })
901+
902+
TRACE_EVENT(svc_authenticate,
903+
TP_PROTO(const struct svc_rqst *rqst, int auth_res, __be32 auth_stat),
904+
905+
TP_ARGS(rqst, auth_res, auth_stat),
906+
907+
TP_STRUCT__entry(
908+
__field(u32, xid)
909+
__field(unsigned long, svc_status)
910+
__field(unsigned long, auth_stat)
911+
),
912+
913+
TP_fast_assign(
914+
__entry->xid = be32_to_cpu(rqst->rq_xid);
915+
__entry->svc_status = auth_res;
916+
__entry->auth_stat = be32_to_cpu(auth_stat);
917+
),
918+
919+
TP_printk("xid=0x%08x auth_res=%s auth_stat=%s",
920+
__entry->xid, svc_show_status(__entry->svc_status),
921+
rpc_show_auth_stat(__entry->auth_stat))
922+
);
923+
869924
TRACE_EVENT(svc_process,
870925
TP_PROTO(const struct svc_rqst *rqst, const char *name),
871926

net/sunrpc/auth_gss/gss_mech_switch.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/sunrpc/sched.h>
2121
#include <linux/sunrpc/gss_api.h>
2222
#include <linux/sunrpc/clnt.h>
23+
#include <trace/events/rpcgss.h>
2324

2425
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
2526
# define RPCDBG_FACILITY RPCDBG_AUTH
@@ -158,7 +159,6 @@ struct gss_api_mech *gss_mech_get_by_OID(struct rpcsec_gss_oid *obj)
158159

159160
if (sprint_oid(obj->data, obj->len, buf, sizeof(buf)) < 0)
160161
return NULL;
161-
dprintk("RPC: %s(%s)\n", __func__, buf);
162162
request_module("rpc-auth-gss-%s", buf);
163163

164164
rcu_read_lock();
@@ -172,6 +172,8 @@ struct gss_api_mech *gss_mech_get_by_OID(struct rpcsec_gss_oid *obj)
172172
}
173173
}
174174
rcu_read_unlock();
175+
if (!gm)
176+
trace_rpcgss_oid_to_mech(buf);
175177
return gm;
176178
}
177179

net/sunrpc/auth_gss/svcauth_gss.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
#include <linux/sunrpc/svcauth.h>
5050
#include <linux/sunrpc/svcauth_gss.h>
5151
#include <linux/sunrpc/cache.h>
52+
53+
#include <trace/events/rpcgss.h>
54+
5255
#include "gss_rpc_upcall.h"
5356

5457

@@ -1270,9 +1273,8 @@ static int svcauth_gss_proxy_init(struct svc_rqst *rqstp,
12701273
if (status)
12711274
goto out;
12721275

1273-
dprintk("RPC: svcauth_gss: gss major status = %d "
1274-
"minor status = %d\n",
1275-
ud.major_status, ud.minor_status);
1276+
trace_rpcgss_accept_upcall(rqstp->rq_xid, ud.major_status,
1277+
ud.minor_status);
12761278

12771279
switch (ud.major_status) {
12781280
case GSS_S_CONTINUE_NEEDED:

net/sunrpc/svc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,8 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
13371337
auth_stat = rpc_autherr_badcred;
13381338
auth_res = progp->pg_authenticate(rqstp);
13391339
}
1340+
if (auth_res != SVC_OK)
1341+
trace_svc_authenticate(rqstp, auth_res, auth_stat);
13401342
switch (auth_res) {
13411343
case SVC_OK:
13421344
break;

net/sunrpc/svcauth.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <linux/err.h>
2020
#include <linux/hash.h>
2121

22+
#include <trace/events/sunrpc.h>
23+
2224
#define RPCDBG_FACILITY RPCDBG_AUTH
2325

2426

0 commit comments

Comments
 (0)