]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_trace.h
Merge pull request #12603 from opensourcerouting/fix/deprecate_bgp_stuff_some
[mirror_frr.git] / bgpd / bgp_trace.h
1 /* Tracing for BGP
2 *
3 * Copyright (C) 2020 NVIDIA Corporation
4 * Quentin Young
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #if !defined(_BGP_TRACE_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
22 #define _BGP_TRACE_H
23
24 #include "lib/trace.h"
25
26 #ifdef HAVE_LTTNG
27
28 #undef TRACEPOINT_PROVIDER
29 #define TRACEPOINT_PROVIDER frr_bgp
30
31 #undef TRACEPOINT_INCLUDE
32 #define TRACEPOINT_INCLUDE "bgpd/bgp_trace.h"
33
34 #include <lttng/tracepoint.h>
35
36 #include "bgpd/bgpd.h"
37 #include "bgpd/bgp_attr.h"
38 #include "lib/stream.h"
39 #include "bgpd/bgp_evpn_private.h"
40 #include "bgpd/bgp_evpn_mh.h"
41
42
43 /* clang-format off */
44
45 TRACEPOINT_EVENT_CLASS(
46 frr_bgp,
47 packet_process,
48 TP_ARGS(struct peer *, peer, bgp_size_t, size),
49 TP_FIELDS(
50 ctf_string(peer, PEER_HOSTNAME(peer))
51 )
52 )
53
54 #define PKT_PROCESS_TRACEPOINT_INSTANCE(name) \
55 TRACEPOINT_EVENT_INSTANCE( \
56 frr_bgp, packet_process, name, \
57 TP_ARGS(struct peer *, peer, bgp_size_t, size)) \
58 TRACEPOINT_LOGLEVEL(frr_bgp, name, TRACE_INFO)
59
60 PKT_PROCESS_TRACEPOINT_INSTANCE(open_process)
61 PKT_PROCESS_TRACEPOINT_INSTANCE(keepalive_process)
62 PKT_PROCESS_TRACEPOINT_INSTANCE(update_process)
63 PKT_PROCESS_TRACEPOINT_INSTANCE(notification_process)
64 PKT_PROCESS_TRACEPOINT_INSTANCE(capability_process)
65 PKT_PROCESS_TRACEPOINT_INSTANCE(refresh_process)
66
67 TRACEPOINT_EVENT(
68 frr_bgp,
69 packet_read,
70 TP_ARGS(struct peer *, peer, struct stream *, pkt),
71 TP_FIELDS(
72 ctf_string(peer, PEER_HOSTNAME(peer))
73 ctf_sequence_hex(uint8_t, packet, pkt->data, size_t,
74 STREAM_READABLE(pkt))
75 )
76 )
77
78 TRACEPOINT_LOGLEVEL(frr_bgp, packet_read, TRACE_INFO)
79
80 TRACEPOINT_EVENT(
81 frr_bgp,
82 process_update,
83 TP_ARGS(struct peer *, peer, char *, pfx, uint32_t, addpath_id, afi_t,
84 afi, safi_t, safi, struct attr *, attr),
85 TP_FIELDS(
86 ctf_string(peer, PEER_HOSTNAME(peer))
87 ctf_string(prefix, pfx)
88 ctf_integer(uint32_t, addpath_id, addpath_id)
89 ctf_integer(afi_t, afi, afi)
90 ctf_integer(safi_t, safi, safi)
91 ctf_integer_hex(intptr_t, attribute_ptr, attr)
92 )
93 )
94
95 TRACEPOINT_LOGLEVEL(frr_bgp, process_update, TRACE_INFO)
96
97 TRACEPOINT_EVENT(
98 frr_bgp,
99 input_filter,
100 TP_ARGS(struct peer *, peer, char *, pfx, afi_t, afi, safi_t, safi,
101 const char *, result),
102 TP_FIELDS(
103 ctf_string(peer, PEER_HOSTNAME(peer))
104 ctf_string(prefix, pfx)
105 ctf_integer(afi_t, afi, afi)
106 ctf_integer(safi_t, safi, safi)
107 ctf_string(action, result)
108 )
109 )
110
111 TRACEPOINT_LOGLEVEL(frr_bgp, input_filter, TRACE_INFO)
112
113 TRACEPOINT_EVENT(
114 frr_bgp,
115 output_filter,
116 TP_ARGS(struct peer *, peer, char *, pfx, afi_t, afi, safi_t, safi,
117 const char *, result),
118 TP_FIELDS(
119 ctf_string(peer, PEER_HOSTNAME(peer))
120 ctf_string(prefix, pfx)
121 ctf_integer(afi_t, afi, afi)
122 ctf_integer(safi_t, safi, safi)
123 ctf_string(action, result)
124 )
125 )
126
127 TRACEPOINT_LOGLEVEL(frr_bgp, output_filter, TRACE_INFO)
128
129 /* BMP tracepoints */
130
131 /* BMP mirrors a packet to all mirror-enabled targets */
132 TRACEPOINT_EVENT(
133 frr_bgp,
134 bmp_mirror_packet,
135 TP_ARGS(struct peer *, peer, uint8_t, type, struct stream *, pkt),
136 TP_FIELDS(
137 ctf_string(peer, PEER_HOSTNAME(peer))
138 ctf_integer(uint8_t, type, type)
139 ctf_sequence_hex(uint8_t, packet, pkt->data, size_t,
140 STREAM_READABLE(pkt))
141 )
142 )
143
144 TRACEPOINT_LOGLEVEL(frr_bgp, bmp_mirror_packet, TRACE_INFO)
145
146
147 /* BMP sends an EOR */
148 TRACEPOINT_EVENT(
149 frr_bgp,
150 bmp_eor,
151 TP_ARGS(afi_t, afi, safi_t, safi, uint8_t, flags),
152 TP_FIELDS(
153 ctf_integer(afi_t, afi, afi)
154 ctf_integer(safi_t, safi, safi)
155 ctf_integer(uint8_t, flags, flags)
156 )
157 )
158
159 TRACEPOINT_LOGLEVEL(frr_bgp, bmp_eor, TRACE_INFO)
160
161
162 /* BMP updates its copy of the last OPEN a peer sent */
163 TRACEPOINT_EVENT(
164 frr_bgp,
165 bmp_update_saved_open,
166 TP_ARGS(struct peer *, peer, struct stream *, pkt),
167 TP_FIELDS(
168 ctf_string(peer, PEER_HOSTNAME(peer))
169 ctf_sequence_hex(uint8_t, packet, pkt->data, size_t,
170 STREAM_READABLE(pkt))
171 )
172 )
173
174 TRACEPOINT_LOGLEVEL(frr_bgp, bmp_update_saved_open, TRACE_DEBUG)
175
176
177 /* BMP is notified of a peer status change internally */
178 TRACEPOINT_EVENT(
179 frr_bgp,
180 bmp_peer_status_changed,
181 TP_ARGS(struct peer *, peer),
182 TP_FIELDS(
183 ctf_string(peer, PEER_HOSTNAME(peer))
184 )
185 )
186
187 TRACEPOINT_LOGLEVEL(frr_bgp, bmp_peer_status_changed, TRACE_DEBUG)
188
189
190 /*
191 * BMP is notified that a peer has transitioned in the opposite direction of
192 * Established internally
193 */
194 TRACEPOINT_EVENT(
195 frr_bgp,
196 bmp_peer_backward_transition,
197 TP_ARGS(struct peer *, peer),
198 TP_FIELDS(
199 ctf_string(peer, PEER_HOSTNAME(peer))
200 )
201 )
202
203 TRACEPOINT_LOGLEVEL(frr_bgp, bmp_peer_backward, TRACE_DEBUG)
204
205
206 /*
207 * BMP is hooked for a route process
208 */
209 TRACEPOINT_EVENT(
210 frr_bgp,
211 bmp_process,
212 TP_ARGS(struct peer *, peer, char *, pfx, afi_t,
213 afi, safi_t, safi, bool, withdraw),
214 TP_FIELDS(
215 ctf_string(peer, PEER_HOSTNAME(peer))
216 ctf_string(prefix, pfx)
217 ctf_integer(afi_t, afi, afi)
218 ctf_integer(safi_t, safi, safi)
219 ctf_integer(bool, withdraw, withdraw)
220 )
221 )
222
223 TRACEPOINT_LOGLEVEL(frr_bgp, bmp_process, TRACE_DEBUG)
224
225 /*
226 * bgp_dest_lock/bgp_dest_unlock
227 */
228 TRACEPOINT_EVENT(
229 frr_bgp,
230 bgp_dest_lock,
231 TP_ARGS(struct bgp_dest *, dest),
232 TP_FIELDS(
233 ctf_string(prefix, bgp_dest_get_prefix_str(dest))
234 ctf_integer(unsigned int, count, bgp_dest_get_lock_count(dest))
235 )
236 )
237 TRACEPOINT_LOGLEVEL(frr_bgp, bgp_dest_lock, TRACE_INFO)
238
239 TRACEPOINT_EVENT(
240 frr_bgp,
241 bgp_dest_unlock,
242 TP_ARGS(struct bgp_dest *, dest),
243 TP_FIELDS(
244 ctf_string(prefix, bgp_dest_get_prefix_str(dest))
245 ctf_integer(unsigned int, count, bgp_dest_get_lock_count(dest))
246 )
247 )
248 TRACEPOINT_LOGLEVEL(frr_bgp, bgp_dest_unlock, TRACE_INFO)
249
250 /*
251 * peer_lock/peer_unlock
252 */
253 TRACEPOINT_EVENT(
254 frr_bgp,
255 bgp_peer_lock,
256 TP_ARGS(struct peer *, peer,
257 const char *, name),
258 TP_FIELDS(
259 ctf_string(caller, name)
260 ctf_string(peer, PEER_HOSTNAME(peer))
261 ctf_integer(unsigned int, count, peer->lock)
262 )
263 )
264 TRACEPOINT_LOGLEVEL(frr_bgp, bgp_peer_lock, TRACE_INFO)
265
266 TRACEPOINT_EVENT(
267 frr_bgp,
268 bgp_peer_unlock,
269 TP_ARGS(struct peer *, peer,
270 const char *, name),
271 TP_FIELDS(
272 ctf_string(caller, name)
273 ctf_string(peer, PEER_HOSTNAME(peer))
274 ctf_integer(unsigned int, count, peer->lock)
275 )
276 )
277 TRACEPOINT_LOGLEVEL(frr_bgp, bgp_peer_unlock, TRACE_INFO)
278
279 /*
280 * bgp_path_info_add/bgp_path_info_free
281 */
282 TRACEPOINT_EVENT(
283 frr_bgp,
284 bgp_path_info_add,
285 TP_ARGS(struct bgp_dest *, dest,
286 struct bgp_path_info *, bpi,
287 const char *, name),
288 TP_FIELDS(
289 ctf_string(caller, name)
290 ctf_string(prefix, bgp_dest_get_prefix_str(dest))
291 ctf_string(peer, PEER_HOSTNAME(bpi->peer))
292 ctf_integer(unsigned int, dest_lock,
293 bgp_dest_get_lock_count(dest))
294 ctf_integer(unsigned int, peer_lock, bpi->peer->lock)
295 )
296 )
297 TRACEPOINT_LOGLEVEL(frr_bgp, bgp_path_info_add, TRACE_INFO)
298
299 TRACEPOINT_EVENT(
300 frr_bgp,
301 bgp_path_info_free,
302 TP_ARGS(struct bgp_path_info *, bpi,
303 const char *, name),
304 TP_FIELDS(
305 ctf_string(caller, name)
306 ctf_string(prefix, bgp_dest_get_prefix_str(bpi->net))
307 ctf_string(peer, PEER_HOSTNAME(bpi->peer))
308 ctf_integer(unsigned int, dest_lock,
309 bgp_dest_get_lock_count(bpi->net))
310 ctf_integer(unsigned int, peer_lock, bpi->peer->lock)
311 )
312 )
313 TRACEPOINT_LOGLEVEL(frr_bgp, bgp_path_info_free, TRACE_INFO)
314
315 TRACEPOINT_EVENT(
316 frr_bgp,
317 evpn_mac_ip_zsend,
318 TP_ARGS(int, add, struct bgpevpn *, vpn,
319 const struct prefix_evpn *, pfx,
320 struct in_addr, vtep, esi_t *, esi),
321 TP_FIELDS(
322 ctf_string(action, add ? "add" : "del")
323 ctf_integer(vni_t, vni, vpn->vni)
324 ctf_array(unsigned char, mac, &pfx->prefix.macip_addr.mac,
325 sizeof(struct ethaddr))
326 ctf_array(unsigned char, ip, &pfx->prefix.macip_addr.ip,
327 sizeof(struct ipaddr))
328 ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
329 ctf_array(unsigned char, esi, esi, sizeof(esi_t))
330 )
331 )
332 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mac_ip_zsend, TRACE_INFO)
333
334 TRACEPOINT_EVENT(
335 frr_bgp,
336 evpn_bum_vtep_zsend,
337 TP_ARGS(int, add, struct bgpevpn *, vpn,
338 const struct prefix_evpn *, pfx),
339 TP_FIELDS(
340 ctf_string(action, add ? "add" : "del")
341 ctf_integer(vni_t, vni, vpn->vni)
342 ctf_integer_network_hex(unsigned int, vtep,
343 pfx->prefix.imet_addr.ip.ipaddr_v4.s_addr)
344 )
345 )
346 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_bum_vtep_zsend, TRACE_INFO)
347
348 TRACEPOINT_EVENT(
349 frr_bgp,
350 evpn_mh_vtep_zsend,
351 TP_ARGS(bool, add, struct bgp_evpn_es *, es,
352 struct bgp_evpn_es_vtep *, es_vtep),
353 TP_FIELDS(
354 ctf_string(action, add ? "add" : "del")
355 ctf_string(esi, es->esi_str)
356 ctf_string(vtep, es_vtep->vtep_str)
357 )
358 )
359 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_vtep_zsend, TRACE_INFO)
360
361 TRACEPOINT_EVENT(
362 frr_bgp,
363 evpn_mh_nhg_zsend,
364 TP_ARGS(bool, add, bool, type_v4, uint32_t, nhg_id,
365 struct bgp_evpn_es_vrf *, es_vrf),
366 TP_FIELDS(
367 ctf_string(action, add ? "add" : "del")
368 ctf_string(type, type_v4 ? "v4" : "v6")
369 ctf_integer(unsigned int, nhg, nhg_id)
370 ctf_string(esi, es_vrf->es->esi_str)
371 ctf_integer(int, vrf, es_vrf->bgp_vrf->vrf_id)
372 )
373 )
374 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_nhg_zsend, TRACE_INFO)
375
376 TRACEPOINT_EVENT(
377 frr_bgp,
378 evpn_mh_nh_zsend,
379 TP_ARGS(uint32_t, nhg_id, struct bgp_evpn_es_vtep *, vtep,
380 struct bgp_evpn_es_vrf *, es_vrf),
381 TP_FIELDS(
382 ctf_integer(unsigned int, nhg, nhg_id)
383 ctf_string(vtep, vtep->vtep_str)
384 ctf_integer(int, svi, es_vrf->bgp_vrf->l3vni_svi_ifindex)
385 )
386 )
387 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_nh_zsend, TRACE_INFO)
388
389 TRACEPOINT_EVENT(
390 frr_bgp,
391 evpn_mh_nh_rmac_zsend,
392 TP_ARGS(bool, add, struct bgp_evpn_nh *, nh),
393 TP_FIELDS(
394 ctf_string(action, add ? "add" : "del")
395 ctf_integer(int, vrf, nh->bgp_vrf->vrf_id)
396 ctf_string(nh, nh->nh_str)
397 ctf_array(unsigned char, rmac, &nh->rmac,
398 sizeof(struct ethaddr))
399 )
400 )
401 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_nh_rmac_zsend, TRACE_INFO)
402
403 TRACEPOINT_EVENT(
404 frr_bgp,
405 evpn_mh_local_es_add_zrecv,
406 TP_ARGS(esi_t *, esi, struct in_addr, vtep,
407 uint8_t, active, uint8_t, bypass, uint16_t, df_pref),
408 TP_FIELDS(
409 ctf_array(unsigned char, esi, esi, sizeof(esi_t))
410 ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
411 ctf_integer(uint8_t, active, active)
412 ctf_integer(uint8_t, bypass, bypass)
413 ctf_integer(uint16_t, df_pref, df_pref)
414 )
415 )
416 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_local_es_add_zrecv, TRACE_INFO)
417
418 TRACEPOINT_EVENT(
419 frr_bgp,
420 evpn_mh_local_es_del_zrecv,
421 TP_ARGS(esi_t *, esi),
422 TP_FIELDS(
423 ctf_array(unsigned char, esi, esi, sizeof(esi_t))
424 )
425 )
426 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_local_es_del_zrecv, TRACE_INFO)
427
428 TRACEPOINT_EVENT(
429 frr_bgp,
430 evpn_mh_local_es_evi_add_zrecv,
431 TP_ARGS(esi_t *, esi, vni_t, vni),
432 TP_FIELDS(
433 ctf_array(unsigned char, esi, esi, sizeof(esi_t))
434 ctf_integer(vni_t, vni, vni)
435 )
436 )
437 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_local_es_evi_add_zrecv, TRACE_INFO)
438
439 TRACEPOINT_EVENT(
440 frr_bgp,
441 evpn_mh_local_es_evi_del_zrecv,
442 TP_ARGS(esi_t *, esi, vni_t, vni),
443 TP_FIELDS(
444 ctf_array(unsigned char, esi, esi, sizeof(esi_t))
445 ctf_integer(vni_t, vni, vni)
446 )
447 )
448 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_local_es_evi_del_zrecv, TRACE_INFO)
449
450 TRACEPOINT_EVENT(
451 frr_bgp,
452 evpn_local_vni_add_zrecv,
453 TP_ARGS(vni_t, vni, struct in_addr, vtep, vrf_id_t, vrf,
454 struct in_addr, mc_grp),
455 TP_FIELDS(
456 ctf_integer(vni_t, vni, vni)
457 ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
458 ctf_integer_network_hex(unsigned int, mc_grp,
459 mc_grp.s_addr)
460 ctf_integer(int, vrf, vrf)
461 )
462 )
463 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_vni_add_zrecv, TRACE_INFO)
464
465 TRACEPOINT_EVENT(
466 frr_bgp,
467 evpn_local_vni_del_zrecv,
468 TP_ARGS(vni_t, vni),
469 TP_FIELDS(
470 ctf_integer(vni_t, vni, vni)
471 )
472 )
473 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_vni_del_zrecv, TRACE_INFO)
474
475 TRACEPOINT_EVENT(
476 frr_bgp,
477 evpn_local_macip_add_zrecv,
478 TP_ARGS(vni_t, vni, struct ethaddr *, mac,
479 struct ipaddr *, ip, uint32_t, flags,
480 uint32_t, seqnum, esi_t *, esi),
481 TP_FIELDS(
482 ctf_integer(vni_t, vni, vni)
483 ctf_array(unsigned char, mac, mac,
484 sizeof(struct ethaddr))
485 ctf_array(unsigned char, ip, ip,
486 sizeof(struct ipaddr))
487 ctf_integer(uint32_t, flags, flags)
488 ctf_integer(uint32_t, seq, seqnum)
489 ctf_array(unsigned char, esi, esi, sizeof(esi_t))
490 )
491 )
492 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_macip_add_zrecv, TRACE_INFO)
493
494 TRACEPOINT_EVENT(
495 frr_bgp,
496 evpn_local_macip_del_zrecv,
497 TP_ARGS(vni_t, vni, struct ethaddr *, mac, struct ipaddr *, ip,
498 int, state),
499 TP_FIELDS(
500 ctf_integer(vni_t, vni, vni)
501 ctf_array(unsigned char, mac, mac,
502 sizeof(struct ethaddr))
503 ctf_array(unsigned char, ip, ip,
504 sizeof(struct ipaddr))
505 ctf_integer(int, state, state)
506 )
507 )
508 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_macip_del_zrecv, TRACE_INFO)
509
510 TRACEPOINT_EVENT(
511 frr_bgp,
512 evpn_local_l3vni_add_zrecv,
513 TP_ARGS(vni_t, vni, vrf_id_t, vrf,
514 struct ethaddr *, svi_rmac,
515 struct ethaddr *, vrr_rmac, int, filter,
516 struct in_addr, vtep, int, svi_ifindex,
517 bool, anycast_mac),
518 TP_FIELDS(
519 ctf_integer(vni_t, vni, vni)
520 ctf_integer(int, vrf, vrf)
521 ctf_array(unsigned char, svi_rmac, svi_rmac,
522 sizeof(struct ethaddr))
523 ctf_array(unsigned char, vrr_rmac, vrr_rmac,
524 sizeof(struct ethaddr))
525 ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
526 ctf_integer(int, filter, filter)
527 ctf_integer(int, svi_ifindex, svi_ifindex)
528 ctf_string(anycast_mac, anycast_mac ? "y" : "n")
529 )
530 )
531 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_l3vni_add_zrecv, TRACE_INFO)
532
533 TRACEPOINT_EVENT(
534 frr_bgp,
535 evpn_local_l3vni_del_zrecv,
536 TP_ARGS(vni_t, vni, vrf_id_t, vrf),
537 TP_FIELDS(
538 ctf_integer(vni_t, vni, vni)
539 ctf_integer(int, vrf, vrf)
540 )
541 )
542 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_l3vni_del_zrecv, TRACE_INFO)
543 /* clang-format on */
544
545 #include <lttng/tracepoint-event.h>
546
547 #endif /* HAVE_LTTNG */
548
549 #endif /* _BGP_TRACE_H */