]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_trace.h
Merge pull request #8887 from LabNConsulting/chopps/fix-test-retries
[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 "lib/stream.h"
38
39 /* clang-format off */
40
41 TRACEPOINT_EVENT_CLASS(
42 frr_bgp,
43 packet_process,
44 TP_ARGS(struct peer *, peer, bgp_size_t, size),
45 TP_FIELDS(
46 ctf_string(peer, PEER_HOSTNAME(peer))
47 )
48 )
49
50 #define PKT_PROCESS_TRACEPOINT_INSTANCE(name) \
51 TRACEPOINT_EVENT_INSTANCE( \
52 frr_bgp, packet_process, name, \
53 TP_ARGS(struct peer *, peer, bgp_size_t, size)) \
54 TRACEPOINT_LOGLEVEL(frr_bgp, name, TRACE_INFO)
55
56 PKT_PROCESS_TRACEPOINT_INSTANCE(open_process)
57 PKT_PROCESS_TRACEPOINT_INSTANCE(keepalive_process)
58 PKT_PROCESS_TRACEPOINT_INSTANCE(update_process)
59 PKT_PROCESS_TRACEPOINT_INSTANCE(notification_process)
60 PKT_PROCESS_TRACEPOINT_INSTANCE(capability_process)
61 PKT_PROCESS_TRACEPOINT_INSTANCE(refresh_process)
62
63 TRACEPOINT_EVENT(
64 frr_bgp,
65 packet_read,
66 TP_ARGS(struct peer *, peer, struct stream *, pkt),
67 TP_FIELDS(
68 ctf_string(peer, PEER_HOSTNAME(peer))
69 ctf_sequence_hex(uint8_t, packet, pkt->data, size_t,
70 STREAM_READABLE(pkt))
71 )
72 )
73
74 TRACEPOINT_LOGLEVEL(frr_bgp, packet_read, TRACE_INFO)
75
76 TRACEPOINT_EVENT(
77 frr_bgp,
78 process_update,
79 TP_ARGS(struct peer *, peer, char *, pfx, uint32_t, addpath_id, afi_t,
80 afi, safi_t, safi, struct attr *, attr),
81 TP_FIELDS(
82 ctf_string(peer, PEER_HOSTNAME(peer))
83 ctf_string(prefix, pfx)
84 ctf_integer(uint32_t, addpath_id, addpath_id)
85 ctf_integer(afi_t, afi, afi)
86 ctf_integer(safi_t, safi, safi)
87 ctf_integer_hex(intptr_t, attribute_ptr, attr)
88 )
89 )
90
91 TRACEPOINT_LOGLEVEL(frr_bgp, process_update, TRACE_INFO)
92
93 TRACEPOINT_EVENT(
94 frr_bgp,
95 input_filter,
96 TP_ARGS(struct peer *, peer, char *, pfx, afi_t, afi, safi_t, safi,
97 const char *, result),
98 TP_FIELDS(
99 ctf_string(peer, PEER_HOSTNAME(peer))
100 ctf_string(prefix, pfx)
101 ctf_integer(afi_t, afi, afi)
102 ctf_integer(safi_t, safi, safi)
103 ctf_string(action, result)
104 )
105 )
106
107 TRACEPOINT_LOGLEVEL(frr_bgp, input_filter, TRACE_INFO)
108
109 TRACEPOINT_EVENT(
110 frr_bgp,
111 output_filter,
112 TP_ARGS(struct peer *, peer, char *, pfx, afi_t, afi, safi_t, safi,
113 const char *, result),
114 TP_FIELDS(
115 ctf_string(peer, PEER_HOSTNAME(peer))
116 ctf_string(prefix, pfx)
117 ctf_integer(afi_t, afi, afi)
118 ctf_integer(safi_t, safi, safi)
119 ctf_string(action, result)
120 )
121 )
122
123 TRACEPOINT_LOGLEVEL(frr_bgp, output_filter, TRACE_INFO)
124
125 /* BMP tracepoints */
126
127 /* BMP mirrors a packet to all mirror-enabled targets */
128 TRACEPOINT_EVENT(
129 frr_bgp,
130 bmp_mirror_packet,
131 TP_ARGS(struct peer *, peer, uint8_t, type, struct stream *, pkt),
132 TP_FIELDS(
133 ctf_string(peer, PEER_HOSTNAME(peer))
134 ctf_integer(uint8_t, type, type)
135 ctf_sequence_hex(uint8_t, packet, pkt->data, size_t,
136 STREAM_READABLE(pkt))
137 )
138 )
139
140 TRACEPOINT_LOGLEVEL(frr_bgp, bmp_mirror_packet, TRACE_INFO)
141
142
143 /* BMP sends an EOR */
144 TRACEPOINT_EVENT(
145 frr_bgp,
146 bmp_eor,
147 TP_ARGS(afi_t, afi, safi_t, safi, uint8_t, flags),
148 TP_FIELDS(
149 ctf_integer(afi_t, afi, afi)
150 ctf_integer(safi_t, safi, safi)
151 ctf_integer(uint8_t, flags, flags)
152 )
153 )
154
155 TRACEPOINT_LOGLEVEL(frr_bgp, bmp_eor, TRACE_INFO)
156
157
158 /* BMP updates its copy of the last OPEN a peer sent */
159 TRACEPOINT_EVENT(
160 frr_bgp,
161 bmp_update_saved_open,
162 TP_ARGS(struct peer *, peer, struct stream *, pkt),
163 TP_FIELDS(
164 ctf_string(peer, PEER_HOSTNAME(peer))
165 ctf_sequence_hex(uint8_t, packet, pkt->data, size_t,
166 STREAM_READABLE(pkt))
167 )
168 )
169
170 TRACEPOINT_LOGLEVEL(frr_bgp, bmp_update_saved_open, TRACE_DEBUG)
171
172
173 /* BMP is notified of a peer status change internally */
174 TRACEPOINT_EVENT(
175 frr_bgp,
176 bmp_peer_status_changed,
177 TP_ARGS(struct peer *, peer),
178 TP_FIELDS(
179 ctf_string(peer, PEER_HOSTNAME(peer))
180 )
181 )
182
183 TRACEPOINT_LOGLEVEL(frr_bgp, bmp_peer_status_changed, TRACE_DEBUG)
184
185
186 /*
187 * BMP is notified that a peer has transitioned in the opposite direction of
188 * Established internally
189 */
190 TRACEPOINT_EVENT(
191 frr_bgp,
192 bmp_peer_backward_transition,
193 TP_ARGS(struct peer *, peer),
194 TP_FIELDS(
195 ctf_string(peer, PEER_HOSTNAME(peer))
196 )
197 )
198
199 TRACEPOINT_LOGLEVEL(frr_bgp, bmp_peer_backward, TRACE_DEBUG)
200
201
202 /*
203 * BMP is hooked for a route process
204 */
205 TRACEPOINT_EVENT(
206 frr_bgp,
207 bmp_process,
208 TP_ARGS(struct peer *, peer, char *, pfx, afi_t,
209 afi, safi_t, safi, bool, withdraw),
210 TP_FIELDS(
211 ctf_string(peer, PEER_HOSTNAME(peer))
212 ctf_string(prefix, pfx)
213 ctf_integer(afi_t, afi, afi)
214 ctf_integer(safi_t, safi, safi)
215 ctf_integer(bool, withdraw, withdraw)
216 )
217 )
218
219 TRACEPOINT_LOGLEVEL(frr_bgp, bmp_process, TRACE_DEBUG)
220
221 /* clang-format on */
222
223 #include <lttng/tracepoint-event.h>
224
225 #endif /* HAVE_LTTNG */
226
227 #endif /* _BGP_TRACE_H */