1 /* Copyright (c) 2020, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
5 * \file lttng_circuit.inc
6 * \brief LTTng tracing probe declaration for the circuit subsystem. It is in
7 * this .inc file due to the non C standard syntax and the way we guard
8 * the header with the LTTng specific TRACEPOINT_HEADER_MULTI_READ.
13 /* We only build the following if LTTng instrumentation has been enabled. */
14 #ifdef USE_TRACING_INSTRUMENTATION_LTTNG
16 /* The following defines are LTTng-UST specific. */
17 #undef TRACEPOINT_PROVIDER
18 #define TRACEPOINT_PROVIDER tor_circuit
20 #undef TRACEPOINT_INCLUDE
21 #define TRACEPOINT_INCLUDE "./src/core/or/lttng_circuit.inc"
23 #if !defined(LTTNG_CIRCUIT_INC) || defined(TRACEPOINT_HEADER_MULTI_READ)
24 #define LTTNG_CIRCUIT_INC
26 #include <lttng/tracepoint.h>
31 * The following defines an enumeration of all possible circuit purposes so
32 * they appear in the trace with the define name (first parameter of
33 * ctf_enum_value) instead of the numerical value.
35 TRACEPOINT_ENUM(tor_circuit, purpose,
38 ctf_enum_value("<UNSET>", 0)
41 ctf_enum_value("OR", CIRCUIT_PURPOSE_OR)
42 ctf_enum_value("OR_INTRO_POINT", CIRCUIT_PURPOSE_INTRO_POINT)
43 ctf_enum_value("OR_REND_POINT_WAITING",
44 CIRCUIT_PURPOSE_REND_POINT_WAITING)
45 ctf_enum_value("OR_REND_ESTABLISHED", CIRCUIT_PURPOSE_REND_ESTABLISHED)
48 ctf_enum_value("C_GENERAL", CIRCUIT_PURPOSE_C_GENERAL)
49 ctf_enum_value("C_INTRODUCING", CIRCUIT_PURPOSE_C_INTRODUCING)
50 ctf_enum_value("C_INTRODUCE_ACK_WAIT",
51 CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT)
52 ctf_enum_value("C_INTRODUCE_ACKED", CIRCUIT_PURPOSE_C_INTRODUCE_ACKED)
53 ctf_enum_value("C_ESTABLISH_REND", CIRCUIT_PURPOSE_C_ESTABLISH_REND)
54 ctf_enum_value("C_REND_READY", CIRCUIT_PURPOSE_C_REND_READY)
55 ctf_enum_value("C_REND_READY_INTRO_ACKED",
56 CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED)
57 ctf_enum_value("C_REND_JOINED", CIRCUIT_PURPOSE_C_REND_JOINED)
58 ctf_enum_value("C_HSDIR_GET", CIRCUIT_PURPOSE_C_HSDIR_GET)
60 /* CBT and Padding. */
61 ctf_enum_value("C_MEASURE_TIMEOUT", CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT)
62 ctf_enum_value("C_CIRCUIT_PADDING", CIRCUIT_PURPOSE_C_CIRCUIT_PADDING)
65 ctf_enum_value("S_ESTABLISH_INTRO", CIRCUIT_PURPOSE_S_ESTABLISH_INTRO)
66 ctf_enum_value("S_INTRO", CIRCUIT_PURPOSE_S_INTRO)
67 ctf_enum_value("S_CONNECT_REND", CIRCUIT_PURPOSE_S_CONNECT_REND)
68 ctf_enum_value("S_REND_JOINED", CIRCUIT_PURPOSE_S_REND_JOINED)
69 ctf_enum_value("S_HSDIR_POST", CIRCUIT_PURPOSE_S_HSDIR_POST)
72 ctf_enum_value("TESTING", CIRCUIT_PURPOSE_TESTING)
73 ctf_enum_value("CONTROLLER", CIRCUIT_PURPOSE_CONTROLLER)
74 ctf_enum_value("PATH_BIAS_TESTING", CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
77 ctf_enum_value("HS_VANGUARDS", CIRCUIT_PURPOSE_HS_VANGUARDS)
84 * The following defines an enumeration of all possible circuit end reasons so
85 * they appear in the trace with the define name (first parameter of
86 * ctf_enum_value) instead of the numerical value.
88 TRACEPOINT_ENUM(tor_circuit, end_reason,
91 ctf_enum_value("IP_NOW_REDUNDANT", END_CIRC_REASON_IP_NOW_REDUNDANT)
92 ctf_enum_value("MEASUREMENT_EXPIRED", END_CIRC_REASON_MEASUREMENT_EXPIRED)
93 ctf_enum_value("REASON_NOPATH", END_CIRC_REASON_NOPATH)
94 ctf_enum_value("AT_ORIGIN", END_CIRC_AT_ORIGIN)
95 ctf_enum_value("NONE", END_CIRC_REASON_NONE)
96 ctf_enum_value("TORPROTOCOL", END_CIRC_REASON_TORPROTOCOL)
97 ctf_enum_value("INTERNAL", END_CIRC_REASON_INTERNAL)
98 ctf_enum_value("REQUESTED", END_CIRC_REASON_REQUESTED)
99 ctf_enum_value("HIBERNATING", END_CIRC_REASON_HIBERNATING)
100 ctf_enum_value("RESOURCELIMIT", END_CIRC_REASON_RESOURCELIMIT)
101 ctf_enum_value("CONNECTFAILED", END_CIRC_REASON_CONNECTFAILED)
102 ctf_enum_value("OR_IDENTITY", END_CIRC_REASON_OR_IDENTITY)
103 ctf_enum_value("CHANNEL_CLOSED", END_CIRC_REASON_CHANNEL_CLOSED)
104 ctf_enum_value("FINISHED", END_CIRC_REASON_FINISHED)
105 ctf_enum_value("TIMEOUT", END_CIRC_REASON_TIMEOUT)
106 ctf_enum_value("DESTROYED", END_CIRC_REASON_DESTROYED)
107 ctf_enum_value("NOSUCHSERVICE", END_CIRC_REASON_NOSUCHSERVICE)
109 /* Remote reasons. */
110 ctf_enum_value("FLAG_REMOTE", END_CIRC_REASON_FLAG_REMOTE)
111 ctf_enum_value("REMOTE_TORPROTOCOL",
112 END_CIRC_REASON_FLAG_REMOTE | END_CIRC_REASON_TORPROTOCOL)
113 ctf_enum_value("REMOTE_INTERNAL",
114 END_CIRC_REASON_FLAG_REMOTE | END_CIRC_REASON_INTERNAL)
115 ctf_enum_value("REMOTE_REQUESTED",
116 END_CIRC_REASON_FLAG_REMOTE | END_CIRC_REASON_REQUESTED)
117 ctf_enum_value("REMOTE_HIBERNATING",
118 END_CIRC_REASON_FLAG_REMOTE | END_CIRC_REASON_HIBERNATING)
119 ctf_enum_value("REMOTE_RESOURCELIMIT",
120 END_CIRC_REASON_FLAG_REMOTE | END_CIRC_REASON_RESOURCELIMIT)
121 ctf_enum_value("REMOTE_CONNECTFAILED",
122 END_CIRC_REASON_FLAG_REMOTE | END_CIRC_REASON_CONNECTFAILED)
123 ctf_enum_value("REMOTE_OR_IDENTITY",
124 END_CIRC_REASON_FLAG_REMOTE | END_CIRC_REASON_OR_IDENTITY)
125 ctf_enum_value("REMOTE_CHANNEL_CLOSED",
126 END_CIRC_REASON_FLAG_REMOTE | END_CIRC_REASON_CHANNEL_CLOSED)
127 ctf_enum_value("REMOTE_FINISHED",
128 END_CIRC_REASON_FLAG_REMOTE | END_CIRC_REASON_FINISHED)
129 ctf_enum_value("REMOTE_TIMEOUT",
130 END_CIRC_REASON_FLAG_REMOTE | END_CIRC_REASON_TIMEOUT)
131 ctf_enum_value("REMOTE_DESTROYED",
132 END_CIRC_REASON_FLAG_REMOTE | END_CIRC_REASON_DESTROYED)
133 ctf_enum_value("REMOTE_NOSUCHSERVICE",
134 END_CIRC_REASON_FLAG_REMOTE | END_CIRC_REASON_NOSUCHSERVICE)
141 * The following defines an enumeration of all possible circuit state so they
142 * appear in the trace with the define name (first parameter of
143 * ctf_enum_value) instead of the numerical value.
145 TRACEPOINT_ENUM(tor_circuit, state,
147 ctf_enum_value("BUILDING", CIRCUIT_STATE_BUILDING)
148 ctf_enum_value("ONIONSKIN_PENDING", CIRCUIT_STATE_ONIONSKIN_PENDING)
149 ctf_enum_value("CHAN_WAIT", CIRCUIT_STATE_CHAN_WAIT)
150 ctf_enum_value("GUARD_WAIT", CIRCUIT_STATE_GUARD_WAIT)
151 ctf_enum_value("OPEN", CIRCUIT_STATE_OPEN)
158 * A tracepoint class is a class of tracepoints which share the same output
159 * event field definitions. They are then used by the
160 * TRACEPOINT_EVENT_INSTANCE() macro as a base field definition.
163 /* Class for origin circuit. */
164 TRACEPOINT_EVENT_CLASS(tor_circuit, origin_circuit_t_class,
165 TP_ARGS(const origin_circuit_t *, circ),
167 ctf_integer(uint32_t, circ_id, circ->global_identifier)
168 ctf_enum(tor_circuit, purpose, int, purpose, TO_CIRCUIT(circ)->purpose)
169 ctf_enum(tor_circuit, state, int, state, TO_CIRCUIT(circ)->state)
173 /* Class for or circuit. */
174 TRACEPOINT_EVENT_CLASS(tor_circuit, or_circuit_t_class,
175 TP_ARGS(const or_circuit_t *, circ),
177 ctf_enum(tor_circuit, purpose, int, purpose, TO_CIRCUIT(circ)->purpose)
178 ctf_enum(tor_circuit, state, int, state, TO_CIRCUIT(circ)->state)
183 * Origin circuit events.
185 * Tracepoint use the origin_circuit_t object.
188 /* Tracepoint emitted when a new origin circuit has been created. */
189 TRACEPOINT_EVENT_INSTANCE(tor_circuit, origin_circuit_t_class, new_origin,
190 TP_ARGS(const origin_circuit_t *, circ)
193 /* Tracepoint emitted when an origin circuit has opened. */
194 TRACEPOINT_EVENT_INSTANCE(tor_circuit, origin_circuit_t_class, opened,
195 TP_ARGS(const origin_circuit_t *, circ)
198 /* Tracepoint emitted when an origin circuit has established. */
199 TRACEPOINT_EVENT_INSTANCE(tor_circuit, origin_circuit_t_class, establish,
200 TP_ARGS(const origin_circuit_t *, circ)
203 /* Tracepoint emitted when an origin circuit has been cannibalized. */
204 TRACEPOINT_EVENT_INSTANCE(tor_circuit, origin_circuit_t_class, cannibalized,
205 TP_ARGS(const origin_circuit_t *, circ)
208 /* Tracepoint emitted when an origin circuit has timed out. This is called
209 * when circuit_expire_building() as selected the circuit and is about to
210 * close it for timeout. */
211 TRACEPOINT_EVENT_INSTANCE(tor_circuit, origin_circuit_t_class, timeout,
212 TP_ARGS(const origin_circuit_t *, circ)
215 /* Tracepoint emitted when an origin circuit has timed out due to idleness.
216 * This is when the circuit is closed after MaxCircuitDirtiness. */
217 TRACEPOINT_EVENT_INSTANCE(tor_circuit, origin_circuit_t_class, idle_timeout,
218 TP_ARGS(const origin_circuit_t *, circ)
221 /* Tracepoint emitted when an origin circuit sends out its first onion skin. */
222 TRACEPOINT_EVENT(tor_circuit, first_onion_skin,
223 TP_ARGS(const origin_circuit_t *, circ, const crypt_path_t *, hop),
225 ctf_integer(uint32_t, circ_id, circ->global_identifier)
226 ctf_enum(tor_circuit, purpose, int, purpose, TO_CIRCUIT(circ)->purpose)
227 ctf_enum(tor_circuit, state, int, state, TO_CIRCUIT(circ)->state)
228 ctf_array_hex(char, fingerprint, hop->extend_info->identity_digest,
233 /* Tracepoint emitted when an origin circuit sends out an intermediate onion
235 TRACEPOINT_EVENT(tor_circuit, intermediate_onion_skin,
236 TP_ARGS(const origin_circuit_t *, circ, const crypt_path_t *, hop),
238 ctf_integer(uint32_t, circ_id, circ->global_identifier)
239 ctf_enum(tor_circuit, purpose, int, purpose, TO_CIRCUIT(circ)->purpose)
240 ctf_enum(tor_circuit, state, int, state, TO_CIRCUIT(circ)->state)
241 ctf_array_hex(char, fingerprint, hop->extend_info->identity_digest,
249 * Tracepoint use the or_circuit_t object.
252 /* Tracepoint emitted when a new or circuit has been created. */
253 TRACEPOINT_EVENT_INSTANCE(tor_circuit, or_circuit_t_class, new_or,
254 TP_ARGS(const or_circuit_t *, circ)
258 * General circuit events.
260 * Tracepoint use the circuit_t object.
263 /* Tracepoint emitted when a circuit is freed. */
264 TRACEPOINT_EVENT(tor_circuit, free,
265 TP_ARGS(const circuit_t *, circ),
267 ctf_integer(uint32_t, circ_id,
268 (CIRCUIT_IS_ORIGIN(circ) ?
269 TO_ORIGIN_CIRCUIT(circ)->global_identifier : 0))
270 ctf_enum(tor_circuit, purpose, int, purpose, circ->purpose)
271 ctf_enum(tor_circuit, state, int, state, circ->state)
275 /* Tracepoint emitted when a circuit is marked for close. */
276 TRACEPOINT_EVENT(tor_circuit, mark_for_close,
277 TP_ARGS(const circuit_t *, circ),
279 ctf_integer(uint32_t, circ_id,
280 (CIRCUIT_IS_ORIGIN(circ) ?
281 TO_ORIGIN_CIRCUIT(circ)->global_identifier : 0))
282 ctf_enum(tor_circuit, purpose, int, purpose, circ->purpose)
283 ctf_enum(tor_circuit, state, int, state, circ->state)
284 ctf_enum(tor_circuit, end_reason, int, close_reason,
285 circ->marked_for_close_reason)
286 ctf_enum(tor_circuit, end_reason, int, orig_close_reason,
287 circ->marked_for_close_orig_reason)
291 /* Tracepoint emitted when a circuit changes purpose. */
292 TRACEPOINT_EVENT(tor_circuit, change_purpose,
293 TP_ARGS(const circuit_t *, circ, int, old_purpose, int, new_purpose),
295 ctf_integer(uint32_t, circ_id,
296 (CIRCUIT_IS_ORIGIN(circ) ?
297 TO_ORIGIN_CIRCUIT(circ)->global_identifier : 0))
298 ctf_enum(tor_circuit, state, int, state, circ->state)
299 ctf_enum(tor_circuit, purpose, int, purpose, old_purpose)
300 ctf_enum(tor_circuit, purpose, int, new, new_purpose)
304 /* Tracepoint emitted when a circuit changes state. */
305 TRACEPOINT_EVENT(tor_circuit, change_state,
306 TP_ARGS(const circuit_t *, circ, int, old_state, int, new_state),
308 ctf_integer(uint32_t, circ_id,
309 (CIRCUIT_IS_ORIGIN(circ) ?
310 TO_ORIGIN_CIRCUIT(circ)->global_identifier : 0))
311 ctf_enum(tor_circuit, purpose, int, purpose, circ->purpose)
312 ctf_enum(tor_circuit, state, int, old, old_state)
313 ctf_enum(tor_circuit, state, int, new, new_state)
317 #endif /* LTTNG_CIRCUIT_INC || TRACEPOINT_HEADER_MULTI_READ */
319 /* Must be included after the probes declaration. */
320 #include <lttng/tracepoint-event.h>
322 #endif /* USE_TRACING_INSTRUMENTATION_LTTNG */