Skip to content

Commit 74fb8fe

Browse files
chuckleveramschuma-ntap
authored andcommitted
SUNRPC: Trace GSS context lifetimes
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 53bc19f commit 74fb8fe

3 files changed

Lines changed: 58 additions & 8 deletions

File tree

‎include/trace/events/rpcgss.h‎

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
** GSS-API related trace events
1818
**/
1919

20+
TRACE_DEFINE_ENUM(RPC_GSS_SVC_NONE);
21+
TRACE_DEFINE_ENUM(RPC_GSS_SVC_INTEGRITY);
22+
TRACE_DEFINE_ENUM(RPC_GSS_SVC_PRIVACY);
23+
24+
#define show_gss_service(x) \
25+
__print_symbolic(x, \
26+
{ RPC_GSS_SVC_NONE, "none" }, \
27+
{ RPC_GSS_SVC_INTEGRITY, "integrity" }, \
28+
{ RPC_GSS_SVC_PRIVACY, "privacy" })
29+
2030
TRACE_DEFINE_ENUM(GSS_S_BAD_MECH);
2131
TRACE_DEFINE_ENUM(GSS_S_BAD_NAME);
2232
TRACE_DEFINE_ENUM(GSS_S_BAD_NAMETYPE);
@@ -126,6 +136,40 @@ DEFINE_GSSAPI_EVENT(verify_mic);
126136
DEFINE_GSSAPI_EVENT(wrap);
127137
DEFINE_GSSAPI_EVENT(unwrap);
128138

139+
DECLARE_EVENT_CLASS(rpcgss_ctx_class,
140+
TP_PROTO(
141+
const struct gss_cred *gc
142+
),
143+
144+
TP_ARGS(gc),
145+
146+
TP_STRUCT__entry(
147+
__field(const void *, cred)
148+
__field(unsigned long, service)
149+
__string(principal, gc->gc_principal)
150+
),
151+
152+
TP_fast_assign(
153+
__entry->cred = gc;
154+
__entry->service = gc->gc_service;
155+
__assign_str(principal, gc->gc_principal)
156+
),
157+
158+
TP_printk("cred=%p service=%s principal='%s'",
159+
__entry->cred, show_gss_service(__entry->service),
160+
__get_str(principal))
161+
);
162+
163+
#define DEFINE_CTX_EVENT(name) \
164+
DEFINE_EVENT(rpcgss_ctx_class, rpcgss_ctx_##name, \
165+
TP_PROTO( \
166+
const struct gss_cred *gc \
167+
), \
168+
TP_ARGS(gc))
169+
170+
DEFINE_CTX_EVENT(init);
171+
DEFINE_CTX_EVENT(destroy);
172+
129173
TRACE_EVENT(rpcgss_svc_accept_upcall,
130174
TP_PROTO(
131175
__be32 xid,
@@ -405,19 +449,21 @@ TRACE_EVENT(rpcgss_upcall_result,
405449

406450
TRACE_EVENT(rpcgss_context,
407451
TP_PROTO(
452+
u32 window_size,
408453
unsigned long expiry,
409454
unsigned long now,
410455
unsigned int timeout,
411456
unsigned int len,
412457
const u8 *data
413458
),
414459

415-
TP_ARGS(expiry, now, timeout, len, data),
460+
TP_ARGS(window_size, expiry, now, timeout, len, data),
416461

417462
TP_STRUCT__entry(
418463
__field(unsigned long, expiry)
419464
__field(unsigned long, now)
420465
__field(unsigned int, timeout)
466+
__field(u32, window_size)
421467
__field(int, len)
422468
__string(acceptor, data)
423469
),
@@ -426,13 +472,14 @@ TRACE_EVENT(rpcgss_context,
426472
__entry->expiry = expiry;
427473
__entry->now = now;
428474
__entry->timeout = timeout;
475+
__entry->window_size = window_size;
429476
__entry->len = len;
430477
strncpy(__get_str(acceptor), data, len);
431478
),
432479

433-
TP_printk("gc_expiry=%lu now=%lu timeout=%u acceptor=%.*s",
434-
__entry->expiry, __entry->now, __entry->timeout,
435-
__entry->len, __get_str(acceptor))
480+
TP_printk("win_size=%u expiry=%lu now=%lu timeout=%u acceptor=%.*s",
481+
__entry->window_size, __entry->expiry, __entry->now,
482+
__entry->timeout, __entry->len, __get_str(acceptor))
436483
);
437484

438485

‎net/sunrpc/auth_gss/auth_gss.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ gss_fill_context(const void *p, const void *end, struct gss_cl_ctx *ctx, struct
254254
if (IS_ERR(p))
255255
goto err;
256256
done:
257-
trace_rpcgss_context(ctx->gc_expiry, now, timeout,
257+
trace_rpcgss_context(window_size, ctx->gc_expiry, now, timeout,
258258
ctx->gc_acceptor.len, ctx->gc_acceptor.data);
259259
err:
260260
return p;
@@ -697,10 +697,12 @@ gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred)
697697
}
698698
schedule();
699699
}
700-
if (gss_msg->ctx)
700+
if (gss_msg->ctx) {
701+
trace_rpcgss_ctx_init(gss_cred);
701702
gss_cred_set_ctx(cred, gss_msg->ctx);
702-
else
703+
} else {
703704
err = gss_msg->msg.errno;
705+
}
704706
spin_unlock(&pipe->lock);
705707
out_intr:
706708
finish_wait(&gss_msg->waitqueue, &wait);
@@ -1284,6 +1286,7 @@ gss_send_destroy_context(struct rpc_cred *cred)
12841286
if (new) {
12851287
ctx->gc_proc = RPC_GSS_PROC_DESTROY;
12861288

1289+
trace_rpcgss_ctx_destroy(gss_cred);
12871290
task = rpc_call_null(gss_auth->client, &new->gc_base,
12881291
RPC_TASK_ASYNC|RPC_TASK_SOFT);
12891292
if (!IS_ERR(task))
@@ -1349,7 +1352,6 @@ gss_destroy_nullcred(struct rpc_cred *cred)
13491352
static void
13501353
gss_destroy_cred(struct rpc_cred *cred)
13511354
{
1352-
13531355
if (test_and_clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0)
13541356
gss_send_destroy_context(cred);
13551357
gss_destroy_nullcred(cred);

‎net/sunrpc/auth_gss/trace.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/sunrpc/clnt.h>
77
#include <linux/sunrpc/sched.h>
88
#include <linux/sunrpc/gss_err.h>
9+
#include <linux/sunrpc/auth_gss.h>
910

1011
#define CREATE_TRACE_POINTS
1112
#include <trace/events/rpcgss.h>

0 commit comments

Comments
 (0)