1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM handshake
5 #if !defined(_TRACE_HANDSHAKE_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_HANDSHAKE_H
9 #include <net/tls_prot.h>
10 #include <linux/tracepoint.h>
11 #include <trace/events/net_probe_common.h>
13 #define TLS_RECORD_TYPE_LIST \
14 record_type(CHANGE_CIPHER_SPEC) \
16 record_type(HANDSHAKE) \
18 record_type(HEARTBEAT) \
19 record_type(TLS12_CID) \
23 #undef record_type_end
24 #define record_type(x) TRACE_DEFINE_ENUM(TLS_RECORD_TYPE_##x);
25 #define record_type_end(x) TRACE_DEFINE_ENUM(TLS_RECORD_TYPE_##x);
30 #undef record_type_end
31 #define record_type(x) { TLS_RECORD_TYPE_##x, #x },
32 #define record_type_end(x) { TLS_RECORD_TYPE_##x, #x }
34 #define show_tls_content_type(type) \
35 __print_symbolic(type, TLS_RECORD_TYPE_LIST)
37 TRACE_DEFINE_ENUM(TLS_ALERT_LEVEL_WARNING);
38 TRACE_DEFINE_ENUM(TLS_ALERT_LEVEL_FATAL);
40 #define show_tls_alert_level(level) \
41 __print_symbolic(level, \
42 { TLS_ALERT_LEVEL_WARNING, "Warning" }, \
43 { TLS_ALERT_LEVEL_FATAL, "Fatal" })
45 #define TLS_ALERT_DESCRIPTION_LIST \
46 alert_description(CLOSE_NOTIFY) \
47 alert_description(UNEXPECTED_MESSAGE) \
48 alert_description(BAD_RECORD_MAC) \
49 alert_description(RECORD_OVERFLOW) \
50 alert_description(HANDSHAKE_FAILURE) \
51 alert_description(BAD_CERTIFICATE) \
52 alert_description(UNSUPPORTED_CERTIFICATE) \
53 alert_description(CERTIFICATE_REVOKED) \
54 alert_description(CERTIFICATE_EXPIRED) \
55 alert_description(CERTIFICATE_UNKNOWN) \
56 alert_description(ILLEGAL_PARAMETER) \
57 alert_description(UNKNOWN_CA) \
58 alert_description(ACCESS_DENIED) \
59 alert_description(DECODE_ERROR) \
60 alert_description(DECRYPT_ERROR) \
61 alert_description(TOO_MANY_CIDS_REQUESTED) \
62 alert_description(PROTOCOL_VERSION) \
63 alert_description(INSUFFICIENT_SECURITY) \
64 alert_description(INTERNAL_ERROR) \
65 alert_description(INAPPROPRIATE_FALLBACK) \
66 alert_description(USER_CANCELED) \
67 alert_description(MISSING_EXTENSION) \
68 alert_description(UNSUPPORTED_EXTENSION) \
69 alert_description(UNRECOGNIZED_NAME) \
70 alert_description(BAD_CERTIFICATE_STATUS_RESPONSE) \
71 alert_description(UNKNOWN_PSK_IDENTITY) \
72 alert_description(CERTIFICATE_REQUIRED) \
73 alert_description_end(NO_APPLICATION_PROTOCOL)
75 #undef alert_description
76 #undef alert_description_end
77 #define alert_description(x) TRACE_DEFINE_ENUM(TLS_ALERT_DESC_##x);
78 #define alert_description_end(x) TRACE_DEFINE_ENUM(TLS_ALERT_DESC_##x);
80 TLS_ALERT_DESCRIPTION_LIST
82 #undef alert_description
83 #undef alert_description_end
84 #define alert_description(x) { TLS_ALERT_DESC_##x, #x },
85 #define alert_description_end(x) { TLS_ALERT_DESC_##x, #x }
87 #define show_tls_alert_description(desc) \
88 __print_symbolic(desc, TLS_ALERT_DESCRIPTION_LIST)
90 DECLARE_EVENT_CLASS(handshake_event_class,
92 const struct net *net,
93 const struct handshake_req *req,
96 TP_ARGS(net, req, sk),
98 __field(const void *, req)
99 __field(const void *, sk)
100 __field(unsigned int, netns_ino)
105 __entry->netns_ino = net->ns.inum;
107 TP_printk("req=%p sk=%p",
108 __entry->req, __entry->sk
111 #define DEFINE_HANDSHAKE_EVENT(name) \
112 DEFINE_EVENT(handshake_event_class, name, \
114 const struct net *net, \
115 const struct handshake_req *req, \
116 const struct sock *sk \
118 TP_ARGS(net, req, sk))
120 DECLARE_EVENT_CLASS(handshake_fd_class,
122 const struct net *net,
123 const struct handshake_req *req,
124 const struct sock *sk,
127 TP_ARGS(net, req, sk, fd),
129 __field(const void *, req)
130 __field(const void *, sk)
132 __field(unsigned int, netns_ino)
136 __entry->sk = req->hr_sk;
138 __entry->netns_ino = net->ns.inum;
140 TP_printk("req=%p sk=%p fd=%d",
141 __entry->req, __entry->sk, __entry->fd
144 #define DEFINE_HANDSHAKE_FD_EVENT(name) \
145 DEFINE_EVENT(handshake_fd_class, name, \
147 const struct net *net, \
148 const struct handshake_req *req, \
149 const struct sock *sk, \
152 TP_ARGS(net, req, sk, fd))
154 DECLARE_EVENT_CLASS(handshake_error_class,
156 const struct net *net,
157 const struct handshake_req *req,
158 const struct sock *sk,
161 TP_ARGS(net, req, sk, err),
163 __field(const void *, req)
164 __field(const void *, sk)
166 __field(unsigned int, netns_ino)
172 __entry->netns_ino = net->ns.inum;
174 TP_printk("req=%p sk=%p err=%d",
175 __entry->req, __entry->sk, __entry->err
178 #define DEFINE_HANDSHAKE_ERROR(name) \
179 DEFINE_EVENT(handshake_error_class, name, \
181 const struct net *net, \
182 const struct handshake_req *req, \
183 const struct sock *sk, \
186 TP_ARGS(net, req, sk, err))
188 DECLARE_EVENT_CLASS(handshake_alert_class,
190 const struct sock *sk,
192 unsigned char description
194 TP_ARGS(sk, level, description),
196 /* sockaddr_in6 is always bigger than sockaddr_in */
197 __array(__u8, saddr, sizeof(struct sockaddr_in6))
198 __array(__u8, daddr, sizeof(struct sockaddr_in6))
199 __field(unsigned int, netns_ino)
200 __field(unsigned long, level)
201 __field(unsigned long, description)
204 const struct inet_sock *inet = inet_sk(sk);
206 memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));
207 memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));
208 TP_STORE_ADDR_PORTS(__entry, inet, sk);
210 __entry->netns_ino = sock_net(sk)->ns.inum;
211 __entry->level = level;
212 __entry->description = description;
214 TP_printk("src=%pISpc dest=%pISpc %s: %s",
215 __entry->saddr, __entry->daddr,
216 show_tls_alert_level(__entry->level),
217 show_tls_alert_description(__entry->description)
220 #define DEFINE_HANDSHAKE_ALERT(name) \
221 DEFINE_EVENT(handshake_alert_class, name, \
223 const struct sock *sk, \
224 unsigned char level, \
225 unsigned char description \
227 TP_ARGS(sk, level, description))
231 * Request lifetime events
234 DEFINE_HANDSHAKE_EVENT(handshake_submit);
235 DEFINE_HANDSHAKE_ERROR(handshake_submit_err);
236 DEFINE_HANDSHAKE_EVENT(handshake_cancel);
237 DEFINE_HANDSHAKE_EVENT(handshake_cancel_none);
238 DEFINE_HANDSHAKE_EVENT(handshake_cancel_busy);
239 DEFINE_HANDSHAKE_EVENT(handshake_destruct);
242 TRACE_EVENT(handshake_complete,
244 const struct net *net,
245 const struct handshake_req *req,
246 const struct sock *sk,
249 TP_ARGS(net, req, sk, status),
251 __field(const void *, req)
252 __field(const void *, sk)
254 __field(unsigned int, netns_ino)
259 __entry->status = status;
260 __entry->netns_ino = net->ns.inum;
262 TP_printk("req=%p sk=%p status=%d",
263 __entry->req, __entry->sk, __entry->status
271 DEFINE_HANDSHAKE_ERROR(handshake_notify_err);
272 DEFINE_HANDSHAKE_FD_EVENT(handshake_cmd_accept);
273 DEFINE_HANDSHAKE_ERROR(handshake_cmd_accept_err);
274 DEFINE_HANDSHAKE_FD_EVENT(handshake_cmd_done);
275 DEFINE_HANDSHAKE_ERROR(handshake_cmd_done_err);
281 TRACE_EVENT(tls_contenttype,
283 const struct sock *sk,
288 /* sockaddr_in6 is always bigger than sockaddr_in */
289 __array(__u8, saddr, sizeof(struct sockaddr_in6))
290 __array(__u8, daddr, sizeof(struct sockaddr_in6))
291 __field(unsigned int, netns_ino)
292 __field(unsigned long, type)
295 const struct inet_sock *inet = inet_sk(sk);
297 memset(__entry->saddr, 0, sizeof(struct sockaddr_in6));
298 memset(__entry->daddr, 0, sizeof(struct sockaddr_in6));
299 TP_STORE_ADDR_PORTS(__entry, inet, sk);
301 __entry->netns_ino = sock_net(sk)->ns.inum;
302 __entry->type = type;
304 TP_printk("src=%pISpc dest=%pISpc %s",
305 __entry->saddr, __entry->daddr,
306 show_tls_content_type(__entry->type)
314 DEFINE_HANDSHAKE_ALERT(tls_alert_send);
315 DEFINE_HANDSHAKE_ALERT(tls_alert_recv);
317 #endif /* _TRACE_HANDSHAKE_H */
319 #include <trace/define_trace.h>