]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_trace.h
Merge pull request #12390 from sigeryang/vrrp-interop
[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 TRACEPOINT_EVENT(
251 frr_bgp,
252 evpn_mac_ip_zsend,
253 TP_ARGS(int, add, struct bgpevpn *, vpn,
254 const struct prefix_evpn *, pfx,
255 struct in_addr, vtep, esi_t *, esi),
256 TP_FIELDS(
257 ctf_string(action, add ? "add" : "del")
258 ctf_integer(vni_t, vni, vpn->vni)
259 ctf_array(unsigned char, mac, &pfx->prefix.macip_addr.mac,
260 sizeof(struct ethaddr))
261 ctf_array(unsigned char, ip, &pfx->prefix.macip_addr.ip,
262 sizeof(struct ipaddr))
263 ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
264 ctf_array(unsigned char, esi, esi, sizeof(esi_t))
265 )
266 )
267 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mac_ip_zsend, TRACE_INFO)
268
269 TRACEPOINT_EVENT(
270 frr_bgp,
271 evpn_bum_vtep_zsend,
272 TP_ARGS(int, add, struct bgpevpn *, vpn,
273 const struct prefix_evpn *, pfx),
274 TP_FIELDS(
275 ctf_string(action, add ? "add" : "del")
276 ctf_integer(vni_t, vni, vpn->vni)
277 ctf_integer_network_hex(unsigned int, vtep,
278 pfx->prefix.imet_addr.ip.ipaddr_v4.s_addr)
279 )
280 )
281 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_bum_vtep_zsend, TRACE_INFO)
282
283 TRACEPOINT_EVENT(
284 frr_bgp,
285 evpn_mh_vtep_zsend,
286 TP_ARGS(bool, add, struct bgp_evpn_es *, es,
287 struct bgp_evpn_es_vtep *, es_vtep),
288 TP_FIELDS(
289 ctf_string(action, add ? "add" : "del")
290 ctf_string(esi, es->esi_str)
291 ctf_string(vtep, es_vtep->vtep_str)
292 )
293 )
294 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_vtep_zsend, TRACE_INFO)
295
296 TRACEPOINT_EVENT(
297 frr_bgp,
298 evpn_mh_nhg_zsend,
299 TP_ARGS(bool, add, bool, type_v4, uint32_t, nhg_id,
300 struct bgp_evpn_es_vrf *, es_vrf),
301 TP_FIELDS(
302 ctf_string(action, add ? "add" : "del")
303 ctf_string(type, type_v4 ? "v4" : "v6")
304 ctf_integer(unsigned int, nhg, nhg_id)
305 ctf_string(esi, es_vrf->es->esi_str)
306 ctf_integer(int, vrf, es_vrf->bgp_vrf->vrf_id)
307 )
308 )
309 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_nhg_zsend, TRACE_INFO)
310
311 TRACEPOINT_EVENT(
312 frr_bgp,
313 evpn_mh_nh_zsend,
314 TP_ARGS(uint32_t, nhg_id, struct bgp_evpn_es_vtep *, vtep,
315 struct bgp_evpn_es_vrf *, es_vrf),
316 TP_FIELDS(
317 ctf_integer(unsigned int, nhg, nhg_id)
318 ctf_string(vtep, vtep->vtep_str)
319 ctf_integer(int, svi, es_vrf->bgp_vrf->l3vni_svi_ifindex)
320 )
321 )
322 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_nh_zsend, TRACE_INFO)
323
324 TRACEPOINT_EVENT(
325 frr_bgp,
326 evpn_mh_nh_rmac_zsend,
327 TP_ARGS(bool, add, struct bgp_evpn_nh *, nh),
328 TP_FIELDS(
329 ctf_string(action, add ? "add" : "del")
330 ctf_integer(int, vrf, nh->bgp_vrf->vrf_id)
331 ctf_string(nh, nh->nh_str)
332 ctf_array(unsigned char, rmac, &nh->rmac,
333 sizeof(struct ethaddr))
334 )
335 )
336 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_nh_rmac_zsend, TRACE_INFO)
337
338 TRACEPOINT_EVENT(
339 frr_bgp,
340 evpn_mh_local_es_add_zrecv,
341 TP_ARGS(esi_t *, esi, struct in_addr, vtep,
342 uint8_t, active, uint8_t, bypass, uint16_t, df_pref),
343 TP_FIELDS(
344 ctf_array(unsigned char, esi, esi, sizeof(esi_t))
345 ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
346 ctf_integer(uint8_t, active, active)
347 ctf_integer(uint8_t, bypass, bypass)
348 ctf_integer(uint16_t, df_pref, df_pref)
349 )
350 )
351 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_local_es_add_zrecv, TRACE_INFO)
352
353 TRACEPOINT_EVENT(
354 frr_bgp,
355 evpn_mh_local_es_del_zrecv,
356 TP_ARGS(esi_t *, esi),
357 TP_FIELDS(
358 ctf_array(unsigned char, esi, esi, sizeof(esi_t))
359 )
360 )
361 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_local_es_del_zrecv, TRACE_INFO)
362
363 TRACEPOINT_EVENT(
364 frr_bgp,
365 evpn_mh_local_es_evi_add_zrecv,
366 TP_ARGS(esi_t *, esi, vni_t, vni),
367 TP_FIELDS(
368 ctf_array(unsigned char, esi, esi, sizeof(esi_t))
369 ctf_integer(vni_t, vni, vni)
370 )
371 )
372 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_local_es_evi_add_zrecv, TRACE_INFO)
373
374 TRACEPOINT_EVENT(
375 frr_bgp,
376 evpn_mh_local_es_evi_del_zrecv,
377 TP_ARGS(esi_t *, esi, vni_t, vni),
378 TP_FIELDS(
379 ctf_array(unsigned char, esi, esi, sizeof(esi_t))
380 ctf_integer(vni_t, vni, vni)
381 )
382 )
383 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_mh_local_es_evi_del_zrecv, TRACE_INFO)
384
385 TRACEPOINT_EVENT(
386 frr_bgp,
387 evpn_local_vni_add_zrecv,
388 TP_ARGS(vni_t, vni, struct in_addr, vtep, vrf_id_t, vrf,
389 struct in_addr, mc_grp),
390 TP_FIELDS(
391 ctf_integer(vni_t, vni, vni)
392 ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
393 ctf_integer_network_hex(unsigned int, mc_grp,
394 mc_grp.s_addr)
395 ctf_integer(int, vrf, vrf)
396 )
397 )
398 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_vni_add_zrecv, TRACE_INFO)
399
400 TRACEPOINT_EVENT(
401 frr_bgp,
402 evpn_local_vni_del_zrecv,
403 TP_ARGS(vni_t, vni),
404 TP_FIELDS(
405 ctf_integer(vni_t, vni, vni)
406 )
407 )
408 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_vni_del_zrecv, TRACE_INFO)
409
410 TRACEPOINT_EVENT(
411 frr_bgp,
412 evpn_local_macip_add_zrecv,
413 TP_ARGS(vni_t, vni, struct ethaddr *, mac,
414 struct ipaddr *, ip, uint32_t, flags,
415 uint32_t, seqnum, esi_t *, esi),
416 TP_FIELDS(
417 ctf_integer(vni_t, vni, vni)
418 ctf_array(unsigned char, mac, mac,
419 sizeof(struct ethaddr))
420 ctf_array(unsigned char, ip, ip,
421 sizeof(struct ipaddr))
422 ctf_integer(uint32_t, flags, flags)
423 ctf_integer(uint32_t, seq, seqnum)
424 ctf_array(unsigned char, esi, esi, sizeof(esi_t))
425 )
426 )
427 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_macip_add_zrecv, TRACE_INFO)
428
429 TRACEPOINT_EVENT(
430 frr_bgp,
431 evpn_local_macip_del_zrecv,
432 TP_ARGS(vni_t, vni, struct ethaddr *, mac, struct ipaddr *, ip,
433 int, state),
434 TP_FIELDS(
435 ctf_integer(vni_t, vni, vni)
436 ctf_array(unsigned char, mac, mac,
437 sizeof(struct ethaddr))
438 ctf_array(unsigned char, ip, ip,
439 sizeof(struct ipaddr))
440 ctf_integer(int, state, state)
441 )
442 )
443 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_macip_del_zrecv, TRACE_INFO)
444
445 TRACEPOINT_EVENT(
446 frr_bgp,
447 evpn_local_l3vni_add_zrecv,
448 TP_ARGS(vni_t, vni, vrf_id_t, vrf,
449 struct ethaddr *, svi_rmac,
450 struct ethaddr *, vrr_rmac, int, filter,
451 struct in_addr, vtep, int, svi_ifindex,
452 bool, anycast_mac),
453 TP_FIELDS(
454 ctf_integer(vni_t, vni, vni)
455 ctf_integer(int, vrf, vrf)
456 ctf_array(unsigned char, svi_rmac, svi_rmac,
457 sizeof(struct ethaddr))
458 ctf_array(unsigned char, vrr_rmac, vrr_rmac,
459 sizeof(struct ethaddr))
460 ctf_integer_network_hex(unsigned int, vtep, vtep.s_addr)
461 ctf_integer(int, filter, filter)
462 ctf_integer(int, svi_ifindex, svi_ifindex)
463 ctf_string(anycast_mac, anycast_mac ? "y" : "n")
464 )
465 )
466 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_l3vni_add_zrecv, TRACE_INFO)
467
468 TRACEPOINT_EVENT(
469 frr_bgp,
470 evpn_local_l3vni_del_zrecv,
471 TP_ARGS(vni_t, vni, vrf_id_t, vrf),
472 TP_FIELDS(
473 ctf_integer(vni_t, vni, vni)
474 ctf_integer(int, vrf, vrf)
475 )
476 )
477 TRACEPOINT_LOGLEVEL(frr_bgp, evpn_local_l3vni_del_zrecv, TRACE_INFO)
478 /* clang-format on */
479
480 #include <lttng/tracepoint-event.h>
481
482 #endif /* HAVE_LTTNG */
483
484 #endif /* _BGP_TRACE_H */