xref: /openbmc/linux/include/trace/events/rpcgss.h (revision 15e3ae36)
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(GSS_S_BAD_MECH);
21 TRACE_DEFINE_ENUM(GSS_S_BAD_NAME);
22 TRACE_DEFINE_ENUM(GSS_S_BAD_NAMETYPE);
23 TRACE_DEFINE_ENUM(GSS_S_BAD_BINDINGS);
24 TRACE_DEFINE_ENUM(GSS_S_BAD_STATUS);
25 TRACE_DEFINE_ENUM(GSS_S_BAD_SIG);
26 TRACE_DEFINE_ENUM(GSS_S_NO_CRED);
27 TRACE_DEFINE_ENUM(GSS_S_NO_CONTEXT);
28 TRACE_DEFINE_ENUM(GSS_S_DEFECTIVE_TOKEN);
29 TRACE_DEFINE_ENUM(GSS_S_DEFECTIVE_CREDENTIAL);
30 TRACE_DEFINE_ENUM(GSS_S_CREDENTIALS_EXPIRED);
31 TRACE_DEFINE_ENUM(GSS_S_CONTEXT_EXPIRED);
32 TRACE_DEFINE_ENUM(GSS_S_FAILURE);
33 TRACE_DEFINE_ENUM(GSS_S_BAD_QOP);
34 TRACE_DEFINE_ENUM(GSS_S_UNAUTHORIZED);
35 TRACE_DEFINE_ENUM(GSS_S_UNAVAILABLE);
36 TRACE_DEFINE_ENUM(GSS_S_DUPLICATE_ELEMENT);
37 TRACE_DEFINE_ENUM(GSS_S_NAME_NOT_MN);
38 TRACE_DEFINE_ENUM(GSS_S_CONTINUE_NEEDED);
39 TRACE_DEFINE_ENUM(GSS_S_DUPLICATE_TOKEN);
40 TRACE_DEFINE_ENUM(GSS_S_OLD_TOKEN);
41 TRACE_DEFINE_ENUM(GSS_S_UNSEQ_TOKEN);
42 TRACE_DEFINE_ENUM(GSS_S_GAP_TOKEN);
43 
44 #define show_gss_status(x)						\
45 	__print_flags(x, "|",						\
46 		{ GSS_S_BAD_MECH, "GSS_S_BAD_MECH" },			\
47 		{ GSS_S_BAD_NAME, "GSS_S_BAD_NAME" },			\
48 		{ GSS_S_BAD_NAMETYPE, "GSS_S_BAD_NAMETYPE" },		\
49 		{ GSS_S_BAD_BINDINGS, "GSS_S_BAD_BINDINGS" },		\
50 		{ GSS_S_BAD_STATUS, "GSS_S_BAD_STATUS" },		\
51 		{ GSS_S_BAD_SIG, "GSS_S_BAD_SIG" },			\
52 		{ GSS_S_NO_CRED, "GSS_S_NO_CRED" },			\
53 		{ GSS_S_NO_CONTEXT, "GSS_S_NO_CONTEXT" },		\
54 		{ GSS_S_DEFECTIVE_TOKEN, "GSS_S_DEFECTIVE_TOKEN" },	\
55 		{ GSS_S_DEFECTIVE_CREDENTIAL, "GSS_S_DEFECTIVE_CREDENTIAL" }, \
56 		{ GSS_S_CREDENTIALS_EXPIRED, "GSS_S_CREDENTIALS_EXPIRED" }, \
57 		{ GSS_S_CONTEXT_EXPIRED, "GSS_S_CONTEXT_EXPIRED" },	\
58 		{ GSS_S_FAILURE, "GSS_S_FAILURE" },			\
59 		{ GSS_S_BAD_QOP, "GSS_S_BAD_QOP" },			\
60 		{ GSS_S_UNAUTHORIZED, "GSS_S_UNAUTHORIZED" },		\
61 		{ GSS_S_UNAVAILABLE, "GSS_S_UNAVAILABLE" },		\
62 		{ GSS_S_DUPLICATE_ELEMENT, "GSS_S_DUPLICATE_ELEMENT" },	\
63 		{ GSS_S_NAME_NOT_MN, "GSS_S_NAME_NOT_MN" },		\
64 		{ GSS_S_CONTINUE_NEEDED, "GSS_S_CONTINUE_NEEDED" },	\
65 		{ GSS_S_DUPLICATE_TOKEN, "GSS_S_DUPLICATE_TOKEN" },	\
66 		{ GSS_S_OLD_TOKEN, "GSS_S_OLD_TOKEN" },			\
67 		{ GSS_S_UNSEQ_TOKEN, "GSS_S_UNSEQ_TOKEN" },		\
68 		{ GSS_S_GAP_TOKEN, "GSS_S_GAP_TOKEN" })
69 
70 
71 DECLARE_EVENT_CLASS(rpcgss_gssapi_event,
72 	TP_PROTO(
73 		const struct rpc_task *task,
74 		u32 maj_stat
75 	),
76 
77 	TP_ARGS(task, maj_stat),
78 
79 	TP_STRUCT__entry(
80 		__field(unsigned int, task_id)
81 		__field(unsigned int, client_id)
82 		__field(u32, maj_stat)
83 
84 	),
85 
86 	TP_fast_assign(
87 		__entry->task_id = task->tk_pid;
88 		__entry->client_id = task->tk_client->cl_clid;
89 		__entry->maj_stat = maj_stat;
90 	),
91 
92 	TP_printk("task:%u@%u maj_stat=%s",
93 		__entry->task_id, __entry->client_id,
94 		__entry->maj_stat == 0 ?
95 		"GSS_S_COMPLETE" : show_gss_status(__entry->maj_stat))
96 );
97 
98 #define DEFINE_GSSAPI_EVENT(name)					\
99 	DEFINE_EVENT(rpcgss_gssapi_event, rpcgss_##name,		\
100 			TP_PROTO(					\
101 				const struct rpc_task *task,		\
102 				u32 maj_stat				\
103 			),						\
104 			TP_ARGS(task, maj_stat))
105 
106 TRACE_EVENT(rpcgss_import_ctx,
107 	TP_PROTO(
108 		int status
109 	),
110 
111 	TP_ARGS(status),
112 
113 	TP_STRUCT__entry(
114 		__field(int, status)
115 	),
116 
117 	TP_fast_assign(
118 		__entry->status = status;
119 	),
120 
121 	TP_printk("status=%d", __entry->status)
122 );
123 
124 DEFINE_GSSAPI_EVENT(get_mic);
125 DEFINE_GSSAPI_EVENT(verify_mic);
126 DEFINE_GSSAPI_EVENT(wrap);
127 DEFINE_GSSAPI_EVENT(unwrap);
128 
129 TRACE_EVENT(rpcgss_svc_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 
157 TRACE_EVENT(rpcgss_svc_accept,
158 	TP_PROTO(
159 		__be32 xid,
160 		size_t len
161 	),
162 
163 	TP_ARGS(xid, len),
164 
165 	TP_STRUCT__entry(
166 		__field(u32, xid)
167 		__field(size_t, len)
168 	),
169 
170 	TP_fast_assign(
171 		__entry->xid = be32_to_cpu(xid);
172 		__entry->len = len;
173 	),
174 
175 	TP_printk("xid=0x%08x len=%zu",
176 		__entry->xid, __entry->len
177 	)
178 );
179 
180 
181 /**
182  ** GSS auth unwrap failures
183  **/
184 
185 TRACE_EVENT(rpcgss_unwrap_failed,
186 	TP_PROTO(
187 		const struct rpc_task *task
188 	),
189 
190 	TP_ARGS(task),
191 
192 	TP_STRUCT__entry(
193 		__field(unsigned int, task_id)
194 		__field(unsigned int, client_id)
195 	),
196 
197 	TP_fast_assign(
198 		__entry->task_id = task->tk_pid;
199 		__entry->client_id = task->tk_client->cl_clid;
200 	),
201 
202 	TP_printk("task:%u@%u", __entry->task_id, __entry->client_id)
203 );
204 
205 TRACE_EVENT(rpcgss_bad_seqno,
206 	TP_PROTO(
207 		const struct rpc_task *task,
208 		u32 expected,
209 		u32 received
210 	),
211 
212 	TP_ARGS(task, expected, received),
213 
214 	TP_STRUCT__entry(
215 		__field(unsigned int, task_id)
216 		__field(unsigned int, client_id)
217 		__field(u32, expected)
218 		__field(u32, received)
219 	),
220 
221 	TP_fast_assign(
222 		__entry->task_id = task->tk_pid;
223 		__entry->client_id = task->tk_client->cl_clid;
224 		__entry->expected = expected;
225 		__entry->received = received;
226 	),
227 
228 	TP_printk("task:%u@%u expected seqno %u, received seqno %u",
229 		__entry->task_id, __entry->client_id,
230 		__entry->expected, __entry->received)
231 );
232 
233 TRACE_EVENT(rpcgss_seqno,
234 	TP_PROTO(
235 		const struct rpc_task *task
236 	),
237 
238 	TP_ARGS(task),
239 
240 	TP_STRUCT__entry(
241 		__field(unsigned int, task_id)
242 		__field(unsigned int, client_id)
243 		__field(u32, xid)
244 		__field(u32, seqno)
245 	),
246 
247 	TP_fast_assign(
248 		const struct rpc_rqst *rqst = task->tk_rqstp;
249 
250 		__entry->task_id = task->tk_pid;
251 		__entry->client_id = task->tk_client->cl_clid;
252 		__entry->xid = be32_to_cpu(rqst->rq_xid);
253 		__entry->seqno = rqst->rq_seqno;
254 	),
255 
256 	TP_printk("task:%u@%u xid=0x%08x seqno=%u",
257 		__entry->task_id, __entry->client_id,
258 		__entry->xid, __entry->seqno)
259 );
260 
261 TRACE_EVENT(rpcgss_need_reencode,
262 	TP_PROTO(
263 		const struct rpc_task *task,
264 		u32 seq_xmit,
265 		bool ret
266 	),
267 
268 	TP_ARGS(task, seq_xmit, ret),
269 
270 	TP_STRUCT__entry(
271 		__field(unsigned int, task_id)
272 		__field(unsigned int, client_id)
273 		__field(u32, xid)
274 		__field(u32, seq_xmit)
275 		__field(u32, seqno)
276 		__field(bool, ret)
277 	),
278 
279 	TP_fast_assign(
280 		__entry->task_id = task->tk_pid;
281 		__entry->client_id = task->tk_client->cl_clid;
282 		__entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid);
283 		__entry->seq_xmit = seq_xmit;
284 		__entry->seqno = task->tk_rqstp->rq_seqno;
285 		__entry->ret = ret;
286 	),
287 
288 	TP_printk("task:%u@%u xid=0x%08x rq_seqno=%u seq_xmit=%u reencode %sneeded",
289 		__entry->task_id, __entry->client_id,
290 		__entry->xid, __entry->seqno, __entry->seq_xmit,
291 		__entry->ret ? "" : "un")
292 );
293 
294 DECLARE_EVENT_CLASS(rpcgss_svc_seqno_class,
295 	TP_PROTO(
296 		__be32 xid,
297 		u32 seqno
298 	),
299 
300 	TP_ARGS(xid, seqno),
301 
302 	TP_STRUCT__entry(
303 		__field(u32, xid)
304 		__field(u32, seqno)
305 	),
306 
307 	TP_fast_assign(
308 		__entry->xid = be32_to_cpu(xid);
309 		__entry->seqno = seqno;
310 	),
311 
312 	TP_printk("xid=0x%08x seqno=%u, request discarded",
313 		__entry->xid, __entry->seqno)
314 );
315 
316 #define DEFINE_SVC_SEQNO_EVENT(name)					\
317 	DEFINE_EVENT(rpcgss_svc_seqno_class, rpcgss_svc_##name,		\
318 			TP_PROTO(					\
319 				__be32 xid,				\
320 				u32 seqno				\
321 			),						\
322 			TP_ARGS(xid, seqno))
323 
324 DEFINE_SVC_SEQNO_EVENT(large_seqno);
325 DEFINE_SVC_SEQNO_EVENT(old_seqno);
326 
327 
328 /**
329  ** gssd upcall related trace events
330  **/
331 
332 TRACE_EVENT(rpcgss_upcall_msg,
333 	TP_PROTO(
334 		const char *buf
335 	),
336 
337 	TP_ARGS(buf),
338 
339 	TP_STRUCT__entry(
340 		__string(msg, buf)
341 	),
342 
343 	TP_fast_assign(
344 		__assign_str(msg, buf)
345 	),
346 
347 	TP_printk("msg='%s'", __get_str(msg))
348 );
349 
350 TRACE_EVENT(rpcgss_upcall_result,
351 	TP_PROTO(
352 		u32 uid,
353 		int result
354 	),
355 
356 	TP_ARGS(uid, result),
357 
358 	TP_STRUCT__entry(
359 		__field(u32, uid)
360 		__field(int, result)
361 
362 	),
363 
364 	TP_fast_assign(
365 		__entry->uid = uid;
366 		__entry->result = result;
367 	),
368 
369 	TP_printk("for uid %u, result=%d", __entry->uid, __entry->result)
370 );
371 
372 TRACE_EVENT(rpcgss_context,
373 	TP_PROTO(
374 		unsigned long expiry,
375 		unsigned long now,
376 		unsigned int timeout,
377 		unsigned int len,
378 		const u8 *data
379 	),
380 
381 	TP_ARGS(expiry, now, timeout, len, data),
382 
383 	TP_STRUCT__entry(
384 		__field(unsigned long, expiry)
385 		__field(unsigned long, now)
386 		__field(unsigned int, timeout)
387 		__field(int, len)
388 		__string(acceptor, data)
389 	),
390 
391 	TP_fast_assign(
392 		__entry->expiry = expiry;
393 		__entry->now = now;
394 		__entry->timeout = timeout;
395 		__entry->len = len;
396 		strncpy(__get_str(acceptor), data, len);
397 	),
398 
399 	TP_printk("gc_expiry=%lu now=%lu timeout=%u acceptor=%.*s",
400 		__entry->expiry, __entry->now, __entry->timeout,
401 		__entry->len, __get_str(acceptor))
402 );
403 
404 
405 /**
406  ** Miscellaneous events
407  */
408 
409 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5);
410 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5I);
411 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5P);
412 
413 #define show_pseudoflavor(x)						\
414 	__print_symbolic(x,						\
415 		{ RPC_AUTH_GSS_KRB5, "RPC_AUTH_GSS_KRB5" },		\
416 		{ RPC_AUTH_GSS_KRB5I, "RPC_AUTH_GSS_KRB5I" },		\
417 		{ RPC_AUTH_GSS_KRB5P, "RPC_AUTH_GSS_KRB5P" })
418 
419 
420 TRACE_EVENT(rpcgss_createauth,
421 	TP_PROTO(
422 		unsigned int flavor,
423 		int error
424 	),
425 
426 	TP_ARGS(flavor, error),
427 
428 	TP_STRUCT__entry(
429 		__field(unsigned int, flavor)
430 		__field(int, error)
431 
432 	),
433 
434 	TP_fast_assign(
435 		__entry->flavor = flavor;
436 		__entry->error = error;
437 	),
438 
439 	TP_printk("flavor=%s error=%d",
440 		show_pseudoflavor(__entry->flavor), __entry->error)
441 );
442 
443 TRACE_EVENT(rpcgss_oid_to_mech,
444 	TP_PROTO(
445 		const char *oid
446 	),
447 
448 	TP_ARGS(oid),
449 
450 	TP_STRUCT__entry(
451 		__string(oid, oid)
452 	),
453 
454 	TP_fast_assign(
455 		__assign_str(oid, oid);
456 	),
457 
458 	TP_printk("mech for oid %s was not found", __get_str(oid))
459 );
460 
461 #endif	/* _TRACE_RPCGSS_H */
462 
463 #include <trace/define_trace.h>
464