23 typedef enum _tcp_output_next
32 #define foreach_tcp4_output_next \ 33 _ (DROP, "error-drop") \ 34 _ (IP_LOOKUP, "ip4-lookup") \ 35 _ (IP_REWRITE, "ip4-rewrite") \ 38 #define foreach_tcp6_output_next \ 39 _ (DROP, "error-drop") \ 40 _ (IP_LOOKUP, "ip6-lookup") \ 41 _ (IP_REWRITE, "ip6-rewrite") \ 42 _ (IP_ARP, "ip6-discover-neighbor") 45 #define tcp_error(n,s) s, 130 if (tc->state != TCP_STATE_SYN_RCVD ||
tcp_opts_wscale (&tc->rcv_opts))
142 u32 available_space, max_fifo, wnd;
150 ASSERT (tc->rcv_opts.mss < max_fifo);
151 if (available_space < tc->rcv_opts.mss && available_space < max_fifo >> 3)
158 observed_wnd = (
i32) tc->rcv_wnd - (tc->rcv_nxt - tc->rcv_las);
159 if (observed_wnd < 0)
163 if (available_space < observed_wnd)
166 TCP_EVT_DBG (TCP_EVT_RCV_WND_SHRUNK, tc, observed_wnd, available_space);
170 wnd = available_space;
174 if (wnd && tc->rcv_wscale)
176 wnd &= ~(1 << tc->rcv_wscale);
178 wnd = 1 << tc->rcv_wscale;
190 if (state < TCP_STATE_ESTABLISHED)
195 if (tc->rcv_wnd == 0)
197 tc->flags |= TCP_CONN_SENT_RCV_WND0;
201 tc->flags &= ~TCP_CONN_SENT_RCV_WND0;
204 return tc->rcv_wnd >> tc->rcv_wscale;
214 u32 buf, seq_len = 4;
220 buf = clib_host_to_net_u16 (opts->
mss);
222 data +=
sizeof (opts->
mss);
245 buf = clib_host_to_net_u32 (opts->
tsval);
247 data +=
sizeof (opts->
tsval);
248 buf = clib_host_to_net_u32 (opts->
tsecr);
250 data +=
sizeof (opts->
tsecr);
260 if (n_sack_blocks != 0)
264 for (i = 0; i < n_sack_blocks; i++)
266 buf = clib_host_to_net_u32 (opts->
sacks[i].start);
269 buf = clib_host_to_net_u32 (opts->
sacks[i].end);
298 opts->
flags |= TCP_OPTS_FLAG_MSS;
302 opts->
flags |= TCP_OPTS_FLAG_WSCALE;
306 opts->
flags |= TCP_OPTS_FLAG_TSTAMP;
313 opts->
flags |= TCP_OPTS_FLAG_SACK_PERMITTED;
327 opts->
flags |= TCP_OPTS_FLAG_MSS;
333 opts->
flags |= TCP_OPTS_FLAG_WSCALE;
334 opts->
wscale = tc->rcv_wscale;
340 opts->
flags |= TCP_OPTS_FLAG_TSTAMP;
342 opts->
tsecr = tc->tsval_recent;
348 opts->
flags |= TCP_OPTS_FLAG_SACK_PERMITTED;
366 opts->
flags |= TCP_OPTS_FLAG_TSTAMP;
368 opts->
tsecr = tc->tsval_recent;
375 opts->
flags |= TCP_OPTS_FLAG_SACK;
376 opts->
sacks = tc->snd_sacks;
394 case TCP_STATE_ESTABLISHED:
395 case TCP_STATE_CLOSE_WAIT:
396 case TCP_STATE_FIN_WAIT_1:
397 case TCP_STATE_LAST_ACK:
398 case TCP_STATE_CLOSING:
399 case TCP_STATE_FIN_WAIT_2:
400 case TCP_STATE_TIME_WAIT:
401 case TCP_STATE_CLOSED:
403 case TCP_STATE_SYN_RCVD:
405 case TCP_STATE_SYN_SENT:
431 TCP_STATE_ESTABLISHED);
434 tc->snd_mss =
clib_min (tc->mss, tc->rcv_opts.mss) - tc->snd_opts_len;
446 u16 default_min_mss = 536;
450 tc->snd_mss =
clib_min (tc->rcv_opts.mss, tc->mss);
452 if (tc->snd_mss < 45)
455 tc->snd_mss = default_min_mss;
456 tc->rcv_opts.mss = default_min_mss;
460 ASSERT (tc->snd_mss > 45);
473 ASSERT (wanted > *n_bufs);
505 if (b->
flags & VLIB_BUFFER_NEXT_PRESENT)
508 b->
flags &= VLIB_BUFFER_NEXT_PRESENT - 1;
521 ASSERT ((b->
flags & VLIB_BUFFER_NEXT_PRESENT) == 0);
522 b->
flags &= VLIB_BUFFER_NON_DEFAULT_FREELIST;
523 b->
flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
540 u8 tcp_opts_len, tcp_hdr_opts_len;
548 tcp_hdr_opts_len = tcp_opts_len +
sizeof (
tcp_header_t);
551 tc->rcv_nxt, tcp_hdr_opts_len, flags, wnd);
554 vnet_buffer (b)->tcp.connection_index = tc->c_c_index;
568 tc->rcv_las = tc->rcv_nxt;
586 vnet_buffer (b)->tcp.flags &= ~TCP_BUF_FLAG_DUPACK;
595 u8 tcp_hdr_opts_len, tcp_opts_len;
605 tcp_hdr_opts_len = tcp_opts_len +
sizeof (
tcp_header_t);
610 vnet_buffer (b)->tcp.connection_index = tc->c_c_index;
622 u8 tcp_opts_len, tcp_hdr_opts_len;
631 tcp_hdr_opts_len = tcp_opts_len +
sizeof (
tcp_header_t);
634 tc->rcv_nxt, tcp_hdr_opts_len,
638 vnet_buffer (b)->tcp.connection_index = tc->c_c_index;
648 u8 is_ip4,
u32 fib_index,
u8 flush)
651 u32 *to_next, next_index;
654 b->
flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
691 u8 is_ip4,
u32 fib_index)
702 u32 *to_next, next_index;
705 b->
flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
777 src_port = th0->src_port;
778 dst_port = th0->dst_port;
781 if (state == TCP_STATE_CLOSED)
786 tmp = clib_net_to_host_u32 (th0->seq_number);
790 ack = clib_host_to_net_u32 (tmp + 1);
796 seq = th0->ack_number;
830 u32 thread_index,
u8 is_ip4)
869 seq = pkt_th->ack_number;
870 ack = (tc->state >= TCP_STATE_SYN_RCVD) ? tc->rcv_nxt : 0;
876 ack = clib_host_to_net_u32 (
vnet_buffer (pkt)->tcp.seq_end);
880 seq, ack, tcp_hdr_len, flags, 0);
916 u16 tcp_hdr_opts_len, advertise_wnd, opts_write_len;
925 tcp_hdr_opts_len = tc->snd_opts_len +
sizeof (
tcp_header_t);
929 tc->rcv_nxt, tcp_hdr_opts_len, flags,
932 ASSERT (opts_write_len == tc->snd_opts_len);
933 vnet_buffer (b)->tcp.connection_index = tc->c_c_index;
938 &tc->c_rmt_ip.ip4, IP_PROTOCOL_TCP, 0);
946 &tc->c_rmt_ip.ip6, IP_PROTOCOL_TCP);
964 &tc->c_rmt_ip4, IP_PROTOCOL_TCP, 1);
973 &tc->c_rmt_ip6, IP_PROTOCOL_TCP);
1011 tc->rtt_seq = tc->snd_nxt;
1092 fin_snt = tc->
flags & TCP_CONN_FINSNT;
1094 tc->snd_nxt = tc->snd_una;
1101 tc->snd_nxt = tc->snd_una_max;
1114 tc->flags |= TCP_CONN_FINSNT;
1115 tc->flags &= ~TCP_CONN_FINPNDG;
1117 tc->snd_una_max += 1;
1118 tc->snd_nxt = tc->snd_una_max;
1122 tc->snd_nxt = tc->snd_una_max;
1131 case TCP_STATE_ESTABLISHED:
1132 case TCP_STATE_CLOSE_WAIT:
1133 case TCP_STATE_TIME_WAIT:
1134 case TCP_STATE_FIN_WAIT_2:
1136 case TCP_STATE_SYN_RCVD:
1138 case TCP_STATE_SYN_SENT:
1140 case TCP_STATE_LAST_ACK:
1141 case TCP_STATE_FIN_WAIT_1:
1142 case TCP_STATE_CLOSING:
1143 if (tc->snd_nxt + 1 < tc->snd_una_max)
1160 u32 advertise_wnd, data_len;
1170 vnet_buffer (b)->tcp.connection_index = tc->c_c_index;
1175 tcp_hdr_opts_len = tc->snd_opts_len +
sizeof (
tcp_header_t);
1178 advertise_wnd = tc->rcv_wnd >> tc->rcv_wscale;
1185 if (
seq_geq (tc->psh_seq, tc->snd_nxt)
1186 &&
seq_lt (tc->psh_seq, tc->snd_nxt + data_len))
1187 flags |= TCP_FLAG_PSH;
1190 tc->rcv_nxt, tcp_hdr_opts_len, flags,
1196 tm->wrk_ctx[tc->c_thread_index].cached_opts,
1202 ASSERT (len == tc->snd_opts_len);
1209 tc->snd_nxt += data_len;
1210 tc->rcv_las = tc->rcv_nxt;
1220 tc->snd_una_max = tc->snd_nxt;
1221 ASSERT (
seq_leq (tc->snd_una_max, tc->snd_una + tc->snd_wnd));
1227 tc->rtt_seq = tc->snd_nxt;
1260 if (!(tc->flags & TCP_CONN_SNDACK))
1263 tc->flags |= TCP_CONN_SNDACK;
1270 if (!(tc->flags & TCP_CONN_SNDACK))
1273 tc->flags |= TCP_CONN_SNDACK;
1275 if (tc->pending_dupacks < 255)
1276 tc->pending_dupacks += 1;
1282 u32 thread_index, *pending_acks;
1291 for (i = 0; i <
vec_len (pending_acks); i++)
1294 tc->flags &= ~TCP_CONN_SNDACK;
1295 n_acks =
clib_max (1, tc->pending_dupacks);
1298 if (tc->pending_dupacks && !vec_len (tc->snd_sacks))
1300 for (j = 0; j < n_acks; j++)
1302 tc->pending_dupacks = 0;
1365 ASSERT (n_bytes == max_deq_bytes);
1368 if (
seq_gt (tc->snd_nxt, tc->snd_una_max))
1369 tc->snd_una_max = tc->snd_nxt;
1374 u32 chain_bi = ~0, n_bufs_per_seg;
1375 u16 n_peeked, len_to_deq, available_bufs;
1380 n_bufs_per_seg = ceil ((
double) seg_size / bytes_per_buffer);
1382 if (n_bufs_per_seg > available_bufs)
1385 if (n_bufs_per_seg > available_bufs)
1397 bytes_per_buffer - MAX_HDRS_LEN);
1399 b[0]->
flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
1401 max_deq_bytes -= n_bytes;
1404 for (i = 1; i < n_bufs_per_seg; i++)
1407 len_to_deq =
clib_min (max_deq_bytes, bytes_per_buffer);
1414 offset + n_bytes, len_to_deq);
1415 ASSERT (n_peeked == len_to_deq);
1416 n_bytes += n_peeked;
1422 prev_b->
flags |= VLIB_BUFFER_NEXT_PRESENT;
1424 max_deq_bytes -= n_peeked;
1429 if (
seq_gt (tc->snd_nxt, tc->snd_una_max))
1430 tc->snd_una_max = tc->snd_nxt;
1434 ASSERT (((*b)->current_data + (*b)->current_length) <= bytes_per_buffer);
1450 u32 start, available_bytes;
1453 ASSERT (tc->state >= TCP_STATE_ESTABLISHED);
1454 ASSERT (max_deq_bytes != 0);
1460 ASSERT (available_bytes >= offset);
1461 available_bytes -=
offset;
1462 if (!available_bytes)
1465 max_deq_bytes =
clib_min (tc->snd_mss, max_deq_bytes);
1466 max_deq_bytes =
clib_min (available_bytes, max_deq_bytes);
1469 start = tc->snd_una +
offset;
1470 if (
seq_geq (start, tc->snd_congestion))
1474 if (
seq_gt (start + max_deq_bytes, tc->snd_congestion))
1476 max_deq_bytes = tc->snd_congestion - start;
1477 if (max_deq_bytes == 0)
1486 tc->snd_rxt_bytes += n_bytes;
1489 TCP_EVT_DBG (TCP_EVT_CC_RTX, tc, offset, n_bytes);
1500 tc->prev_ssthresh = tc->ssthresh;
1501 tc->prev_cwnd = tc->cwnd;
1512 tc->cc_algo->congestion (tc);
1514 tc->snd_congestion = tc->snd_una_max;
1516 tc->cwnd_acc_bytes = 0;
1535 if (
PREDICT_FALSE (tc == 0 || tc->state != TCP_STATE_SYN_SENT))
1543 if (
PREDICT_FALSE (tc == 0 || tc->state == TCP_STATE_SYN_SENT))
1547 if (tc->state == TCP_STATE_CLOSED)
1551 if (tc->state >= TCP_STATE_ESTABLISHED)
1566 if ((tc->rto_boff == 0 && tc->snd_una == tc->snd_una_max)
1567 || (tc->rto_boff > 0 &&
seq_geq (tc->snd_una, tc->snd_congestion)
1588 if (tc->rto_boff == 1)
1594 if (
seq_gt (tc->snd_una_max, tc->snd_congestion))
1595 tc->snd_congestion = tc->snd_una_max;
1597 tc->snd_una_max = tc->snd_nxt = tc->snd_una;
1612 if (tc->rto_boff == 1)
1619 else if (tc->state == TCP_STATE_SYN_SENT)
1624 if (tc->flags & TCP_CONN_HALF_OPEN_DONE)
1627 TCP_DBG (
"could not remove half-open connection");
1657 else if (tc->state == TCP_STATE_SYN_RCVD)
1682 ASSERT (tc->state == TCP_STATE_CLOSED);
1708 u32 bi, max_snd_bytes, available_bytes,
offset;
1725 if (tc->state == TCP_STATE_CLOSED || tc->state > TCP_STATE_ESTABLISHED
1726 || tc->snd_wnd > tc->snd_mss)
1730 offset = tc->snd_una_max - tc->snd_una;
1734 if (!available_bytes)
1740 if (available_bytes <= offset)
1768 || tc->snd_nxt == tc->snd_una_max
1769 || tc->rto_boff > 1));
1772 tc->snd_una_max = tc->snd_nxt;
1786 u32 bi, old_snd_nxt, n_bytes;
1790 old_snd_nxt = tc->snd_nxt;
1791 tc->snd_nxt = tc->snd_una;
1801 tc->snd_nxt = old_snd_nxt;
1814 tc->snd_nxt = tc->snd_una_max;
1815 offset = tc->snd_una_max - tc->snd_una;
1816 while (n_segs < burst_size)
1824 offset += n_written;
1832 #define scoreboard_rescue_rxt_valid(_sb, _tc) \ 1833 (seq_geq (_sb->rescue_rxt, _tc->snd_una) \ 1834 && seq_leq (_sb->rescue_rxt, _tc->snd_congestion)) 1843 u32 n_written = 0,
offset, max_bytes, n_segs = 0, n_segs_now;
1848 u32 bi, old_snd_nxt;
1851 u8 snd_limited = 0, can_rescue = 0;
1856 if (snd_space < tc->snd_mss)
1863 old_snd_nxt = tc->snd_nxt;
1868 max_deq -= tc->snd_una_max - tc->snd_una;
1870 while (snd_space > 0 && n_segs < burst_size)
1878 snd_space =
clib_min (max_deq, snd_space);
1879 burst_size =
clib_min (burst_size - n_segs,
1880 snd_space / tc->snd_mss);
1882 if (max_deq > n_segs_now * tc->snd_mss)
1884 n_segs += n_segs_now;
1897 tc->snd_congestion - tc->snd_una);
1898 max_bytes =
clib_min (max_bytes, snd_space);
1899 offset = tc->snd_congestion - tc->snd_una - max_bytes;
1900 sb->rescue_rxt = tc->snd_congestion;
1901 tc->snd_nxt = tc->snd_una +
offset;
1913 max_bytes =
clib_min (hole->end - sb->high_rxt, snd_space);
1914 max_bytes = snd_limited ?
clib_min (max_bytes, tc->snd_mss) : max_bytes;
1918 offset = sb->high_rxt - tc->snd_una;
1919 tc->snd_nxt = sb->high_rxt;
1922 ASSERT (n_written <= snd_space);
1931 sb->high_rxt += n_written;
1932 snd_space -= n_written;
1941 tc->snd_nxt = old_snd_nxt;
1952 u32 n_written = 0,
offset = 0, bi, old_snd_nxt, max_deq, n_segs_now;
1954 int snd_space, n_segs = 0;
1959 old_snd_nxt = tc->snd_nxt;
1966 snd_space = tc->sack_sb.last_bytes_delivered;
1967 tc->snd_nxt = tc->snd_una;
1968 while (snd_space > 0 && n_segs < burst_size)
1979 snd_space -= n_written;
1984 if (n_segs == burst_size)
1991 if (snd_space < tc->snd_mss || tc->snd_mss == 0)
1995 max_deq -= tc->snd_una_max - tc->snd_una;
1998 snd_space =
clib_min (max_deq, snd_space);
1999 burst_size =
clib_min (burst_size - n_segs, snd_space / tc->snd_mss);
2001 if (max_deq > n_segs_now * tc->snd_mss)
2003 n_segs += n_segs_now;
2007 tc->snd_nxt = old_snd_nxt;
2029 u16 * next0,
u32 * error0)
2042 *error0 = TCP_ERROR_LINK_LOCAL_RW;
2054 *error0 = TCP_ERROR_LINK_LOCAL_RW;
2061 u32 * to_next,
u32 n_bufs)
2070 for (i = 0; i <
clib_min (n_trace, n_bufs); i++)
2093 IP_PROTOCOL_TCP, 1);
2094 b0->
flags |= VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
2102 &tc0->c_rmt_ip6, IP_PROTOCOL_TCP);
2103 b0->
flags |= VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
2112 u32 * error0,
u16 * next0,
u8 is_ip4)
2117 *error0 = TCP_ERROR_INVALID_CONNECTION;
2154 while (n_left_from >= 4)
2156 u32 error0 = TCP_ERROR_PKTS_SENT, error1 = TCP_ERROR_PKTS_SENT;
2184 while (n_left_from > 0)
2186 u32 error0 = TCP_ERROR_PKTS_SENT;
2189 if (n_left_from > 1)
2229 .name =
"tcp4-output",
2231 .vector_size =
sizeof (
u32),
2237 #define _(s,n) [TCP_OUTPUT_NEXT_##s] = n, 2252 .name =
"tcp6-output",
2254 .vector_size =
sizeof (
u32),
2260 #define _(s,n) [TCP_OUTPUT_NEXT_##s] = n, 2271 typedef enum _tcp_reset_next
2278 #define foreach_tcp4_reset_next \ 2279 _(DROP, "error-drop") \ 2280 _(IP_LOOKUP, "ip4-lookup") 2282 #define foreach_tcp6_reset_next \ 2283 _(DROP, "error-drop") \ 2284 _(IP_LOOKUP, "ip6-lookup") 2290 u32 n_left_from, next_index, *from, *to_next;
2298 while (n_left_from > 0)
2304 while (n_left_from > 0 && n_left_to_next > 0)
2317 n_left_to_next -= 1;
2322 my_thread_index, is_ip4))
2324 error0 = TCP_ERROR_LOOKUP_DROPS;
2335 b0->
flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
2349 n_left_to_next, bi0, next0);
2373 .name =
"tcp4-reset",
2374 .vector_size =
sizeof (
u32),
2379 #define _(s,n) [TCP_RESET_NEXT_##s] = n, 2392 .name =
"tcp6-reset",
2393 .vector_size =
sizeof (
u32),
2398 #define _(s,n) [TCP_RESET_NEXT_##s] = n, void tcp_make_fin(tcp_connection_t *tc, vlib_buffer_t *b)
Convert buffer to FIN-ACK.
#define tcp_in_cong_recovery(tc)
#define TCP_DBG_BUFFER_ALLOC_MAYBE_FAIL(thread_index)
void session_flush_frames_main_thread(vlib_main_t *vm)
static u32 tcp_options_write(u8 *data, tcp_options_t *opts)
Write TCP options to segment.
static void tcp_rxt_timeout_cc(tcp_connection_t *tc)
Reset congestion control, switch cwnd to loss window and try again.
#define TCP_OPTION_LEN_EOL
u32 * pending_acks
vector of pending acks
#define tcp_in_recovery(tc)
void scoreboard_clear(sack_scoreboard_t *sb)
static f64 tcp_time_now_us(u32 thread_index)
static void tcp_retransmit_timer_set(tcp_connection_t *tc)
static u32 transport_rx_fifo_size(transport_connection_t *tc)
#define TCP_OPTION_LEN_SACK_PERMITTED
#define seq_leq(_s1, _s2)
static u32 vlib_get_trace_count(vlib_main_t *vm, vlib_node_runtime_t *rt)
void tcp_timer_retransmit_handler(u32 index)
#define TCP_TO_TIMER_TICK
#define TCP_MIN_RX_FIFO_SIZE
#define tcp_opts_tstamp(_to)
static uword tcp4_send_reset(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
void tcp_make_synack(tcp_connection_t *tc, vlib_buffer_t *b)
Convert buffer to SYN-ACK.
static void tcp_flush_frame_to_ip_lookup(tcp_worker_ctx_t *wrk, u8 is_ip4)
Flush ip lookup tx frames populated by timer pops.
static tcp_connection_t * tcp_connection_get_if_valid(u32 conn_index, u32 thread_index)
static int tcp_make_syn_options(tcp_options_t *opts, u8 wnd_scale)
#define clib_memcpy_fast(a, b, c)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
struct _sack_scoreboard sack_scoreboard_t
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
static tcp_connection_t * tcp_half_open_connection_get(u32 conn_index)
void tcp_update_rcv_mss(tcp_connection_t *tc)
Update max segment size we're able to process.
vlib_frame_t * tx_frames[2]
tx frames for tcp 4/6 output nodes
void tcp_send_acks(tcp_worker_ctx_t *wrk)
struct _tcp_main tcp_main_t
This packet is to be rewritten and forwarded to the next processing node.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static u32 tcp_initial_wnd_unscaled(tcp_connection_t *tc)
TCP's initial window.
enum _tcp_output_next tcp_output_next_t
struct _tcp_connection tcp_connection_t
static u32 tcp_available_cc_snd_space(const tcp_connection_t *tc)
Estimate of how many bytes we can still push into the network.
#define tcp_opts_sack(_to)
static void tcp_push_ip_hdr(tcp_worker_ctx_t *wrk, tcp_connection_t *tc, vlib_buffer_t *b)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static uword tcp46_send_reset_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u8 is_ip4)
vlib_error_t * errors
Vector of errors for this node.
int tcp_fast_retransmit_no_sack(tcp_worker_ctx_t *wrk, tcp_connection_t *tc, u32 burst_size)
Fast retransmit without SACK info.
u8 n_sack_blocks
Number of SACKs blocks.
static void tcp_enqueue_to_output_i(tcp_worker_ctx_t *wrk, vlib_buffer_t *b, u32 bi, u8 is_ip4, u8 flush)
struct _tcp_header tcp_header_t
int tcp_half_open_connection_cleanup(tcp_connection_t *tc)
Try to cleanup half-open connection.
#define scoreboard_rescue_rxt_valid(_sb, _tc)
struct _sack_scoreboard_hole sack_scoreboard_hole_t
u8 wscale
Window scale advertised.
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
#define TCP_OPTS_MAX_SACK_BLOCKS
#define TCP_MAX_RX_FIFO_SIZE
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
static void tcp_timer_retransmit_handler_i(u32 index, u8 is_syn)
#define foreach_tcp4_reset_next
static u32 tcp_prepare_retransmit_segment(tcp_worker_ctx_t *wrk, tcp_connection_t *tc, u32 offset, u32 max_deq_bytes, vlib_buffer_t **b)
Build a retransmit segment.
static uword tcp46_output_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_ip4)
static void * tcp_init_buffer(vlib_main_t *vm, vlib_buffer_t *b)
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
void tcp_make_syn(tcp_connection_t *tc, vlib_buffer_t *b)
Convert buffer to SYN.
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static int tcp_prepare_segment(tcp_worker_ctx_t *wrk, tcp_connection_t *tc, u32 offset, u32 max_deq_bytes, vlib_buffer_t **b)
Allocate a new buffer and build a new tcp segment.
sack_scoreboard_hole_t * scoreboard_get_hole(sack_scoreboard_t *sb, u32 index)
#define TCP_OPTION_LEN_SACK_BLOCK
static tcp_header_t * tcp_buffer_hdr(vlib_buffer_t *b)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
u8 * format_tcp_tx_trace(u8 *s, va_list *args)
enum _tcp_state tcp_state_t
#define TCP_ALWAYS_ACK
On/off delayed acks.
vhost_vring_state_t state
static void * ip4_next_header(ip4_header_t *i)
static u32 tcp_time_now(void)
sack_block_t * sacks
SACK blocks.
static void tcp46_output_trace_frame(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *to_next, u32 n_bufs)
#define TCP_ESTABLISH_TIME
sack_scoreboard_hole_t * scoreboard_next_rxt_hole(sack_scoreboard_t *sb, sack_scoreboard_hole_t *start, u8 have_sent_1_smss, u8 *can_rescue, u8 *snd_limited)
Figure out the next hole to retransmit.
#define tcp_validate_txf_size(_tc, _a)
static void tcp_enqueue_to_ip_lookup_now(tcp_worker_ctx_t *wrk, vlib_buffer_t *b, u32 bi, u8 is_ip4, u32 fib_index)
#define TCP_EVT_DBG(_evt, _args...)
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
static int tcp_alloc_tx_buffers(tcp_worker_ctx_t *wrk, u16 *n_bufs, u32 wanted)
static void tcp_timer_set(tcp_connection_t *tc, u8 timer_id, u32 interval)
#define TCP_OPTION_LEN_WINDOW_SCALE
vlib_node_registration_t tcp6_reset_node
(constructor) VLIB_REGISTER_NODE (tcp6_reset_node)
#define TCP_RTO_SYN_RETRIES
int tcp_fast_retransmit_sack(tcp_worker_ctx_t *wrk, tcp_connection_t *tc, u32 burst_size)
Do fast retransmit with SACKs.
#define tcp_trajectory_add_start(b, start)
vlib_main_t * vm
convenience pointer to this thread's vlib main
void tcp_send_reset(tcp_connection_t *tc)
Build and set reset packet for connection.
void tcp_send_synack(tcp_connection_t *tc)
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
static int tcp_make_synack_options(tcp_connection_t *tc, tcp_options_t *opts)
u16 current_length
Nbytes between current data and the end of this buffer.
static void * vlib_buffer_make_headroom(vlib_buffer_t *b, u8 size)
Make head room, typically for packet headers.
#define tcp_in_fastrecovery(tc)
void tcp_connection_tx_pacer_reset(tcp_connection_t *tc, u32 window, u32 start_bucket)
static void * vlib_buffer_push_tcp_net_order(vlib_buffer_t *b, u16 sp, u16 dp, u32 seq, u32 ack, u8 tcp_hdr_opts_len, u8 flags, u16 wnd)
Push TCP header to buffer.
#define tcp_opts_mss(_to)
void tcp_flush_frames_to_output(tcp_worker_ctx_t *wrk)
Flush v4 and v6 tcp and ip-lookup tx frames for thread index.
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
u32 tcp_push_header(tcp_connection_t *tc, vlib_buffer_t *b)
#define TCP_TIMER_HANDLE_INVALID
static void tcp_output_handle_link_local(tcp_connection_t *tc0, vlib_buffer_t *b0, u16 *next0, u32 *error0)
#define foreach_tcp6_output_next
static u32 tcp_flight_size(const tcp_connection_t *tc)
Our estimate of the number of bytes in flight (pipe size)
static int tcp_make_reset_in_place(vlib_main_t *vm, vlib_buffer_t *b0, tcp_state_t state, u8 thread_index, u8 is_ip4)
static u8 tcp_window_compute_scale(u32 window)
void tcp_timer_retransmit_syn_handler(u32 index)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
#define TCP_OPTION_LEN_TIMESTAMP
#define foreach_tcp4_output_next
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static void tcp_enqueue_to_ip_lookup(tcp_worker_ctx_t *wrk, vlib_buffer_t *b, u32 bi, u8 is_ip4, u32 fib_index)
void tcp_make_ack(tcp_connection_t *tc, vlib_buffer_t *b)
Convert buffer to ACK.
#define TCP_DBG(_fmt, _args...)
#define TCP_MAX_WND_SCALE
static void tcp_timer_reset(tcp_connection_t *tc, u8 timer_id)
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
#define VLIB_REGISTER_NODE(x,...)
static void * vlib_buffer_push_tcp(vlib_buffer_t *b, u16 sp_net, u16 dp_net, u32 seq, u32 ack, u8 tcp_hdr_opts_len, u8 flags, u16 wnd)
Push TCP header to buffer.
static_always_inline uword vlib_get_thread_index(void)
#define CLIB_PREFETCH(addr, size, type)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
void tcp_send_reset_w_pkt(tcp_connection_t *tc, vlib_buffer_t *pkt, u32 thread_index, u8 is_ip4)
Send reset without reusing existing buffer.
#define clib_warning(format, args...)
static u8 tcp_make_state_flags(tcp_connection_t *tc, tcp_state_t next_state)
#define TCP_USE_SACKS
Disable only for testing.
#define tcp_recovery_on(tc)
static u32 tcp_window_to_advertise(tcp_connection_t *tc, tcp_state_t state)
Compute and return window to advertise, scaled as per RFC1323.
#define tcp_fastrecovery_first(tc)
u32 adj_index_t
An index for adjacencies.
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
u16 mss
Option flags, see above.
static void tcp_output_handle_packet(tcp_connection_t *tc0, vlib_buffer_t *b0, u32 *error0, u16 *next0, u8 is_ip4)
static void * ip6_next_header(ip6_header_t *i)
void tcp_program_fastretransmit(tcp_worker_ctx_t *wrk, tcp_connection_t *tc)
static void tcp_timer_update(tcp_connection_t *tc, u8 timer_id, u32 interval)
u16 ip6_tcp_udp_icmp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip6_header_t *ip0, int *bogus_lengthp)
vlib_node_registration_t ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (ip6_lookup_node)
static int tcp_make_established_options(tcp_connection_t *tc, tcp_options_t *opts)
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static void tcp_output_push_ip(vlib_main_t *vm, vlib_buffer_t *b0, tcp_connection_t *tc0, u8 is_ip4)
u32 session_tx_fifo_max_dequeue(transport_connection_t *tc)
static uword tcp6_output(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static int tcp_get_free_buffer_index(tcp_worker_ctx_t *wrk, u32 *bidx)
u16 ip4_tcp_udp_compute_checksum(vlib_main_t *vm, vlib_buffer_t *p0, ip4_header_t *ip0)
void tcp_update_burst_snd_vars(tcp_connection_t *tc)
Update burst send vars.
#define seq_geq(_s1, _s2)
u32 next_buffer
Next buffer for this linked-list of buffers.
void tcp_init_mss(tcp_connection_t *tc)
static uword tcp6_send_reset(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static uword ip6_address_is_link_local_unicast(const ip6_address_t *a)
#define tcp_fastrecovery_first_off(tc)
static void tcp_update_rcv_wnd(tcp_connection_t *tc)
void tcp_send_fin(tcp_connection_t *tc)
Send FIN.
static vlib_main_t * vlib_get_main(void)
static u32 tcp_time_now_w_thread(u32 thread_index)
VLIB_NODE_FUNCTION_MULTIARCH(tcp4_output_node, tcp4_output)
void tcp_send_ack(tcp_connection_t *tc)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
struct _vlib_node_registration vlib_node_registration_t
int tcp_retransmit_first_unacked(tcp_worker_ctx_t *wrk, tcp_connection_t *tc)
Retransmit first unacked segment.
template key/value backing page structure
#define tcp_opts_wscale(_to)
u32 tsval
Timestamp value.
u32 tsecr
Echoed/reflected time stamp.
static void * vlib_buffer_push_ip6(vlib_main_t *vm, vlib_buffer_t *b, ip6_address_t *src, ip6_address_t *dst, int proto)
Push IPv6 header to buffer.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip_lookup_next_t lookup_next_index
Next hop after ip4-lookup.
static u8 tcp_is_lost_fin(tcp_connection_t *tc)
#define foreach_tcp6_reset_next
static int tcp_fast_retransmit_unsent(tcp_worker_ctx_t *wrk, tcp_connection_t *tc, u32 burst_size)
#define VLIB_BUFFER_TRACE_TRAJECTORY_INIT(b)
static tcp_worker_ctx_t * tcp_get_worker(u32 thread_index)
static void tcp_retransmit_timer_update(tcp_connection_t *tc)
static void tcp_enqueue_to_ip_lookup_i(tcp_worker_ctx_t *wrk, vlib_buffer_t *b, u32 bi, u8 is_ip4, u32 fib_index, u8 flush)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static void tcp_make_ack_i(tcp_connection_t *tc, vlib_buffer_t *b, tcp_state_t state, u8 flags)
Prepare ACK.
void tcp_timer_delack_handler(u32 index)
Delayed ack timer handler.
#define TCP_OPTION_LEN_MSS
void tcp_flush_frame_to_output(tcp_worker_ctx_t *wrk, u8 is_ip4)
Flush tx frame populated by retransmits and timer pops.
struct clib_bihash_value offset
template key/value backing page structure
static void tcp_retransmit_timer_force_update(tcp_connection_t *tc)
int tcp_fast_retransmit(tcp_worker_ctx_t *wrk, tcp_connection_t *tc, u32 burst_size)
Do fast retransmit.
u8 * format_tcp_connection(u8 *s, va_list *args)
u32 tcp_initial_window_to_advertise(tcp_connection_t *tc)
Compute initial window and scale factor.
static tcp_connection_t * tcp_connection_get(u32 conn_index, u32 thread_index)
void tcp_update_rto(tcp_connection_t *tc)
static u32 vlib_num_workers()
#define TCP_OPTION_LEN_NOOP
void tcp_send_syn(tcp_connection_t *tc)
Send SYN.
vlib_node_registration_t tcp6_output_node
(constructor) VLIB_REGISTER_NODE (tcp6_output_node)
u16 flags
Copy of main node flags.
void tcp_program_ack(tcp_worker_ctx_t *wrk, tcp_connection_t *tc)
enum _tcp_reset_next tcp_reset_next_t
static u32 transport_max_rx_enqueue(transport_connection_t *tc)
#define tcp_opts_sack_permitted(_to)
static void vlib_buffer_free_one(vlib_main_t *vm, u32 buffer_index)
Free one buffer Shorthand to free a single buffer chain.
tcp_connection_t tcp_connection
static u32 tcp_loss_wnd(const tcp_connection_t *tc)
vlib_frame_t * ip_lookup_tx_frames[2]
tx frames for ip 4/6 lookup nodes
static void * tcp_reuse_buffer(vlib_main_t *vm, vlib_buffer_t *b)
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
static void tcp_enqueue_to_output_now(tcp_worker_ctx_t *wrk, vlib_buffer_t *b, u32 bi, u8 is_ip4)
vlib_node_registration_t tcp4_reset_node
(constructor) VLIB_REGISTER_NODE (tcp4_reset_node)
#define VLIB_NODE_FLAG_TRACE
vlib_node_registration_t tcp4_output_node
(constructor) VLIB_REGISTER_NODE (tcp4_output_node)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static void tcp_enqueue_to_output(tcp_worker_ctx_t *wrk, vlib_buffer_t *b, u32 bi, u8 is_ip4)
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
static void tcp_persist_timer_set(tcp_connection_t *tc)
static tcp_main_t * vnet_get_tcp_main()
int stream_session_peek_bytes(transport_connection_t *tc, u8 *buffer, u32 offset, u32 max_bytes)
static char * tcp_error_strings[]
static uword tcp4_output(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
static void * vlib_buffer_push_ip4(vlib_main_t *vm, vlib_buffer_t *b, ip4_address_t *src, ip4_address_t *dst, int proto, u8 csum_offload)
Push IPv4 header to buffer.
static void tcp_push_hdr_i(tcp_connection_t *tc, vlib_buffer_t *b, tcp_state_t next_state, u8 compute_opts, u8 maybe_burst)
Push TCP header and update connection variables.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
void tcp_cc_fastrecovery_exit(tcp_connection_t *tc)
static u32 tcp_set_time_now(tcp_worker_ctx_t *wrk)
void tcp_timer_persist_handler(u32 index)
Got 0 snd_wnd from peer, try to do something about it.
static u8 tcp_timer_is_active(tcp_connection_t *tc, tcp_timers_e timer)
u32 * tx_buffers
tx buffer free list
adj_index_t adj_nbr_find(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Lookup neighbor adjancency.
static int tcp_make_options(tcp_connection_t *tc, tcp_options_t *opts, tcp_state_t state)
void tcp_program_dupack(tcp_worker_ctx_t *wrk, tcp_connection_t *tc)