xref: /openbmc/linux/include/trace/events/rpcgss.h (revision 81de3bf3)
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_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 
158 /**
159  ** GSS auth unwrap failures
160  **/
161 
162 TRACE_EVENT(rpcgss_unwrap_failed,
163 	TP_PROTO(
164 		const struct rpc_task *task
165 	),
166 
167 	TP_ARGS(task),
168 
169 	TP_STRUCT__entry(
170 		__field(unsigned int, task_id)
171 		__field(unsigned int, client_id)
172 	),
173 
174 	TP_fast_assign(
175 		__entry->task_id = task->tk_pid;
176 		__entry->client_id = task->tk_client->cl_clid;
177 	),
178 
179 	TP_printk("task:%u@%u", __entry->task_id, __entry->client_id)
180 );
181 
182 TRACE_EVENT(rpcgss_bad_seqno,
183 	TP_PROTO(
184 		const struct rpc_task *task,
185 		u32 expected,
186 		u32 received
187 	),
188 
189 	TP_ARGS(task, expected, received),
190 
191 	TP_STRUCT__entry(
192 		__field(unsigned int, task_id)
193 		__field(unsigned int, client_id)
194 		__field(u32, expected)
195 		__field(u32, received)
196 	),
197 
198 	TP_fast_assign(
199 		__entry->task_id = task->tk_pid;
200 		__entry->client_id = task->tk_client->cl_clid;
201 		__entry->expected = expected;
202 		__entry->received = received;
203 	),
204 
205 	TP_printk("task:%u@%u expected seqno %u, received seqno %u",
206 		__entry->task_id, __entry->client_id,
207 		__entry->expected, __entry->received)
208 );
209 
210 TRACE_EVENT(rpcgss_seqno,
211 	TP_PROTO(
212 		const struct rpc_task *task
213 	),
214 
215 	TP_ARGS(task),
216 
217 	TP_STRUCT__entry(
218 		__field(unsigned int, task_id)
219 		__field(unsigned int, client_id)
220 		__field(u32, xid)
221 		__field(u32, seqno)
222 	),
223 
224 	TP_fast_assign(
225 		const struct rpc_rqst *rqst = task->tk_rqstp;
226 
227 		__entry->task_id = task->tk_pid;
228 		__entry->client_id = task->tk_client->cl_clid;
229 		__entry->xid = be32_to_cpu(rqst->rq_xid);
230 		__entry->seqno = rqst->rq_seqno;
231 	),
232 
233 	TP_printk("task:%u@%u xid=0x%08x seqno=%u",
234 		__entry->task_id, __entry->client_id,
235 		__entry->xid, __entry->seqno)
236 );
237 
238 TRACE_EVENT(rpcgss_need_reencode,
239 	TP_PROTO(
240 		const struct rpc_task *task,
241 		u32 seq_xmit,
242 		bool ret
243 	),
244 
245 	TP_ARGS(task, seq_xmit, ret),
246 
247 	TP_STRUCT__entry(
248 		__field(unsigned int, task_id)
249 		__field(unsigned int, client_id)
250 		__field(u32, xid)
251 		__field(u32, seq_xmit)
252 		__field(u32, seqno)
253 		__field(bool, ret)
254 	),
255 
256 	TP_fast_assign(
257 		__entry->task_id = task->tk_pid;
258 		__entry->client_id = task->tk_client->cl_clid;
259 		__entry->xid = be32_to_cpu(task->tk_rqstp->rq_xid);
260 		__entry->seq_xmit = seq_xmit;
261 		__entry->seqno = task->tk_rqstp->rq_seqno;
262 		__entry->ret = ret;
263 	),
264 
265 	TP_printk("task:%u@%u xid=0x%08x rq_seqno=%u seq_xmit=%u reencode %sneeded",
266 		__entry->task_id, __entry->client_id,
267 		__entry->xid, __entry->seqno, __entry->seq_xmit,
268 		__entry->ret ? "" : "un")
269 );
270 
271 /**
272  ** gssd upcall related trace events
273  **/
274 
275 TRACE_EVENT(rpcgss_upcall_msg,
276 	TP_PROTO(
277 		const char *buf
278 	),
279 
280 	TP_ARGS(buf),
281 
282 	TP_STRUCT__entry(
283 		__string(msg, buf)
284 	),
285 
286 	TP_fast_assign(
287 		__assign_str(msg, buf)
288 	),
289 
290 	TP_printk("msg='%s'", __get_str(msg))
291 );
292 
293 TRACE_EVENT(rpcgss_upcall_result,
294 	TP_PROTO(
295 		u32 uid,
296 		int result
297 	),
298 
299 	TP_ARGS(uid, result),
300 
301 	TP_STRUCT__entry(
302 		__field(u32, uid)
303 		__field(int, result)
304 
305 	),
306 
307 	TP_fast_assign(
308 		__entry->uid = uid;
309 		__entry->result = result;
310 	),
311 
312 	TP_printk("for uid %u, result=%d", __entry->uid, __entry->result)
313 );
314 
315 TRACE_EVENT(rpcgss_context,
316 	TP_PROTO(
317 		unsigned long expiry,
318 		unsigned long now,
319 		unsigned int timeout,
320 		unsigned int len,
321 		const u8 *data
322 	),
323 
324 	TP_ARGS(expiry, now, timeout, len, data),
325 
326 	TP_STRUCT__entry(
327 		__field(unsigned long, expiry)
328 		__field(unsigned long, now)
329 		__field(unsigned int, timeout)
330 		__field(int, len)
331 		__string(acceptor, data)
332 	),
333 
334 	TP_fast_assign(
335 		__entry->expiry = expiry;
336 		__entry->now = now;
337 		__entry->timeout = timeout;
338 		__entry->len = len;
339 		strncpy(__get_str(acceptor), data, len);
340 	),
341 
342 	TP_printk("gc_expiry=%lu now=%lu timeout=%u acceptor=%.*s",
343 		__entry->expiry, __entry->now, __entry->timeout,
344 		__entry->len, __get_str(acceptor))
345 );
346 
347 
348 /**
349  ** Miscellaneous events
350  */
351 
352 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5);
353 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5I);
354 TRACE_DEFINE_ENUM(RPC_AUTH_GSS_KRB5P);
355 
356 #define show_pseudoflavor(x)						\
357 	__print_symbolic(x,						\
358 		{ RPC_AUTH_GSS_KRB5, "RPC_AUTH_GSS_KRB5" },		\
359 		{ RPC_AUTH_GSS_KRB5I, "RPC_AUTH_GSS_KRB5I" },		\
360 		{ RPC_AUTH_GSS_KRB5P, "RPC_AUTH_GSS_KRB5P" })
361 
362 
363 TRACE_EVENT(rpcgss_createauth,
364 	TP_PROTO(
365 		unsigned int flavor,
366 		int error
367 	),
368 
369 	TP_ARGS(flavor, error),
370 
371 	TP_STRUCT__entry(
372 		__field(unsigned int, flavor)
373 		__field(int, error)
374 
375 	),
376 
377 	TP_fast_assign(
378 		__entry->flavor = flavor;
379 		__entry->error = error;
380 	),
381 
382 	TP_printk("flavor=%s error=%d",
383 		show_pseudoflavor(__entry->flavor), __entry->error)
384 );
385 
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 );
403 
404 #endif	/* _TRACE_RPCGSS_H */
405 
406 #include <trace/define_trace.h>
407