blob: 5c554bac5a99c416c9895c72f63def72b1fae155 [file] [log] [blame]
Dave Barach68b0fb02017-02-28 15:15:56 -05001/*
2 * Copyright (c) 2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include <vnet/tcp/tcp.h>
17#include <vnet/session/session.h>
18#include <vnet/fib/fib.h>
19#include <math.h>
20
21tcp_main_t tcp_main;
22
23static u32
Florin Corase69f4952017-03-07 10:06:24 -080024tcp_connection_bind (u32 session_index, ip46_address_t * ip,
Dave Barach68b0fb02017-02-28 15:15:56 -050025 u16 port_host_byte_order, u8 is_ip4)
26{
27 tcp_main_t *tm = &tcp_main;
28 tcp_connection_t *listener;
29
30 pool_get (tm->listener_pool, listener);
31 memset (listener, 0, sizeof (*listener));
32
33 listener->c_c_index = listener - tm->listener_pool;
34 listener->c_lcl_port = clib_host_to_net_u16 (port_host_byte_order);
35
36 if (is_ip4)
Florin Coras6cf30ad2017-04-04 23:08:23 -070037 {
38 listener->c_lcl_ip4.as_u32 = ip->ip4.as_u32;
39 listener->c_is_ip4 = 1;
40 listener->c_proto = SESSION_TYPE_IP4_TCP;
41 }
Dave Barach68b0fb02017-02-28 15:15:56 -050042 else
Florin Coras6cf30ad2017-04-04 23:08:23 -070043 {
44 clib_memcpy (&listener->c_lcl_ip6, &ip->ip6, sizeof (ip6_address_t));
45 listener->c_proto = SESSION_TYPE_IP6_TCP;
46 }
Dave Barach68b0fb02017-02-28 15:15:56 -050047
48 listener->c_s_index = session_index;
Dave Barach68b0fb02017-02-28 15:15:56 -050049 listener->state = TCP_STATE_LISTEN;
Dave Barach68b0fb02017-02-28 15:15:56 -050050
Florin Corase69f4952017-03-07 10:06:24 -080051 tcp_connection_timers_init (listener);
52
53 TCP_EVT_DBG (TCP_EVT_BIND, listener);
54
Dave Barach68b0fb02017-02-28 15:15:56 -050055 return listener->c_c_index;
56}
57
58u32
Florin Corase69f4952017-03-07 10:06:24 -080059tcp_session_bind_ip4 (u32 session_index, ip46_address_t * ip,
60 u16 port_host_byte_order)
Dave Barach68b0fb02017-02-28 15:15:56 -050061{
Florin Corase69f4952017-03-07 10:06:24 -080062 return tcp_connection_bind (session_index, ip, port_host_byte_order, 1);
Dave Barach68b0fb02017-02-28 15:15:56 -050063}
64
65u32
Florin Corase69f4952017-03-07 10:06:24 -080066tcp_session_bind_ip6 (u32 session_index, ip46_address_t * ip,
67 u16 port_host_byte_order)
Dave Barach68b0fb02017-02-28 15:15:56 -050068{
Florin Corase69f4952017-03-07 10:06:24 -080069 return tcp_connection_bind (session_index, ip, port_host_byte_order, 0);
Dave Barach68b0fb02017-02-28 15:15:56 -050070}
71
72static void
Florin Corase69f4952017-03-07 10:06:24 -080073tcp_connection_unbind (u32 listener_index)
Dave Barach68b0fb02017-02-28 15:15:56 -050074{
75 tcp_main_t *tm = vnet_get_tcp_main ();
Florin Corase69f4952017-03-07 10:06:24 -080076 TCP_EVT_DBG (TCP_EVT_UNBIND,
77 pool_elt_at_index (tm->listener_pool, listener_index));
Dave Barach68b0fb02017-02-28 15:15:56 -050078 pool_put_index (tm->listener_pool, listener_index);
79}
80
81u32
Florin Corase69f4952017-03-07 10:06:24 -080082tcp_session_unbind (u32 listener_index)
Dave Barach68b0fb02017-02-28 15:15:56 -050083{
Florin Corase69f4952017-03-07 10:06:24 -080084 tcp_connection_unbind (listener_index);
Dave Barach68b0fb02017-02-28 15:15:56 -050085 return 0;
86}
87
88transport_connection_t *
89tcp_session_get_listener (u32 listener_index)
90{
91 tcp_main_t *tm = vnet_get_tcp_main ();
92 tcp_connection_t *tc;
93 tc = pool_elt_at_index (tm->listener_pool, listener_index);
94 return &tc->connection;
95}
96
97/**
98 * Cleans up connection state.
99 *
100 * No notifications.
101 */
102void
103tcp_connection_cleanup (tcp_connection_t * tc)
104{
105 tcp_main_t *tm = &tcp_main;
106 u32 tepi;
107 transport_endpoint_t *tep;
108
109 /* Cleanup local endpoint if this was an active connect */
110 tepi = transport_endpoint_lookup (&tm->local_endpoints_table, &tc->c_lcl_ip,
111 tc->c_lcl_port);
112
113 /*XXX lock */
114 if (tepi != TRANSPORT_ENDPOINT_INVALID_INDEX)
115 {
116 tep = pool_elt_at_index (tm->local_endpoints, tepi);
117 transport_endpoint_table_del (&tm->local_endpoints_table, tep);
118 pool_put (tm->local_endpoints, tep);
119 }
120
121 /* Make sure all timers are cleared */
122 tcp_connection_timers_reset (tc);
123
124 /* Check if half-open */
125 if (tc->state == TCP_STATE_SYN_SENT)
126 pool_put (tm->half_open_connections, tc);
127 else
128 pool_put (tm->connections[tc->c_thread_index], tc);
129}
130
131/**
132 * Connection removal.
133 *
134 * This should be called only once connection enters CLOSED state. Note
135 * that it notifies the session of the removal event, so if the goal is to
136 * just remove the connection, call tcp_connection_cleanup instead.
137 */
138void
139tcp_connection_del (tcp_connection_t * tc)
140{
Florin Corase69f4952017-03-07 10:06:24 -0800141 TCP_EVT_DBG (TCP_EVT_DELETE, tc);
Dave Barach68b0fb02017-02-28 15:15:56 -0500142 stream_session_delete_notify (&tc->connection);
143 tcp_connection_cleanup (tc);
144}
145
Florin Corasd79b41e2017-03-04 05:37:52 -0800146/** Notify session that connection has been reset.
147 *
148 * Switch state to closed and wait for session to call cleanup.
149 */
150void
151tcp_connection_reset (tcp_connection_t * tc)
152{
Florin Coras11c05492017-05-10 12:29:14 -0700153 switch (tc->state)
154 {
155 case TCP_STATE_SYN_RCVD:
156 /* Cleanup everything. App wasn't notified yet */
157 stream_session_delete_notify (&tc->connection);
158 tcp_connection_cleanup (tc);
159 break;
160 case TCP_STATE_SYN_SENT:
161 case TCP_STATE_ESTABLISHED:
162 case TCP_STATE_CLOSE_WAIT:
163 case TCP_STATE_FIN_WAIT_1:
164 case TCP_STATE_FIN_WAIT_2:
165 case TCP_STATE_CLOSING:
166 tc->state = TCP_STATE_CLOSED;
Florin Corasd79b41e2017-03-04 05:37:52 -0800167
Florin Coras11c05492017-05-10 12:29:14 -0700168 /* Make sure all timers are cleared */
169 tcp_connection_timers_reset (tc);
Florin Corasdb84e572017-05-09 18:54:52 -0700170
Florin Coras11c05492017-05-10 12:29:14 -0700171 stream_session_reset_notify (&tc->connection);
172 break;
173 case TCP_STATE_CLOSED:
174 return;
175 }
Florin Corasdb84e572017-05-09 18:54:52 -0700176
Florin Corasd79b41e2017-03-04 05:37:52 -0800177}
178
Dave Barach68b0fb02017-02-28 15:15:56 -0500179/**
180 * Begin connection closing procedure.
181 *
182 * If at the end the connection is not in CLOSED state, it is not removed.
183 * Instead, we rely on on TCP to advance through state machine to either
184 * 1) LAST_ACK (passive close) whereby when the last ACK is received
185 * tcp_connection_del is called. This notifies session of the delete and
186 * calls cleanup.
187 * 2) TIME_WAIT (active close) whereby after 2MSL the 2MSL timer triggers
188 * and cleanup is called.
Florin Corasd79b41e2017-03-04 05:37:52 -0800189 *
190 * N.B. Half-close connections are not supported
Dave Barach68b0fb02017-02-28 15:15:56 -0500191 */
192void
193tcp_connection_close (tcp_connection_t * tc)
194{
Florin Corase69f4952017-03-07 10:06:24 -0800195 TCP_EVT_DBG (TCP_EVT_CLOSE, tc);
196
Dave Barach68b0fb02017-02-28 15:15:56 -0500197 /* Send FIN if needed */
Florin Coras93992a92017-05-24 18:03:56 -0700198 if (tc->state == TCP_STATE_ESTABLISHED
199 || tc->state == TCP_STATE_SYN_RCVD || tc->state == TCP_STATE_CLOSE_WAIT)
Dave Barach68b0fb02017-02-28 15:15:56 -0500200 tcp_send_fin (tc);
201
202 /* Switch state */
203 if (tc->state == TCP_STATE_ESTABLISHED || tc->state == TCP_STATE_SYN_RCVD)
204 tc->state = TCP_STATE_FIN_WAIT_1;
205 else if (tc->state == TCP_STATE_SYN_SENT)
206 tc->state = TCP_STATE_CLOSED;
207 else if (tc->state == TCP_STATE_CLOSE_WAIT)
208 tc->state = TCP_STATE_LAST_ACK;
209
Florin Corasd79b41e2017-03-04 05:37:52 -0800210 /* If in CLOSED and WAITCLOSE timer is not set, delete connection now */
211 if (tc->timers[TCP_TIMER_WAITCLOSE] == TCP_TIMER_HANDLE_INVALID
212 && tc->state == TCP_STATE_CLOSED)
Dave Barach68b0fb02017-02-28 15:15:56 -0500213 tcp_connection_del (tc);
214}
215
216void
217tcp_session_close (u32 conn_index, u32 thread_index)
218{
219 tcp_connection_t *tc;
220 tc = tcp_connection_get (conn_index, thread_index);
221 tcp_connection_close (tc);
222}
223
224void
225tcp_session_cleanup (u32 conn_index, u32 thread_index)
226{
227 tcp_connection_t *tc;
228 tc = tcp_connection_get (conn_index, thread_index);
Florin Corasd79b41e2017-03-04 05:37:52 -0800229
230 /* Wait for the session tx events to clear */
231 tc->state = TCP_STATE_CLOSED;
232 tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME);
Dave Barach68b0fb02017-02-28 15:15:56 -0500233}
234
235void *
236ip_interface_get_first_ip (u32 sw_if_index, u8 is_ip4)
237{
238 ip_lookup_main_t *lm4 = &ip4_main.lookup_main;
239 ip_lookup_main_t *lm6 = &ip6_main.lookup_main;
240 ip_interface_address_t *ia = 0;
241
242 if (is_ip4)
243 {
244 /* *INDENT-OFF* */
245 foreach_ip_interface_address (lm4, ia, sw_if_index, 1 /* unnumbered */ ,
246 ({
247 return ip_interface_address_get_address (lm4, ia);
248 }));
249 /* *INDENT-ON* */
250 }
251 else
252 {
253 /* *INDENT-OFF* */
254 foreach_ip_interface_address (lm6, ia, sw_if_index, 1 /* unnumbered */ ,
255 ({
256 return ip_interface_address_get_address (lm6, ia);
257 }));
258 /* *INDENT-ON* */
259 }
260
261 return 0;
262}
263
Florin Corase04c2992017-03-01 08:17:34 -0800264#define PORT_MASK ((1 << 16)- 1)
Dave Barach68b0fb02017-02-28 15:15:56 -0500265/**
266 * Allocate local port and add if successful add entry to local endpoint
267 * table to mark the pair as used.
268 */
269u16
270tcp_allocate_local_port (tcp_main_t * tm, ip46_address_t * ip)
271{
Dave Barach68b0fb02017-02-28 15:15:56 -0500272 transport_endpoint_t *tep;
273 u32 time_now, tei;
Florin Corasd79b41e2017-03-04 05:37:52 -0800274 u16 min = 1024, max = 65535; /* XXX configurable ? */
275 int tries;
Dave Barach68b0fb02017-02-28 15:15:56 -0500276
277 tries = max - min;
278 time_now = tcp_time_now ();
279
280 /* Start at random point or max */
281 pool_get (tm->local_endpoints, tep);
282 clib_memcpy (&tep->ip, ip, sizeof (*ip));
Dave Barach68b0fb02017-02-28 15:15:56 -0500283
284 /* Search for first free slot */
Florin Corase04c2992017-03-01 08:17:34 -0800285 for (; tries >= 0; tries--)
Dave Barach68b0fb02017-02-28 15:15:56 -0500286 {
Florin Corase04c2992017-03-01 08:17:34 -0800287 u16 port = 0;
288
289 /* Find a port in the specified range */
290 while (1)
Dave Barach68b0fb02017-02-28 15:15:56 -0500291 {
Florin Corase04c2992017-03-01 08:17:34 -0800292 port = random_u32 (&time_now) & PORT_MASK;
293 if (PREDICT_TRUE (port >= min && port < max))
294 break;
Dave Barach68b0fb02017-02-28 15:15:56 -0500295 }
296
Florin Corase04c2992017-03-01 08:17:34 -0800297 tep->port = port;
Dave Barach68b0fb02017-02-28 15:15:56 -0500298
Florin Corase04c2992017-03-01 08:17:34 -0800299 /* Look it up */
300 tei = transport_endpoint_lookup (&tm->local_endpoints_table, &tep->ip,
301 tep->port);
302 /* If not found, we're done */
303 if (tei == TRANSPORT_ENDPOINT_INVALID_INDEX)
304 {
305 transport_endpoint_table_add (&tm->local_endpoints_table, tep,
306 tep - tm->local_endpoints);
307 return tep->port;
308 }
Dave Barach68b0fb02017-02-28 15:15:56 -0500309 }
Florin Corase04c2992017-03-01 08:17:34 -0800310 /* No free ports */
Dave Barach68b0fb02017-02-28 15:15:56 -0500311 pool_put (tm->local_endpoints, tep);
312 return -1;
313}
314
315/**
316 * Initialize all connection timers as invalid
317 */
318void
319tcp_connection_timers_init (tcp_connection_t * tc)
320{
321 int i;
322
323 /* Set all to invalid */
324 for (i = 0; i < TCP_N_TIMERS; i++)
325 {
326 tc->timers[i] = TCP_TIMER_HANDLE_INVALID;
327 }
328
329 tc->rto = TCP_RTO_INIT;
330}
331
332/**
333 * Stop all connection timers
334 */
335void
336tcp_connection_timers_reset (tcp_connection_t * tc)
337{
338 int i;
339 for (i = 0; i < TCP_N_TIMERS; i++)
340 {
341 tcp_timer_reset (tc, i);
342 }
343}
344
345/** Initialize tcp connection variables
346 *
347 * Should be called after having received a msg from the peer, i.e., a SYN or
348 * a SYNACK, such that connection options have already been exchanged. */
349void
350tcp_connection_init_vars (tcp_connection_t * tc)
351{
352 tcp_connection_timers_init (tc);
Florin Corasc8343412017-05-04 14:25:50 -0700353 tcp_init_mss (tc);
Florin Coras6792ec02017-03-13 03:49:51 -0700354 scoreboard_init (&tc->sack_sb);
Dave Barach68b0fb02017-02-28 15:15:56 -0500355 tcp_cc_init (tc);
356}
357
358int
359tcp_connection_open (ip46_address_t * rmt_addr, u16 rmt_port, u8 is_ip4)
360{
361 tcp_main_t *tm = vnet_get_tcp_main ();
362 tcp_connection_t *tc;
363 fib_prefix_t prefix;
364 u32 fei, sw_if_index;
365 ip46_address_t lcl_addr;
366 u16 lcl_port;
367
368 /*
369 * Find the local address and allocate port
370 */
371 memset (&lcl_addr, 0, sizeof (lcl_addr));
372
373 /* Find a FIB path to the destination */
374 clib_memcpy (&prefix.fp_addr, rmt_addr, sizeof (*rmt_addr));
375 prefix.fp_proto = is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
376 prefix.fp_len = is_ip4 ? 32 : 128;
377
378 fei = fib_table_lookup (0, &prefix);
379
380 /* Couldn't find route to destination. Bail out. */
381 if (fei == FIB_NODE_INDEX_INVALID)
382 return -1;
383
384 sw_if_index = fib_entry_get_resolving_interface (fei);
385
386 if (sw_if_index == (u32) ~ 0)
387 return -1;
388
389 if (is_ip4)
390 {
391 ip4_address_t *ip4;
392 ip4 = ip_interface_get_first_ip (sw_if_index, 1);
393 lcl_addr.ip4.as_u32 = ip4->as_u32;
394 }
395 else
396 {
397 ip6_address_t *ip6;
398 ip6 = ip_interface_get_first_ip (sw_if_index, 0);
399 clib_memcpy (&lcl_addr.ip6, ip6, sizeof (*ip6));
400 }
401
402 /* Allocate source port */
403 lcl_port = tcp_allocate_local_port (tm, &lcl_addr);
404 if (lcl_port < 1)
Florin Corase04c2992017-03-01 08:17:34 -0800405 {
406 clib_warning ("Failed to allocate src port");
407 return -1;
408 }
Dave Barach68b0fb02017-02-28 15:15:56 -0500409
410 /*
411 * Create connection and send SYN
412 */
413
414 pool_get (tm->half_open_connections, tc);
415 memset (tc, 0, sizeof (*tc));
416
417 clib_memcpy (&tc->c_rmt_ip, rmt_addr, sizeof (ip46_address_t));
418 clib_memcpy (&tc->c_lcl_ip, &lcl_addr, sizeof (ip46_address_t));
419 tc->c_rmt_port = clib_host_to_net_u16 (rmt_port);
420 tc->c_lcl_port = clib_host_to_net_u16 (lcl_port);
421 tc->c_c_index = tc - tm->half_open_connections;
422 tc->c_is_ip4 = is_ip4;
Florin Coras6cf30ad2017-04-04 23:08:23 -0700423 tc->c_proto = is_ip4 ? SESSION_TYPE_IP4_TCP : SESSION_TYPE_IP6_TCP;
Dave Barach68b0fb02017-02-28 15:15:56 -0500424
425 /* The other connection vars will be initialized after SYN ACK */
426 tcp_connection_timers_init (tc);
427
428 tcp_send_syn (tc);
429
430 tc->state = TCP_STATE_SYN_SENT;
431
Florin Corase69f4952017-03-07 10:06:24 -0800432 TCP_EVT_DBG (TCP_EVT_OPEN, tc);
433
Dave Barach68b0fb02017-02-28 15:15:56 -0500434 return tc->c_c_index;
435}
436
437int
438tcp_session_open_ip4 (ip46_address_t * addr, u16 port)
439{
440 return tcp_connection_open (addr, port, 1);
441}
442
443int
444tcp_session_open_ip6 (ip46_address_t * addr, u16 port)
445{
446 return tcp_connection_open (addr, port, 0);
447}
448
Florin Corase69f4952017-03-07 10:06:24 -0800449const char *tcp_dbg_evt_str[] = {
450#define _(sym, str) str,
451 foreach_tcp_dbg_evt
452#undef _
453};
454
455const char *tcp_fsm_states[] = {
456#define _(sym, str) str,
457 foreach_tcp_fsm_state
458#undef _
459};
460
Dave Barach68b0fb02017-02-28 15:15:56 -0500461u8 *
Florin Corase69f4952017-03-07 10:06:24 -0800462format_tcp_state (u8 * s, va_list * args)
463{
Florin Corasbb292f42017-05-19 09:49:19 -0700464 u32 state = va_arg (*args, u32);
Florin Corase69f4952017-03-07 10:06:24 -0800465
Florin Corasbb292f42017-05-19 09:49:19 -0700466 if (state < TCP_N_STATES)
467 s = format (s, "%s", tcp_fsm_states[state]);
Florin Corase69f4952017-03-07 10:06:24 -0800468 else
Florin Corasbb292f42017-05-19 09:49:19 -0700469 s = format (s, "UNKNOWN (%d (0x%x))", state, state);
Florin Corase69f4952017-03-07 10:06:24 -0800470 return s;
471}
472
473const char *tcp_conn_timers[] = {
474#define _(sym, str) str,
475 foreach_tcp_timer
476#undef _
477};
478
479u8 *
480format_tcp_timers (u8 * s, va_list * args)
481{
482 tcp_connection_t *tc = va_arg (*args, tcp_connection_t *);
Florin Coras93992a92017-05-24 18:03:56 -0700483 int i, last = -1;
Florin Corase69f4952017-03-07 10:06:24 -0800484
485 for (i = 0; i < TCP_N_TIMERS; i++)
486 if (tc->timers[i] != TCP_TIMER_HANDLE_INVALID)
487 last = i;
488
489 s = format (s, "[");
490 for (i = 0; i < last; i++)
491 {
492 if (tc->timers[i] != TCP_TIMER_HANDLE_INVALID)
493 s = format (s, "%s,", tcp_conn_timers[i]);
494 }
495
Florin Coras93992a92017-05-24 18:03:56 -0700496 if (last >= 0)
Florin Corase69f4952017-03-07 10:06:24 -0800497 s = format (s, "%s]", tcp_conn_timers[i]);
498 else
499 s = format (s, "]");
500
501 return s;
502}
503
504u8 *
Florin Corasbb292f42017-05-19 09:49:19 -0700505format_tcp_congestion_status (u8 * s, va_list * args)
506{
507 tcp_connection_t *tc = va_arg (*args, tcp_connection_t *);
508 if (tcp_in_recovery (tc))
509 s = format (s, "recovery");
510 else if (tcp_in_fastrecovery (tc))
511 s = format (s, "fastrecovery");
512 else
513 s = format (s, "none");
514 return s;
515}
516
517u8 *
518format_tcp_vars (u8 * s, va_list * args)
519{
520 tcp_connection_t *tc = va_arg (*args, tcp_connection_t *);
521 s = format (s, " snd_una %u snd_nxt %u snd_una_max %u\n",
522 tc->snd_una - tc->iss, tc->snd_nxt - tc->iss,
523 tc->snd_una_max - tc->iss);
524 s = format (s, " rcv_nxt %u rcv_las %u\n",
525 tc->rcv_nxt - tc->irs, tc->rcv_las - tc->irs);
526 s = format (s, " snd_wnd %u rcv_wnd %u snd_wl1 %u snd_wl2 %u\n",
527 tc->snd_wnd, tc->rcv_wnd, tc->snd_wl1 - tc->irs,
528 tc->snd_wl2 - tc->iss);
Florin Coras93992a92017-05-24 18:03:56 -0700529 s = format (s, " flight size %u send space %u rcv_wnd_av %d\n",
530 tcp_flight_size (tc), tcp_available_snd_space (tc),
531 tcp_rcv_wnd_available (tc));
Florin Corasbb292f42017-05-19 09:49:19 -0700532 s = format (s, " cong %U ", format_tcp_congestion_status, tc);
533 s = format (s, "cwnd %u ssthresh %u rtx_bytes %u bytes_acked %u\n",
Florin Coras93992a92017-05-24 18:03:56 -0700534 tc->cwnd, tc->ssthresh, tc->snd_rxt_bytes, tc->bytes_acked);
535 s = format (s, " prev_ssthresh %u snd_congestion %u dupack %u\n",
536 tc->prev_ssthresh, tc->snd_congestion - tc->iss,
537 tc->rcv_dupacks);
Florin Corasbb292f42017-05-19 09:49:19 -0700538 s = format (s, " rto %u rto_boff %u srtt %u rttvar %u rtt_ts %u ", tc->rto,
539 tc->rto_boff, tc->srtt, tc->rttvar, tc->rtt_ts);
540 s = format (s, "rtt_seq %u\n", tc->rtt_seq);
Florin Coras93992a92017-05-24 18:03:56 -0700541 s = format (s, " scoreboard: %U\n", format_tcp_scoreboard, &tc->sack_sb);
Florin Corasbb292f42017-05-19 09:49:19 -0700542 if (vec_len (tc->snd_sacks))
543 s = format (s, " sacks tx: %U\n", format_tcp_sacks, tc);
544
545 return s;
546}
547
548u8 *
549format_tcp_connection_id (u8 * s, va_list * args)
Florin Corase69f4952017-03-07 10:06:24 -0800550{
551 tcp_connection_t *tc = va_arg (*args, tcp_connection_t *);
Florin Corasa5464812017-04-19 13:00:05 -0700552 if (!tc)
553 return s;
Florin Corase69f4952017-03-07 10:06:24 -0800554 if (tc->c_is_ip4)
555 {
556 s = format (s, "[#%d][%s] %U:%d->%U:%d", tc->c_thread_index, "T",
557 format_ip4_address, &tc->c_lcl_ip4,
558 clib_net_to_host_u16 (tc->c_lcl_port), format_ip4_address,
559 &tc->c_rmt_ip4, clib_net_to_host_u16 (tc->c_rmt_port));
560 }
561 else
562 {
563 s = format (s, "[#%d][%s] %U:%d->%U:%d", tc->c_thread_index, "T",
564 format_ip6_address, &tc->c_lcl_ip6,
565 clib_net_to_host_u16 (tc->c_lcl_port), format_ip6_address,
566 &tc->c_rmt_ip6, clib_net_to_host_u16 (tc->c_rmt_port));
567 }
568
569 return s;
570}
571
572u8 *
Florin Corasbb292f42017-05-19 09:49:19 -0700573format_tcp_connection (u8 * s, va_list * args)
Florin Corase69f4952017-03-07 10:06:24 -0800574{
575 tcp_connection_t *tc = va_arg (*args, tcp_connection_t *);
Florin Corasbb292f42017-05-19 09:49:19 -0700576 u32 verbose = va_arg (*args, u32);
577
578 s = format (s, "%-50U", format_tcp_connection_id, tc);
579 if (verbose)
580 {
581 s = format (s, "%-15U", format_tcp_state, tc->state);
582 if (verbose > 1)
583 s = format (s, " %U\n%U", format_tcp_timers, tc, format_tcp_vars, tc);
584 }
Florin Corase69f4952017-03-07 10:06:24 -0800585 return s;
586}
587
588u8 *
589format_tcp_session (u8 * s, va_list * args)
Dave Barach68b0fb02017-02-28 15:15:56 -0500590{
591 u32 tci = va_arg (*args, u32);
592 u32 thread_index = va_arg (*args, u32);
Florin Corasbb292f42017-05-19 09:49:19 -0700593 u32 verbose = va_arg (*args, u32);
Dave Barach68b0fb02017-02-28 15:15:56 -0500594 tcp_connection_t *tc;
595
596 tc = tcp_connection_get (tci, thread_index);
Florin Coras6cf30ad2017-04-04 23:08:23 -0700597 if (tc)
Florin Coras93992a92017-05-24 18:03:56 -0700598 s = format (s, "%U", format_tcp_connection, tc, verbose);
Florin Coras6cf30ad2017-04-04 23:08:23 -0700599 else
Florin Coras93992a92017-05-24 18:03:56 -0700600 s = format (s, "empty");
601 return s;
Dave Barach68b0fb02017-02-28 15:15:56 -0500602}
603
604u8 *
Florin Corase69f4952017-03-07 10:06:24 -0800605format_tcp_listener_session (u8 * s, va_list * args)
Dave Barach68b0fb02017-02-28 15:15:56 -0500606{
607 u32 tci = va_arg (*args, u32);
608 tcp_connection_t *tc = tcp_listener_get (tci);
Florin Corasbb292f42017-05-19 09:49:19 -0700609 return format (s, "%U", format_tcp_connection_id, tc);
Dave Barach68b0fb02017-02-28 15:15:56 -0500610}
611
612u8 *
Florin Corase69f4952017-03-07 10:06:24 -0800613format_tcp_half_open_session (u8 * s, va_list * args)
Dave Barach68b0fb02017-02-28 15:15:56 -0500614{
615 u32 tci = va_arg (*args, u32);
616 tcp_connection_t *tc = tcp_half_open_connection_get (tci);
Florin Corasbb292f42017-05-19 09:49:19 -0700617 return format (s, "%U", format_tcp_connection_id, tc);
Dave Barach68b0fb02017-02-28 15:15:56 -0500618}
619
Florin Coras06d11012017-05-17 14:21:51 -0700620u8 *
621format_tcp_sacks (u8 * s, va_list * args)
622{
623 tcp_connection_t *tc = va_arg (*args, tcp_connection_t *);
624 sack_block_t *sacks = tc->snd_sacks;
625 sack_block_t *block;
626 vec_foreach (block, sacks)
627 {
628 s = format (s, " start %u end %u\n", block->start - tc->irs,
629 block->end - tc->irs);
630 }
631 return s;
632}
633
634u8 *
635format_tcp_sack_hole (u8 * s, va_list * args)
636{
637 sack_scoreboard_hole_t *hole = va_arg (*args, sack_scoreboard_hole_t *);
638 s = format (s, "[%u, %u]", hole->start, hole->end);
639 return s;
640}
641
642u8 *
643format_tcp_scoreboard (u8 * s, va_list * args)
644{
645 sack_scoreboard_t *sb = va_arg (*args, sack_scoreboard_t *);
646 sack_scoreboard_hole_t *hole;
Florin Coras93992a92017-05-24 18:03:56 -0700647 s = format (s, "sacked_bytes %u last_sacked_bytes %u lost_bytes %u\n",
648 sb->sacked_bytes, sb->last_sacked_bytes, sb->lost_bytes);
649 s = format (s, " last_bytes_delivered %u high_sacked %u snd_una_adv %u\n",
650 sb->last_bytes_delivered, sb->high_sacked, sb->snd_una_adv);
651 s = format (s, " cur_rxt_hole %u high_rxt %u rescue_rxt %u",
652 sb->cur_rxt_hole, sb->high_rxt, sb->rescue_rxt);
653
Florin Coras06d11012017-05-17 14:21:51 -0700654 hole = scoreboard_first_hole (sb);
Florin Coras93992a92017-05-24 18:03:56 -0700655 if (hole)
656 s = format (s, "\n head %u tail %u holes:\n", sb->head, sb->tail);
657
Florin Coras06d11012017-05-17 14:21:51 -0700658 while (hole)
659 {
660 s = format (s, "%U", format_tcp_sack_hole, hole);
661 hole = scoreboard_next_hole (sb, hole);
662 }
663 return s;
664}
665
Dave Barach68b0fb02017-02-28 15:15:56 -0500666transport_connection_t *
667tcp_session_get_transport (u32 conn_index, u32 thread_index)
668{
669 tcp_connection_t *tc = tcp_connection_get (conn_index, thread_index);
670 return &tc->connection;
671}
672
673transport_connection_t *
674tcp_half_open_session_get_transport (u32 conn_index)
675{
676 tcp_connection_t *tc = tcp_half_open_connection_get (conn_index);
677 return &tc->connection;
678}
679
Florin Corasc8343412017-05-04 14:25:50 -0700680/**
681 * Compute maximum segment size for session layer.
682 *
683 * Since the result needs to be the actual data length, it first computes
684 * the tcp options to be used in the next burst and subtracts their
685 * length from the connection's snd_mss.
686 */
Dave Barach68b0fb02017-02-28 15:15:56 -0500687u16
688tcp_session_send_mss (transport_connection_t * trans_conn)
689{
690 tcp_connection_t *tc = (tcp_connection_t *) trans_conn;
Florin Corasc8343412017-05-04 14:25:50 -0700691
692 /* Ensure snd_mss does accurately reflect the amount of data we can push
693 * in a segment. This also makes sure that options are updated according to
694 * the current state of the connection. */
695 tcp_update_snd_mss (tc);
696
Dave Barach68b0fb02017-02-28 15:15:56 -0500697 return tc->snd_mss;
698}
699
Florin Coras3af90fc2017-05-03 21:09:42 -0700700always_inline u32
701tcp_round_snd_space (tcp_connection_t * tc, u32 snd_space)
702{
703 if (tc->snd_wnd < tc->snd_mss)
704 {
Florin Corasdb84e572017-05-09 18:54:52 -0700705 return tc->snd_wnd <= snd_space ? tc->snd_wnd : 0;
Florin Coras3af90fc2017-05-03 21:09:42 -0700706 }
707
708 /* If we can't write at least a segment, don't try at all */
709 if (snd_space < tc->snd_mss)
710 return 0;
711
712 /* round down to mss multiple */
713 return snd_space - (snd_space % tc->snd_mss);
714}
715
Florin Coras6792ec02017-03-13 03:49:51 -0700716/**
717 * Compute tx window session is allowed to fill.
Florin Corasbb292f42017-05-19 09:49:19 -0700718 *
719 * Takes into account available send space, snd_mss and the congestion
720 * state of the connection. If possible, the value returned is a multiple
721 * of snd_mss.
722 *
723 * @param tc tcp connection
724 * @return number of bytes session is allowed to write
Florin Coras6792ec02017-03-13 03:49:51 -0700725 */
Dave Barach68b0fb02017-02-28 15:15:56 -0500726u32
Florin Corasbb292f42017-05-19 09:49:19 -0700727tcp_snd_space (tcp_connection_t * tc)
Dave Barach68b0fb02017-02-28 15:15:56 -0500728{
Florin Corasf03a59a2017-06-09 21:07:32 -0700729 int snd_space, snt_limited;
Florin Coras6792ec02017-03-13 03:49:51 -0700730
Florin Corasf03a59a2017-06-09 21:07:32 -0700731 if (PREDICT_TRUE (tcp_in_cong_recovery (tc) == 0))
Florin Coras6792ec02017-03-13 03:49:51 -0700732 {
733 snd_space = tcp_available_snd_space (tc);
Florin Corasf03a59a2017-06-09 21:07:32 -0700734
735 /* If we haven't gotten dupacks or if we did and have gotten sacked
736 * bytes then we can still send as per Limited Transmit (RFC3042) */
737 if (PREDICT_FALSE (tc->rcv_dupacks != 0
738 && (tcp_opts_sack_permitted (tc)
739 && tc->sack_sb.last_sacked_bytes == 0)))
740 {
741 if (tc->rcv_dupacks == 1 && tc->limited_transmit != tc->snd_nxt)
742 tc->limited_transmit = tc->snd_nxt;
743 ASSERT (seq_leq (tc->limited_transmit, tc->snd_nxt));
744
745 snt_limited = tc->snd_nxt - tc->limited_transmit;
746 snd_space = clib_max (2 * tc->snd_mss - snt_limited, 0);
747 }
Florin Coras3af90fc2017-05-03 21:09:42 -0700748 return tcp_round_snd_space (tc, snd_space);
749 }
Florin Coras6792ec02017-03-13 03:49:51 -0700750
Florin Coras3af90fc2017-05-03 21:09:42 -0700751 if (tcp_in_recovery (tc))
752 {
753 tc->snd_nxt = tc->snd_una_max;
Florin Coras93992a92017-05-24 18:03:56 -0700754 snd_space = tcp_available_wnd (tc) - tc->snd_rxt_bytes
Florin Coras3af90fc2017-05-03 21:09:42 -0700755 - (tc->snd_una_max - tc->snd_congestion);
Florin Corasc8343412017-05-04 14:25:50 -0700756 if (snd_space <= 0 || (tc->snd_una_max - tc->snd_una) >= tc->snd_wnd)
Florin Coras6792ec02017-03-13 03:49:51 -0700757 return 0;
Florin Coras3af90fc2017-05-03 21:09:42 -0700758 return tcp_round_snd_space (tc, snd_space);
Florin Coras6792ec02017-03-13 03:49:51 -0700759 }
760
761 /* If in fast recovery, send 1 SMSS if wnd allows */
Florin Coras93992a92017-05-24 18:03:56 -0700762 if (tcp_in_fastrecovery (tc)
763 && tcp_available_snd_space (tc) && !tcp_fastrecovery_sent_1_smss (tc))
Florin Coras6792ec02017-03-13 03:49:51 -0700764 {
765 tcp_fastrecovery_1_smss_on (tc);
766 return tc->snd_mss;
767 }
768
769 return 0;
Dave Barach68b0fb02017-02-28 15:15:56 -0500770}
771
772u32
Florin Corasbb292f42017-05-19 09:49:19 -0700773tcp_session_send_space (transport_connection_t * trans_conn)
774{
775 tcp_connection_t *tc = (tcp_connection_t *) trans_conn;
776 return tcp_snd_space (tc);
777}
778
Florin Coras93992a92017-05-24 18:03:56 -0700779i32
780tcp_rcv_wnd_available (tcp_connection_t * tc)
781{
782 return (i32) tc->rcv_wnd - (tc->rcv_nxt - tc->rcv_las);
783}
784
Florin Corasbb292f42017-05-19 09:49:19 -0700785u32
Florin Corasd79b41e2017-03-04 05:37:52 -0800786tcp_session_tx_fifo_offset (transport_connection_t * trans_conn)
Dave Barach68b0fb02017-02-28 15:15:56 -0500787{
788 tcp_connection_t *tc = (tcp_connection_t *) trans_conn;
Florin Coras6792ec02017-03-13 03:49:51 -0700789
790 ASSERT (seq_geq (tc->snd_nxt, tc->snd_una));
791
792 /* This still works if fast retransmit is on */
Florin Corasd79b41e2017-03-04 05:37:52 -0800793 return (tc->snd_nxt - tc->snd_una);
Dave Barach68b0fb02017-02-28 15:15:56 -0500794}
795
796/* *INDENT-OFF* */
797const static transport_proto_vft_t tcp4_proto = {
798 .bind = tcp_session_bind_ip4,
Florin Corase69f4952017-03-07 10:06:24 -0800799 .unbind = tcp_session_unbind,
Dave Barach68b0fb02017-02-28 15:15:56 -0500800 .push_header = tcp_push_header,
801 .get_connection = tcp_session_get_transport,
802 .get_listener = tcp_session_get_listener,
803 .get_half_open = tcp_half_open_session_get_transport,
804 .open = tcp_session_open_ip4,
805 .close = tcp_session_close,
806 .cleanup = tcp_session_cleanup,
807 .send_mss = tcp_session_send_mss,
808 .send_space = tcp_session_send_space,
Florin Corasd79b41e2017-03-04 05:37:52 -0800809 .tx_fifo_offset = tcp_session_tx_fifo_offset,
Florin Corase69f4952017-03-07 10:06:24 -0800810 .format_connection = format_tcp_session,
811 .format_listener = format_tcp_listener_session,
812 .format_half_open = format_tcp_half_open_session,
Dave Barach68b0fb02017-02-28 15:15:56 -0500813};
814
815const static transport_proto_vft_t tcp6_proto = {
816 .bind = tcp_session_bind_ip6,
Florin Corase69f4952017-03-07 10:06:24 -0800817 .unbind = tcp_session_unbind,
Dave Barach68b0fb02017-02-28 15:15:56 -0500818 .push_header = tcp_push_header,
819 .get_connection = tcp_session_get_transport,
820 .get_listener = tcp_session_get_listener,
821 .get_half_open = tcp_half_open_session_get_transport,
822 .open = tcp_session_open_ip6,
823 .close = tcp_session_close,
824 .cleanup = tcp_session_cleanup,
825 .send_mss = tcp_session_send_mss,
826 .send_space = tcp_session_send_space,
Florin Corasd79b41e2017-03-04 05:37:52 -0800827 .tx_fifo_offset = tcp_session_tx_fifo_offset,
Florin Corase69f4952017-03-07 10:06:24 -0800828 .format_connection = format_tcp_session,
829 .format_listener = format_tcp_listener_session,
830 .format_half_open = format_tcp_half_open_session,
Dave Barach68b0fb02017-02-28 15:15:56 -0500831};
832/* *INDENT-ON* */
833
834void
835tcp_timer_keep_handler (u32 conn_index)
836{
Damjan Marion586afd72017-04-05 19:18:20 +0200837 u32 thread_index = vlib_get_thread_index ();
Dave Barach68b0fb02017-02-28 15:15:56 -0500838 tcp_connection_t *tc;
839
Damjan Marion586afd72017-04-05 19:18:20 +0200840 tc = tcp_connection_get (conn_index, thread_index);
Dave Barach68b0fb02017-02-28 15:15:56 -0500841 tc->timers[TCP_TIMER_KEEP] = TCP_TIMER_HANDLE_INVALID;
842
843 tcp_connection_close (tc);
844}
845
846void
847tcp_timer_establish_handler (u32 conn_index)
848{
849 tcp_connection_t *tc;
850 u8 sst;
851
852 tc = tcp_half_open_connection_get (conn_index);
853 tc->timers[TCP_TIMER_ESTABLISH] = TCP_TIMER_HANDLE_INVALID;
854
855 ASSERT (tc->state == TCP_STATE_SYN_SENT);
856
857 sst = tc->c_is_ip4 ? SESSION_TYPE_IP4_TCP : SESSION_TYPE_IP6_TCP;
858 stream_session_connect_notify (&tc->connection, sst, 1 /* fail */ );
859
860 tcp_connection_cleanup (tc);
861}
862
863void
Florin Corasd79b41e2017-03-04 05:37:52 -0800864tcp_timer_waitclose_handler (u32 conn_index)
Dave Barach68b0fb02017-02-28 15:15:56 -0500865{
Damjan Marion586afd72017-04-05 19:18:20 +0200866 u32 thread_index = vlib_get_thread_index ();
Dave Barach68b0fb02017-02-28 15:15:56 -0500867 tcp_connection_t *tc;
868
Damjan Marion586afd72017-04-05 19:18:20 +0200869 tc = tcp_connection_get (conn_index, thread_index);
Florin Corasd79b41e2017-03-04 05:37:52 -0800870 tc->timers[TCP_TIMER_WAITCLOSE] = TCP_TIMER_HANDLE_INVALID;
871
872 /* Session didn't come back with a close(). Send FIN either way
873 * and switch to LAST_ACK. */
874 if (tc->state == TCP_STATE_CLOSE_WAIT)
875 {
876 if (tc->flags & TCP_CONN_FINSNT)
877 {
878 clib_warning ("FIN was sent and still in CLOSE WAIT. Weird!");
879 }
880
881 tcp_send_fin (tc);
882 tc->state = TCP_STATE_LAST_ACK;
883
884 /* Make sure we don't wait in LAST ACK forever */
885 tcp_timer_set (tc, TCP_TIMER_WAITCLOSE, TCP_2MSL_TIME);
886
887 /* Don't delete the connection yet */
888 return;
889 }
Dave Barach68b0fb02017-02-28 15:15:56 -0500890
891 tcp_connection_del (tc);
892}
893
894/* *INDENT-OFF* */
895static timer_expiration_handler *timer_expiration_handlers[TCP_N_TIMERS] =
896{
897 tcp_timer_retransmit_handler,
898 tcp_timer_delack_handler,
Florin Coras3e350af2017-03-30 02:54:28 -0700899 tcp_timer_persist_handler,
Dave Barach68b0fb02017-02-28 15:15:56 -0500900 tcp_timer_keep_handler,
Florin Corasd79b41e2017-03-04 05:37:52 -0800901 tcp_timer_waitclose_handler,
Dave Barach68b0fb02017-02-28 15:15:56 -0500902 tcp_timer_retransmit_syn_handler,
903 tcp_timer_establish_handler
904};
905/* *INDENT-ON* */
906
907static void
908tcp_expired_timers_dispatch (u32 * expired_timers)
909{
910 int i;
911 u32 connection_index, timer_id;
912
913 for (i = 0; i < vec_len (expired_timers); i++)
914 {
915 /* Get session index and timer id */
916 connection_index = expired_timers[i] & 0x0FFFFFFF;
917 timer_id = expired_timers[i] >> 28;
918
Florin Corase69f4952017-03-07 10:06:24 -0800919 TCP_EVT_DBG (TCP_EVT_TIMER_POP, connection_index, timer_id);
920
Dave Barach68b0fb02017-02-28 15:15:56 -0500921 /* Handle expiration */
922 (*timer_expiration_handlers[timer_id]) (connection_index);
923 }
924}
925
926void
927tcp_initialize_timer_wheels (tcp_main_t * tm)
928{
929 tw_timer_wheel_16t_2w_512sl_t *tw;
Florin Corasa5464812017-04-19 13:00:05 -0700930 /* *INDENT-OFF* */
931 foreach_vlib_main (({
932 tw = &tm->timer_wheels[ii];
Dave Barach68b0fb02017-02-28 15:15:56 -0500933 tw_timer_wheel_init_16t_2w_512sl (tw, tcp_expired_timers_dispatch,
934 100e-3 /* timer period 100ms */ , ~0);
Florin Corasa5464812017-04-19 13:00:05 -0700935 tw->last_run_time = vlib_time_now (this_vlib_main);
936 }));
937 /* *INDENT-ON* */
Dave Barach68b0fb02017-02-28 15:15:56 -0500938}
939
940clib_error_t *
Florin Corasa0b34a72017-03-07 01:20:52 -0800941tcp_main_enable (vlib_main_t * vm)
Dave Barach68b0fb02017-02-28 15:15:56 -0500942{
Dave Barach68b0fb02017-02-28 15:15:56 -0500943 tcp_main_t *tm = vnet_get_tcp_main ();
Florin Corasa0b34a72017-03-07 01:20:52 -0800944 ip_protocol_info_t *pi;
945 ip_main_t *im = &ip_main;
Dave Barach68b0fb02017-02-28 15:15:56 -0500946 vlib_thread_main_t *vtm = vlib_get_thread_main ();
947 clib_error_t *error = 0;
948 u32 num_threads;
949
Dave Barach68b0fb02017-02-28 15:15:56 -0500950 if ((error = vlib_call_init_function (vm, ip_main_init)))
951 return error;
952 if ((error = vlib_call_init_function (vm, ip4_lookup_init)))
953 return error;
954 if ((error = vlib_call_init_function (vm, ip6_lookup_init)))
955 return error;
956
957 /*
958 * Registrations
959 */
960
961 /* Register with IP */
962 pi = ip_get_protocol_info (im, IP_PROTOCOL_TCP);
963 if (pi == 0)
964 return clib_error_return (0, "TCP protocol info AWOL");
965 pi->format_header = format_tcp_header;
966 pi->unformat_pg_edit = unformat_pg_tcp_header;
967
968 ip4_register_protocol (IP_PROTOCOL_TCP, tcp4_input_node.index);
969
970 /* Register as transport with URI */
971 session_register_transport (SESSION_TYPE_IP4_TCP, &tcp4_proto);
972 session_register_transport (SESSION_TYPE_IP6_TCP, &tcp6_proto);
973
974 /*
975 * Initialize data structures
976 */
977
978 num_threads = 1 /* main thread */ + vtm->n_threads;
979 vec_validate (tm->connections, num_threads - 1);
980
981 /* Initialize per worker thread tx buffers (used for control messages) */
982 vec_validate (tm->tx_buffers, num_threads - 1);
983
984 /* Initialize timer wheels */
985 vec_validate (tm->timer_wheels, num_threads - 1);
986 tcp_initialize_timer_wheels (tm);
987
Florin Coras6792ec02017-03-13 03:49:51 -0700988// vec_validate (tm->delack_connections, num_threads - 1);
Dave Barach68b0fb02017-02-28 15:15:56 -0500989
990 /* Initialize clocks per tick for TCP timestamp. Used to compute
991 * monotonically increasing timestamps. */
992 tm->tstamp_ticks_per_clock = vm->clib_time.seconds_per_clock
993 / TCP_TSTAMP_RESOLUTION;
994
995 clib_bihash_init_24_8 (&tm->local_endpoints_table, "local endpoint table",
996 200000 /* $$$$ config parameter nbuckets */ ,
997 (64 << 20) /*$$$ config parameter table size */ );
998
999 return error;
1000}
1001
Florin Corasa0b34a72017-03-07 01:20:52 -08001002clib_error_t *
1003vnet_tcp_enable_disable (vlib_main_t * vm, u8 is_en)
1004{
1005 if (is_en)
1006 {
1007 if (tcp_main.is_enabled)
1008 return 0;
1009
1010 return tcp_main_enable (vm);
1011 }
1012 else
1013 {
1014 tcp_main.is_enabled = 0;
1015 }
1016
1017 return 0;
1018}
1019
1020clib_error_t *
1021tcp_init (vlib_main_t * vm)
1022{
1023 tcp_main_t *tm = vnet_get_tcp_main ();
1024
1025 tm->vlib_main = vm;
1026 tm->vnet_main = vnet_get_main ();
1027 tm->is_enabled = 0;
1028
1029 return 0;
1030}
1031
Dave Barach68b0fb02017-02-28 15:15:56 -05001032VLIB_INIT_FUNCTION (tcp_init);
1033
1034/*
1035 * fd.io coding-style-patch-verification: ON
1036 *
1037 * Local Variables:
1038 * eval: (c-set-style "gnu")
1039 * End:
1040 */