Tor  0.4.7.0-alpha-dev
lttng_circuit.inc
Go to the documentation of this file.
1 /* Copyright (c) 2020, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
4 /**
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.
9  **/
10 
11 #include "orconfig.h"
12 
13 /* We only build the following if LTTng instrumentation has been enabled. */
14 #ifdef USE_TRACING_INSTRUMENTATION_LTTNG
15 
16 /* The following defines are LTTng-UST specific. */
17 #undef TRACEPOINT_PROVIDER
18 #define TRACEPOINT_PROVIDER tor_circuit
19 
20 #undef TRACEPOINT_INCLUDE
21 #define TRACEPOINT_INCLUDE "./src/core/or/lttng_circuit.inc"
22 
23 #if !defined(LTTNG_CIRCUIT_INC) || defined(TRACEPOINT_HEADER_MULTI_READ)
24 #define LTTNG_CIRCUIT_INC
25 
26 #include <lttng/tracepoint.h>
27 
28 /*
29  * Circuit Purposes
30  *
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.
34  */
35 TRACEPOINT_ENUM(tor_circuit, purpose,
36  TP_ENUM_VALUES(
37  /* Initializing. */
38  ctf_enum_value("<UNSET>", 0)
39 
40  /* OR Side. */
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",
45  ctf_enum_value("OR_REND_ESTABLISHED", CIRCUIT_PURPOSE_REND_ESTABLISHED)
46 
47  /* Client Side. */
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",
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",
57  ctf_enum_value("C_REND_JOINED", CIRCUIT_PURPOSE_C_REND_JOINED)
58  ctf_enum_value("C_HSDIR_GET", CIRCUIT_PURPOSE_C_HSDIR_GET)
59 
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)
63 
64  /* Service Side. */
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)
70 
71  /* Misc. */
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)
75 
76  /* VanGuard */
77  ctf_enum_value("HS_VANGUARDS", CIRCUIT_PURPOSE_HS_VANGUARDS)
78  )
79 )
80 
81 /*
82  * Circuit End Reasons
83  *
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.
87  */
88 TRACEPOINT_ENUM(tor_circuit, end_reason,
89  TP_ENUM_VALUES(
90  /* Local reasons. */
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)
108 
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)
135  )
136 )
137 
138 /*
139  * Circuit State
140  *
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.
144  */
145 TRACEPOINT_ENUM(tor_circuit, state,
146  TP_ENUM_VALUES(
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)
152  )
153 )
154 
155 /*
156  * Event Class
157  *
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.
161  */
162 
163 /* Class for origin circuit. */
164 TRACEPOINT_EVENT_CLASS(tor_circuit, origin_circuit_t_class,
165  TP_ARGS(const origin_circuit_t *, circ),
166  TP_FIELDS(
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)
170  )
171 )
172 
173 /* Class for or circuit. */
174 TRACEPOINT_EVENT_CLASS(tor_circuit, or_circuit_t_class,
175  TP_ARGS(const or_circuit_t *, circ),
176  TP_FIELDS(
177  ctf_enum(tor_circuit, purpose, int, purpose, TO_CIRCUIT(circ)->purpose)
178  ctf_enum(tor_circuit, state, int, state, TO_CIRCUIT(circ)->state)
179  )
180 )
181 
182 /*
183  * Origin circuit events.
184  *
185  * Tracepoint use the origin_circuit_t object.
186  */
187 
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)
191 )
192 
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)
196 )
197 
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)
201 )
202 
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)
206 )
207 
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)
213 )
214 
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)
219 )
220 
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),
224  TP_FIELDS(
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,
229  DIGEST_LEN)
230  )
231 )
232 
233 /* Tracepoint emitted when an origin circuit sends out an intermediate onion
234  * skin. */
235 TRACEPOINT_EVENT(tor_circuit, intermediate_onion_skin,
236  TP_ARGS(const origin_circuit_t *, circ, const crypt_path_t *, hop),
237  TP_FIELDS(
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,
242  DIGEST_LEN)
243  )
244 )
245 
246 /*
247  * OR circuit events.
248  *
249  * Tracepoint use the or_circuit_t object.
250  */
251 
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)
255 )
256 
257 /*
258  * General circuit events.
259  *
260  * Tracepoint use the circuit_t object.
261  */
262 
263 /* Tracepoint emitted when a circuit is freed. */
264 TRACEPOINT_EVENT(tor_circuit, free,
265  TP_ARGS(const circuit_t *, circ),
266  TP_FIELDS(
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)
272  )
273 )
274 
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),
278  TP_FIELDS(
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)
288  )
289 )
290 
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),
294  TP_FIELDS(
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)
301  )
302 )
303 
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),
307  TP_FIELDS(
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)
314  )
315 )
316 
317 #endif /* LTTNG_CIRCUIT_INC || TRACEPOINT_HEADER_MULTI_READ */
318 
319 /* Must be included after the probes declaration. */
320 #include <lttng/tracepoint-event.h>
321 
322 #endif /* USE_TRACING_INSTRUMENTATION_LTTNG */
origin_circuit_t * TO_ORIGIN_CIRCUIT(circuit_t *x)
Definition: circuitlist.c:166
#define CIRCUIT_PURPOSE_S_CONNECT_REND
Definition: circuitlist.h:107
#define CIRCUIT_STATE_ONIONSKIN_PENDING
Definition: circuitlist.h:23
#define CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT
Definition: circuitlist.h:93
#define CIRCUIT_PURPOSE_REND_POINT_WAITING
Definition: circuitlist.h:45
#define CIRCUIT_PURPOSE_PATH_BIAS_TESTING
Definition: circuitlist.h:123
#define CIRCUIT_STATE_OPEN
Definition: circuitlist.h:32
#define CIRCUIT_STATE_BUILDING
Definition: circuitlist.h:21
#define CIRCUIT_PURPOSE_C_REND_JOINED
Definition: circuitlist.h:88
#define CIRCUIT_PURPOSE_S_INTRO
Definition: circuitlist.h:104
#define CIRCUIT_PURPOSE_INTRO_POINT
Definition: circuitlist.h:42
#define CIRCUIT_PURPOSE_CONTROLLER
Definition: circuitlist.h:121
#define CIRCUIT_IS_ORIGIN(c)
Definition: circuitlist.h:147
#define CIRCUIT_PURPOSE_C_CIRCUIT_PADDING
Definition: circuitlist.h:95
#define CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED
Definition: circuitlist.h:86
#define CIRCUIT_STATE_GUARD_WAIT
Definition: circuitlist.h:30
#define CIRCUIT_PURPOSE_TESTING
Definition: circuitlist.h:118
#define CIRCUIT_PURPOSE_OR
Definition: circuitlist.h:39
#define CIRCUIT_STATE_CHAN_WAIT
Definition: circuitlist.h:26
#define CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT
Definition: circuitlist.h:76
#define CIRCUIT_PURPOSE_S_REND_JOINED
Definition: circuitlist.h:110
#define CIRCUIT_PURPOSE_C_REND_READY
Definition: circuitlist.h:83
#define CIRCUIT_PURPOSE_S_HSDIR_POST
Definition: circuitlist.h:112
#define CIRCUIT_PURPOSE_C_HSDIR_GET
Definition: circuitlist.h:90
#define CIRCUIT_PURPOSE_REND_ESTABLISHED
Definition: circuitlist.h:47
#define CIRCUIT_PURPOSE_C_INTRODUCE_ACKED
Definition: circuitlist.h:79
#define CIRCUIT_PURPOSE_C_INTRODUCING
Definition: circuitlist.h:73
#define CIRCUIT_PURPOSE_S_ESTABLISH_INTRO
Definition: circuitlist.h:101
#define CIRCUIT_PURPOSE_C_ESTABLISH_REND
Definition: circuitlist.h:81
#define CIRCUIT_PURPOSE_C_GENERAL
Definition: circuitlist.h:70
#define CIRCUIT_PURPOSE_HS_VANGUARDS
Definition: circuitlist.h:131
#define DIGEST_LEN
Definition: digest_sizes.h:20
#define END_CIRC_REASON_NOPATH
Definition: or.h:304
#define TO_CIRCUIT(x)
Definition: or.h:845
#define END_CIRC_REASON_MEASUREMENT_EXPIRED
Definition: or.h:301
#define END_CIRC_REASON_FLAG_REMOTE
Definition: or.h:329
#define END_CIRC_AT_ORIGIN
Definition: or.h:306