1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
/*
* Copyright (c) 2017 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SRC_VNET_TCP_TCP_DEBUG_H_
#define SRC_VNET_TCP_TCP_DEBUG_H_
#include <vlib/vlib.h>
#define TCP_DEBUG (1)
#define foreach_tcp_dbg_evt \
_(INIT, "") \
_(DEALLOC, "") \
_(OPEN, "open") \
_(CLOSE, "close") \
_(BIND, "bind") \
_(UNBIND, "unbind") \
_(DELETE, "delete") \
_(SYN_SENT, "SYN sent") \
_(FIN_SENT, "FIN sent") \
_(RST_SENT, "RST sent") \
_(SYN_RCVD, "SYN rcvd") \
_(ACK_RCVD, "ACK rcvd") \
_(FIN_RCVD, "FIN rcvd") \
_(RST_RCVD, "RST rcvd") \
_(PKTIZE, "packetize") \
_(INPUT, "in") \
_(TIMER_POP, "timer pop")
typedef enum _tcp_dbg
{
#define _(sym, str) TCP_DBG_##sym,
foreach_tcp_dbg_evt
#undef _
} tcp_dbg_e;
typedef enum _tcp_dbg_evt
{
#define _(sym, str) TCP_EVT_##sym,
foreach_tcp_dbg_evt
#undef _
} tcp_dbg_evt_e;
#if TCP_DEBUG
#define TRANSPORT_DEBUG (1)
#define TCP_DBG(_tc, _evt, _args...) \
{ \
u8 *_tmp = 0; \
_tmp = format(_tmp, "%U", format_tcp_connection_verbose, _tc); \
clib_warning("%s", _tmp); \
vec_free(_tmp); \
}
#define DECLARE_ETD(_tc, _e, _size) \
struct \
{ \
u32 data[_size]; \
} * ed; \
ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, \
_e, _tc->c_elog_track)
#define TCP_EVT_INIT_HANDLER(_tc, ...) \
{ \
_tc->c_elog_track.name = \
(char *) format (0, "%d%c", _tc->c_c_index, 0); \
elog_track_register (&vlib_global_main.elog_main, &_tc->c_elog_track);\
}
#define TCP_EVT_DEALLOC_HANDLER(_tc, ...) \
{ \
vec_free (_tc->c_elog_track.name); \
}
#define TCP_EVT_OPEN_HANDLER(_tc, ...) \
{ \
TCP_EVT_INIT_HANDLER(_tc); \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "open: index %d", \
.format_args = "i4", \
}; \
DECLARE_ETD(_tc, _e, 1); \
ed->data[0] = _tc->c_c_index; \
}
#define TCP_EVT_CLOSE_HANDLER(_tc, ...) \
{ \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "close: %d", \
.format_args = "i4", \
}; \
DECLARE_ETD(_tc, _e, 1); \
ed->data[0] = _tc->c_c_index; \
}
#define TCP_EVT_BIND_HANDLER(_tc, ...) \
{ \
TCP_EVT_INIT_HANDLER(_tc); \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "bind: listener %d", \
}; \
DECLARE_ETD(_tc, _e, 1); \
ed->data[0] = _tc->c_c_index; \
}
#define TCP_EVT_UNBIND_HANDLER(_tc, ...) \
{ \
TCP_EVT_DEALLOC_HANDLER(_tc); \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "unbind: listener %d", \
}; \
DECLARE_ETD(_tc, _e, 1); \
ed->data[0] = _tc->c_c_index; \
TCP_EVT_DEALLOC_HANDLER(_tc); \
}
#define TCP_EVT_DELETE_HANDLER(_tc, ...) \
{ \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "delete: %d", \
.format_args = "i4", \
}; \
DECLARE_ETD(_tc, _e, 0); \
ed->data[0] = _tc->c_c_index; \
TCP_EVT_DEALLOC_HANDLER(_tc); \
}
#define TCP_EVT_SYN_SENT_HANDLER(_tc, ...) \
{ \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "SYN: iss %d", \
.format_args = "i4", \
}; \
DECLARE_ETD(_tc, _e, 1); \
ed->data[0] = _tc->iss; \
}
#define TCP_EVT_FIN_SENT_HANDLER(_tc, ...) \
{ \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "FIN: snd_nxt %d rcv_nxt %d", \
.format_args = "i4i4", \
}; \
DECLARE_ETD(_tc, _e, 2); \
ed->data[0] = _tc->snd_nxt - _tc->iss; \
ed->data[1] = _tc->rcv_nxt - _tc->irs; \
}
#define TCP_EVT_RST_SENT_HANDLER(_tc, ...) \
{ \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "RST: snd_nxt %d rcv_nxt %d", \
.format_args = "i4i4", \
}; \
DECLARE_ETD(_tc, _e, 2); \
ed->data[0] = _tc->snd_nxt - _tc->iss; \
ed->data[1] = _tc->rcv_nxt - _tc->irs; \
}
#define TCP_EVT_SYN_RCVD_HANDLER(_tc, ...) \
{ \
TCP_EVT_INIT_HANDLER(_tc); \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "SYN rcvd: irs %d", \
.format_args = "i4", \
}; \
DECLARE_ETD(_tc, _e, 1); \
ed->data[0] = _tc->irs; \
}
#define TCP_EVT_FIN_RCVD_HANDLER(_tc, ...) \
{ \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "FIN rcvd: snd_nxt %d rcv_nxt %d", \
.format_args = "i4i4", \
}; \
DECLARE_ETD(_tc, _e, 2); \
ed->data[0] = _tc->snd_nxt - _tc->iss; \
ed->data[1] = _tc->rcv_nxt - _tc->irs; \
}
#define TCP_EVT_RST_RCVD_HANDLER(_tc, ...) \
{ \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "RST rcvd: snd_nxt %d rcv_nxt %d", \
.format_args = "i4i4", \
}; \
DECLARE_ETD(_tc, _e, 2); \
ed->data[0] = _tc->snd_nxt - _tc->iss; \
ed->data[1] = _tc->rcv_nxt - _tc->irs; \
}
#define TCP_EVT_ACK_RCVD_HANDLER(_tc, ...) \
{ \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "ACK: acked %u cwnd %u inflight %u", \
.format_args = "i4i4i4", \
}; \
DECLARE_ETD(_tc, _e, 3); \
ed->data[0] = _tc->bytes_acked; \
ed->data[1] = _tc->cwnd; \
ed->data[2] = tcp_flight_size(_tc); \
}
#define TCP_EVT_PKTIZE_HANDLER(_tc, ...) \
{ \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "pktize: snd_una %u snd_nxt %u una_max %u", \
.format_args = "i4i4i4", \
}; \
DECLARE_ETD(_tc, _e, 3); \
ed->data[0] = _tc->snd_una - _tc->iss; \
ed->data[1] = _tc->snd_nxt - _tc->iss; \
ed->data[2] = _tc->snd_una_max - _tc->iss; \
}
#define TCP_EVT_OUTPUT_HANDLER(_tc, flags, n_bytes,...) \
{ \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "out: flags %x, bytes %u", \
.format_args = "i4i4", \
}; \
DECLARE_ETD(_tc, _e, 2); \
ed->data[0] = flags; \
ed->data[1] = n_bytes; \
}
#define TCP_EVT_INPUT_HANDLER(_tc, n_bytes, ...) \
{ \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "in: bytes %u rcv_nxt %u", \
.format_args = "i4i4", \
}; \
DECLARE_ETD(_tc, _e, 2); \
ed->data[0] = n_bytes; \
ed->data[1] = _tc->rcv_nxt - _tc->irs; \
}
#define TCP_EVT_TIMER_POP_HANDLER(_tc_index, _timer_id, ...) \
{ \
tcp_connection_t *_tc; \
if (_timer_id == TCP_TIMER_RETRANSMIT_SYN) \
{ \
_tc = tcp_half_open_connection_get (_tc_index); \
} \
else \
{ \
u32 _thread_index = os_get_cpu_number (); \
_tc = tcp_connection_get (_tc_index, _thread_index); \
} \
ELOG_TYPE_DECLARE (_e) = \
{ \
.format = "TimerPop: %s (%d)", \
.format_args = "t4i4", \
.n_enum_strings = 7, \
.enum_strings = { \
"retransmit", \
"delack", \
"BUG", \
"keep", \
"waitclose", \
"retransmit syn", \
"establish", \
}, \
}; \
DECLARE_ETD(_tc, _e, 2); \
ed->data[0] = _timer_id; \
ed->data[1] = _timer_id; \
}
#define CONCAT_HELPER(_a, _b) _a##_b
#define CC(_a, _b) CONCAT_HELPER(_a, _b)
#define TCP_EVT_DBG(_evt, _args...) CC(_evt, _HANDLER)(_args)
#else
#define TCP_EVT_DBG(_evt, _args...)
#endif
#endif /* SRC_VNET_TCP_TCP_DEBUG_H_ */
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
|