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