xref: /openbmc/linux/include/trace/events/rpcgss.h (revision c4a54f70)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2018 Oracle.  All rights reserved.
4  *
5  * Trace point definitions for the "rpcgss" subsystem.
6  */
7 
8 #undef TRACE_SYSTEM
9 #define TRACE_SYSTEM rpcgss
10 
11 #if !defined(_TRACE_RPCRDMA_H) || defined(TRACE_HEADER_MULTI_READ)
12 #define _TRACE_RPCGSS_H
13 
14 #include <linux/tracepoint.h>
15 
16 /**
17  ** GSS-API related trace events
18  **/
19 
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 
30 TRACE_DEFINE_ENUM(GSS_S_BAD_MECH);
31 TRACE_DEFINE_ENUM(GSS_S_BAD_NAME);
32 TRACE_DEFINE_ENUM(GSS_S_BAD_NAMETYPE);
33 TRACE_DEFINE_ENUM(GSS_S_BAD_BINDINGS);
34 TRACE_DEFINE_ENUM(GSS_S_BAD_STATUS);
35 TRACE_DEFINE_ENUM(GSS_S_BAD_SIG);
36 TRACE_DEFINE_ENUM(GSS_S_NO_CRED);
37 TRACE_DEFINE_ENUM(GSS_S_NO_CONTEXT);
38 TRACE_DEFINE_ENUM(GSS_S_DEFECTIVE_TOKEN);
39 TRACE_DEFINE_ENUM(GSS_S_DEFECTIVE_CREDENTIAL);
40 TRACE_DEFINE_ENUM(GSS_S_CREDENTIALS_EXPIRED);
41 TRACE_DEFINE_ENUM(GSS_S_CONTEXT_EXPIRED);
42 TRACE_DEFINE_ENUM(GSS_S_FAILURE);
43 TRACE_DEFINE_ENUM(GSS_S_BAD_QOP);
44 TRACE_DEFINE_ENUM(GSS_S_UNAUTHORIZED);
45 TRACE_DEFINE_ENUM(GSS_S_UNAVAILABLE);
46 TRACE_DEFINE_ENUM(GSS_S_DUPLICATE_ELEMENT);
47 TRACE_DEFINE_ENUM(GSS_S_NAME_NOT_MN);
48 TRACE_DEFINE_ENUM(GSS_S_CONTINUE_NEEDED);
49 TRACE_DEFINE_ENUM(GSS_S_DUPLICATE_TOKEN);
50 TRACE_DEFINE_ENUM(GSS_S_OLD_TOKEN);
51 TRACE_DEFINE_ENUM(GSS_S_UNSEQ_TOKEN);
52 TRACE_DEFINE_ENUM(GSS_S_GAP_TOKEN);
53 
54 #define show_gss_status(x)						\
55 	__print_flags(x, "|",						\
56 		{ GSS_S_BAD_MECH, "GSS_S_BAD_MECH" },			\
57 		{ GSS_S_BAD_NAME, "GSS_S_BAD_NAME" },			\
58 		{ GSS_S_BAD_NAMETYPE, "GSS_S_BAD_NAMETYPE" },		\
59 		{ GSS_S_BAD_BINDINGS, "GSS_S_BAD_BINDINGS" },		\
60 		{ GSS_S_BAD_STATUS, "GSS_S_BAD_STATUS" },		\
61 		{ GSS_S_BAD_SIG, "GSS_S_BAD_SIG" },			\
62 		{ GSS_S_NO_CRED, "GSS_S_NO_CRED" },			\
63 		{ GSS_S_NO_CONTEXT, "GSS_S_NO_CONTEXT" },		\
64 		{ GSS_S_DEFECTIVE_TOKEN, "GSS_S_DEFECTIVE_TOKEN" },	\
65 		{ GSS_S_DEFECTIVE_CREDENTIAL, "GSS_S_DEFECTIVE_CREDENTIAL" }, \
66 		{ GSS_S_CREDENTIALS_EXPIRED, "GSS_S_CREDENTIALS_EXPIRED" }, \
67 		{ GSS_S_CONTEXT_EXPIRED, "GSS_S_CONTEXT_EXPIRED" },	\
68 		{ GSS_S_FAILURE, "GSS_S_FAILURE" },			\
69 		{ GSS_S_BAD_QOP, "GSS_S_BAD_QOP" },			\
70 		{ GSS_S_UNAUTHORIZED, "GSS_S_UNAUTHORIZED" },		\
71 		{ GSS_S_UNAVAILABLE, "GSS_S_UNAVAILABLE" },		\
72 		{ GSS_S_DUPLICATE_ELEMENT, "GSS_S_DUPLICATE_ELEMENT" },	\
73 		{ GSS_S_NAME_NOT_MN, "GSS_S_NAME_NOT_MN" },		\
74 		{ GSS_S_CONTINUE_NEEDED, "GSS_S_CONTINUE_NEEDED" },	\
75 		{ GSS_S_DUPLICATE_TOKEN, "GSS_S_DUPLICATE_TOKEN" },	\
76 		{ GSS_S_OLD_TOKEN, "GSS_S_OLD_TOKEN" },			\
77 		{ GSS_S_UNSEQ_TOKEN, "GSS_S_UNSEQ_TOKEN" },		\
78 		{ GSS_S_GAP_TOKEN, "GSS_S_GAP_TOKEN" })
79 
80 
81 DECLARE_EVENT_CLASS(rpcgss_gssapi_event,
82 	TP_PROTO(
83 		const struct rpc_task *task,
84 		u32 maj_stat
85 	),
86 
87 	TP_ARGS(task, maj_stat),
88 
89 	TP_STRUCT__entry(
90 		__field(unsigned int, task_id)
91 		__field(unsigned int, client_id)
92 		__field(u32, maj_stat)
93 
94 	),
95 
96 	TP_fast_assign(
97 		__entry->task_id = task->tk_pid;
98 		__entry->client_id = task->tk_client->cl_clid;
99 		__entry->maj_stat = maj_stat;
100 	),
101 
102 	TP_printk("task:%u@%u maj_stat=%s",
103 		__entry->task_id, __entry->client_id,
104 		__entry->maj_stat == 0 ?
105 		"GSS_S_COMPLETE" : show_gss_status(__entry->maj_stat))
106 );
107 
108 #define DEFINE_GSSAPI_EVENT(name)					\
109 	DEFINE_EVENT(rpcgss_gssapi_event, rpcgss_##name,		\
110 			TP_PROTO(					\
111 				const struct rpc_task *task,		\
112 				u32 maj_stat				\
113 			),						\
114 			TP_ARGS(task, maj_stat))
115 
116 TRACE_EVENT(rpcgss_import_ctx,
117 	TP_PROTO(
118 		int status
119 	),
120 
121 	TP_ARGS(status),
122 
123 	TP_STRUCT__entry(
124 		__field(int, status)
125 	),
126 
127 	TP_fast_assign(
128 		__entry->status = status;
129 	),
130 
131 	TP_printk("status=%d", __entry->status)
132 );
133 
134 DEFINE_GSSAPI_EVENT(get_mic);
135 DEFINE_GSSAPI_EVENT(verify_mic);
136 DEFINE_GSSAPI_EVENT(wrap);
137 DEFINE_GSSAPI_EVENT(unwrap);
138 
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 
173 TRACE_EVENT(rpcgss_svc_accept_upcall,
174 	TP_PROTO(
175 		__be32 xid,
176 		u32 major_status,
177 		u32 minor_status
178 	),
179 
180 	TP_ARGS(xid, major_status, minor_status),
181 
182 	TP_STRUCT__entry(
183 		__field(u32, xid)
184 		__field(u32, minor_status)
185 		__field(unsigned long, major_status)
186 	),
187 
188 	TP_fast_assign(
189 		__entry->xid = be32_to_cpu(xid);
190 		__entry->minor_status = minor_status;
191 		__entry->major_status = major_status;
192 	),
193 
194 	TP_printk("xid=0x%08x major_status=%s (0x%08lx) minor_status=%u",
195 		__entry->xid, __entry->major_status == 0 ? "GSS_S_COMPLETE" :
196 				show_gss_status(__entry->major_status),
197 		__entry->major_status, __entry->minor_status
198 	)
199 );
200 
201 TRACE_EVENT(rpcgss_svc_accept,
202 	TP_PROTO(
203 		__be32 xid,
204 		size_t len
205 	),
206 
207 	TP_ARGS(xid, len),
208 
209 	TP_STRUCT__entry(
210 		__field(u32, xid)
211 		__field(size_t, len)
212 	),
213 
214 	TP_fast_assign(
215 		__entry->xid = be32_to_cpu(xid);
216 		__entry->len = len;
217 	),
218 
219 	TP_printk("xid=0x%08x len=%zu",
220 		__entry->xid, __entry->len
221 	)
222 );
223 
224 
225 /**
226  ** GSS auth unwrap failures
227  **/
228 
229 TRACE_EVENT(rpcgss_unwrap_failed,
230 	TP_PROTO(
231 		const struct rpc_task *task
232 	),
233 
234 	TP_ARGS(task),
235 
236 	TP_STRUCT__entry(
237 		__field(unsigned int, task_id)
238 		__field(unsigned int, client_id)
239 	),
240 
241 	TP_fast_assign(
242 		__entry->task_id = task->tk_pid;
243 		__entry->client_id = task->tk_client->cl_clid;
244 	),
245 
246 	TP_printk("task:%u@%u", __entry->task_id, __entry->client_id)
247 );
248 
249 TRACE_EVENT(rpcgss_bad_seqno,
250 	TP_PROTO(
251 		const struct rpc_task *task,
252 		u32 expected,
253 		u32 received
254 	),
255 
256 	TP_ARGS(task, expected, received),
257 
258 	TP_STRUCT__entry(
259 		__field(unsigned int, task_id)
260 		__field(unsigned int, client_id)
261 		__field(u32, expected)
262 		__field(u32, received)
263 	),
264 
265 	TP_fast_assign(
266 		__entry->task_id = task->tk_pid;
267 		__entry->client_id = task->tk_client->cl_clid;
268 		__entry->expected = expected;
269 		__entry->received = received;
270 	),
271 
272 	TP_printk("task:%u@%u expected seqno %u, received seqno %u",
273 		__entry->task_id, __entry->client_id,
274 		__entry->expected, __entry->received)
275 );
276 
277 TRACE_EVENT(rpcgss_seqno,
278 	TP_PROTO(
279 		const struct rpc_task *task
280 	),
281 
282 	TP_ARGS(task),
283 
284 	TP_STRUCT__entry(
285 		__field(unsigned int, task_id)
286 		__field(unsigned int, client_id)
287 		__field(u32, xid)
288 		__field(u32, seqno)
289 	),
290 
291 	TP_fast_assign(
292 		const struct rpc_rqst *rqst = task->tk_rqstp;
293 
294 		__entry->task_id = task->tk_pid;
295 		__entry->client_id = task->tk_client->cl_clid;
296 		__entry->xid = be32_to_cpu(rqst->rq_xid);
297 		__entry->seqno = rqst->rq_seqno;
298 	),
299 
300 	TP_printk("task:%u@%u xid=0x%08x seqno=%u",
301 		__entry->task_id, __entry->client_id,
302 		__entry->xid, __entry->seqno)
303 );
304 
305 TRACE_EVENT(rpcgss_need_reencode,
306 	TP_PROTO(
307 		const struct rpc_task *task,
308 		u32 seq_xmit,
309 		bool ret
310 	),
311 
312 	TP_ARGS(task, seq_xmit, ret),
313 
314 	TP_STRUCT__entry(
315 		__field(unsigned int, task_id)
316 		__field(unsigned int, client_id)
317 		__field(u32, xid)
318 		__field(u32, seq_xmit)
319 		__field(u32, seqno)
320 		__field(bool, ret)
321 	),
322 
323 	TP_fast_assign(
324 		__entry->task_id = task->tk_pid;
325 		__entry->client_id = task->tk_client->cl_clid;
326 		__entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid);
327 		__entry->seq_xmit = seq_xmit;
328 		__entry->seqno = task->tk_rqstp->rq_seqno;
329 		__entry->ret = ret;
330 	),
331 
332 	TP_printk("task:%u@%u xid=0x%08x rq_seqno=%u seq_xmit=%u reencode %sneeded",
333 		__entry->task_id, __entry->client_id,
334 		__entry->xid, __entry->seqno, __entry->seq_xmit,
335 		__entry->ret ? "" : "un")
336 );
337 
338 TRACE_EVENT(rpcgss_update_slack,
339 	TP_PROTO(
340 		const struct rpc_task *task,
341 		const struct rpc_auth *auth
342 	),
343 
344 	TP_ARGS(task, auth),
345 
346 	TP_STRUCT__entry(
347 		__field(unsigned int, task_id)
348 		__field(unsigned int, client_id)
349 		__field(u32, xid)
350 		__field(const void *, auth)
351 		__field(unsigned int, rslack)
352 		__field(unsigned int, ralign)
353 		__field(unsigned int, verfsize)
354 	),
355 
356 	TP_fast_assign(
357 		__entry->task_id = task->tk_pid;
358 		__entry->client_id = task->tk_client->cl_clid;
359 		__entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid);
360 		__entry->auth = auth;
361 		__entry->rslack = auth->au_rslack;
362 		__entry->ralign = auth->au_ralign;
363 		__entry->verfsize = auth->au_verfsize;
364 	),
365 
366 	TP_printk("task:%u@%u xid=0x%08x auth=%p rslack=%u ralign=%u verfsize=%u\n",
367 		__entry->task_id, __entry->client_id, __entry->xid,
368 		__entry->auth, __entry->rslack, __entry->ralign,
369 		__entry->verfsize)
370 );
371 
372 DECLARE_EVENT_CLASS(rpcgss_svc_seqno_class,
373 	TP_PROTO(
374 		__be32 xid,
375 		u32 seqno
376 	),
377 
378 	TP_ARGS(xid, seqno),
379 
380 	TP_STRUCT__entry(
381 		__field(u32, xid)
382 		__field(u32, seqno)
383 	),
384 
385 	TP_fast_assign(
386 		__entry->xid = be32_to_cpu(xid);
387 		__entry->seqno = seqno;
388 	),
389 
390 	TP_printk("xid=0x%08x seqno=%u, request discarded",
391 		__entry->xid, __entry->seqno)
392 );
393 
394 #define DEFINE_SVC_SEQNO_EVENT(name)					\
395 	DEFINE_EVENT(rpcgss_svc_seqno_class, rpcgss_svc_##name,		\
396 			TP_PROTO(					\
397 				__be32 xid,				\
398 				u32 seqno				\
399 			),						\
400 			TP_ARGS(xid, seqno))
401 
402 DEFINE_SVC_SEQNO_EVENT(large_seqno);
403 DEFINE_SVC_SEQNO_EVENT(old_seqno);
404 
405 
406 /**
407  ** gssd upcall related trace events
408  **/
409 
410 TRACE_EVENT(rpcgss_upcall_msg,
411 	TP_PROTO(
412 		const char *buf
413 	),
414 
415 	TP_ARGS(buf),
416 
417 	TP_STRUCT__entry(
418 		__string(msg, buf)
419 	),
420 
421 	TP_fast_assign(
422 		__assign_str(msg, buf)
423 	),
424 
425 	TP_printk("msg='%s'", __get_str(msg))
426 );
427 
428 TRACE_EVENT(rpcgss_upcall_result,
429 	TP_PROTO(
430 		u32 uid,
431 		int result
432 	),
433 
434 	TP_ARGS(uid, result),
435 
436 	TP_STRUCT__entry(
437 		__field(u32, uid)
438 		__field(int, result)
439 
440 	),
441 
442 	TP_fast_assign(
443 		__entry->uid = uid;
444 		__entry->result = result;
445 	),
446 
447 	TP_printk("for uid %u, result=%d", __entry->uid, __entry->result)
448 );
449 
450 TRACE_EVENT(rpcgss_context,
451 	TP_PROTO(
452 		u32 window_size,
453 		unsigned long expiry,
454 		unsigned long now,
455 		unsigned int timeout,
456 		unsigned int len,
457 		const u8 *data
458 	),
459 
460 	TP_ARGS(window_size, expiry, now, timeout, len, data),
461 
462 	TP_STRUCT__entry(
463 		__field(unsigned long, expiry)
464 		__field(unsigned long, now)
465 		__field(unsigned int, timeout)
466 		__field(u32, window_size)
467 		__field(int, len)
468 		__string(acceptor, data)
469 	),
470 
471 	TP_fast_assign(
472 		__entry->expiry = expiry;
473 		__entry->now = now;
474 		__entry->timeout = timeout;
475 		__entry->window_size = window_size;
476 		__entry->len = len;
477 		strncpy(__get_str(acceptor), data, len);
478 	),
479 
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))
483 );
484 
485 
486 /**
487  ** Miscellaneous events
488  */
489 
490 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5);
491 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5I);
492 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5P);
493 
494 #define show_pseudoflavor(x)						\
495 	__print_symbolic(x,						\
496 		{ RPC_AUTH_GSS_KRB5, "RPC_AUTH_GSS_KRB5" },		\
497 		{ RPC_AUTH_GSS_KRB5I, "RPC_AUTH_GSS_KRB5I" },		\
498 		{ RPC_AUTH_GSS_KRB5P, "RPC_AUTH_GSS_KRB5P" })
499 
500 
501 TRACE_EVENT(rpcgss_createauth,
502 	TP_PROTO(
503 		unsigned int flavor,
504 		int error
505 	),
506 
507 	TP_ARGS(flavor, error),
508 
509 	TP_STRUCT__entry(
510 		__field(unsigned int, flavor)
511 		__field(int, error)
512 
513 	),
514 
515 	TP_fast_assign(
516 		__entry->flavor = flavor;
517 		__entry->error = error;
518 	),
519 
520 	TP_printk("flavor=%s error=%d",
521 		show_pseudoflavor(__entry->flavor), __entry->error)
522 );
523 
524 TRACE_EVENT(rpcgss_oid_to_mech,
525 	TP_PROTO(
526 		const char *oid
527 	),
528 
529 	TP_ARGS(oid),
530 
531 	TP_STRUCT__entry(
532 		__string(oid, oid)
533 	),
534 
535 	TP_fast_assign(
536 		__assign_str(oid, oid);
537 	),
538 
539 	TP_printk("mech for oid %s was not found", __get_str(oid))
540 );
541 
542 #endif	/* _TRACE_RPCGSS_H */
543 
544 #include <trace/define_trace.h>
545