25 #define tcp_error(n,s) s, 31 #define foreach_tcp_state_next \ 32 _ (DROP4, "ip4-drop") \ 33 _ (DROP6, "ip6-drop") \ 34 _ (TCP4_OUTPUT, "tcp4-output") \ 35 _ (TCP6_OUTPUT, "tcp6-output") 37 typedef enum _tcp_established_next
39 #define _(s,n) TCP_ESTABLISHED_NEXT_##s, 45 typedef enum _tcp_rcv_process_next
47 #define _(s,n) TCP_RCV_PROCESS_NEXT_##s, 53 typedef enum _tcp_syn_sent_next
55 #define _(s,n) TCP_SYN_SENT_NEXT_##s, 61 typedef enum _tcp_listen_next
63 #define _(s,n) TCP_LISTEN_NEXT_##s, 70 typedef enum _tcp_state_next
72 #define _(s,n) TCP_NEXT_##s, 78 #define tcp_next_output(is_ip4) (is_ip4 ? TCP_NEXT_TCP4_OUTPUT \ 79 : TCP_NEXT_TCP6_OUTPUT) 81 #define tcp_next_drop(is_ip4) (is_ip4 ? TCP_NEXT_DROP4 \ 114 return (
seq_geq (end_seq, tc->rcv_las)
115 &&
seq_leq (seq, tc->rcv_nxt + tc->rcv_wnd));
130 u8 opt_len, opts_len, kind;
135 data = (
const u8 *) (th + 1);
138 to->
flags &= (TCP_OPTS_FLAG_SACK_PERMITTED | TCP_OPTS_FLAG_WSCALE
139 | TCP_OPTS_FLAG_TSTAMP | TCP_OPTS_FLAG_MSS);
141 for (; opts_len > 0; opts_len -= opt_len, data += opt_len)
161 if (opt_len < 2 || opt_len > opts_len)
173 to->
flags |= TCP_OPTS_FLAG_MSS;
174 to->
mss = clib_net_to_host_u16 (*(
u16 *) (data + 2));
182 to->
flags |= TCP_OPTS_FLAG_WSCALE;
190 to->
flags |= TCP_OPTS_FLAG_TSTAMP;
191 if ((to->
flags & TCP_OPTS_FLAG_TSTAMP)
194 to->
tsval = clib_net_to_host_u32 (*(
u32 *) (data + 2));
195 to->
tsecr = clib_net_to_host_u32 (*(
u32 *) (data + 6));
202 to->
flags |= TCP_OPTS_FLAG_SACK_PERMITTED;
206 if ((to->
flags & TCP_OPTS_FLAG_SACK_PERMITTED) == 0 ||
tcp_syn (th))
213 to->
flags |= TCP_OPTS_FLAG_SACK;
218 b.start = clib_net_to_host_u32 (*(
u32 *) (data + 2 + 8 * j));
219 b.end = clib_net_to_host_u32 (*(
u32 *) (data + 6 + 8 * j));
261 &&
seq_leq (tc->rcv_las, seq_end))
264 tc->tsval_recent = tc->rcv_opts.tsval;
286 *error0 = TCP_ERROR_CONNECTION_CLOSED;
292 *error0 = TCP_ERROR_SEGMENT_INVALID;
298 *error0 = TCP_ERROR_OPTIONS;
304 *error0 = TCP_ERROR_PAWS;
313 tc0->tsval_recent = tc0->rcv_opts.tsval;
334 &&
vnet_buffer (b0)->tcp.seq_number == tc0->rcv_nxt - 1)
337 if (tc0->state == TCP_STATE_SYN_RCVD)
340 TCP_EVT (TCP_EVT_SYN_RCVD, tc0, 0);
341 *error0 = TCP_ERROR_SYNS_RCVD;
346 TCP_EVT (TCP_EVT_SYNACK_RCVD, tc0);
347 *error0 = TCP_ERROR_SYN_ACKS_RCVD;
354 if (tc0->rcv_wnd < tc0->snd_mss
355 && tc0->rcv_nxt ==
vnet_buffer (b0)->tcp.seq_number)
363 tc0->rcv_las - tc0->rcv_wnd)
365 tc0->rcv_nxt + tc0->rcv_wnd))
368 *error0 = TCP_ERROR_RCV_WND;
372 if ((tc0->flags & TCP_CONN_ZERO_RWND_SENT)
374 tc0->rcv_las + tc0->rcv_opts.mss))
375 *error0 = TCP_ERROR_ZERO_RWND;
396 *error0 = TCP_ERROR_RST_RCVD;
407 *error0 = TCP_ERROR_SPURIOUS_SYN;
433 *error = TCP_ERROR_ACK_INVALID;
438 tc->bytes_acked =
vnet_buffer (b)->tcp.ack_number - tc->snd_una;
440 *error = TCP_ERROR_ACK_OK;
460 err = mrtt - tc->srtt;
464 tc->srtt =
clib_max ((
int) tc->srtt + (err >> 3), 1);
465 diff = (
clib_abs (err) - (int) tc->rttvar) >> 2;
466 tc->rttvar =
clib_max ((
int) tc->rttvar + diff, 1);
472 tc->rttvar = mrtt >> 1;
476 #ifndef CLIB_MARCH_VARIANT 506 if ((tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE)
515 if (tc->rtt_ts &&
seq_geq (ack, tc->rtt_seq))
518 tc->mrtt_us = tc->mrtt_us + (sample - tc->mrtt_us) * 0.125;
529 mrtt =
clib_max (now - tc->rcv_opts.tsecr, 1);
559 tc->mrtt_us =
clib_max (tc->mrtt_us, 0.0001);
568 if (tc->rto_boff && mrtt > 1 *
THZ)
590 return (space < tc->snd_mss + tc->burst_acked);
600 u32 *pending_deq_acked;
608 for (i = 0; i <
vec_len (pending_deq_acked); i++)
611 tc->flags &= ~TCP_CONN_DEQ_PENDING;
621 if (
seq_leq (tc->psh_seq, tc->snd_una))
622 tc->flags &= ~TCP_CONN_PSH_PENDING;
635 if (tc->data_segs_out == tc->prev_dsegs_out
639 tc->prev_dsegs_out = tc->data_segs_out;
648 if (!(tc->flags & TCP_CONN_DEQ_PENDING))
651 tc->flags |= TCP_CONN_DEQ_PENDING;
653 tc->burst_acked += tc->bytes_acked;
656 #ifndef CLIB_MARCH_VARIANT 661 return hole - sb->holes;
667 return hole->end - hole->start;
718 next->prev = hole->prev;
722 sb->tail = hole->prev;
728 prev->next = hole->next;
732 sb->head = hole->next;
762 hole->prev = prev_index;
763 hole->next = prev->next;
766 next->prev = hole_index;
768 sb->tail = hole_index;
770 prev->next = hole_index;
774 sb->head = hole_index;
786 if (!has_rxt ||
seq_geq (start, sb->high_rxt))
790 seq_lt (end, sb->high_rxt) ? (end - start) : (sb->high_rxt - start);
797 u32 sacked = 0, blks = 0, old_sacked;
799 old_sacked = sb->sacked_bytes;
801 sb->last_lost_bytes = 0;
803 sb->sacked_bytes = 0;
808 sb->sacked_bytes = sb->high_sacked - ack;
809 sb->last_sacked_bytes = sb->sacked_bytes
810 - (old_sacked - sb->last_bytes_delivered);
814 if (
seq_gt (sb->high_sacked, right->end))
816 sacked = sb->high_sacked - right->end;
829 ASSERT (right->start == ack || sb->is_reneging);
830 sacked += right->start - ack;
835 sacked += right->start - left->end;
844 sb->last_lost_bytes += right->is_lost ? 0 : (right->end - right->start);
849 ASSERT (right->start == ack || sb->is_reneging);
850 sacked += right->start - ack;
853 sacked += right->start - left->end;
857 sb->sacked_bytes = sacked;
858 sb->last_sacked_bytes = sacked - (old_sacked - sb->last_bytes_delivered);
869 u8 have_unsent,
u8 * can_rescue,
u8 * snd_limited)
874 while (hole &&
seq_leq (hole->end, sb->high_rxt) && hole->is_lost)
885 if (hole->is_lost &&
seq_lt (hole->start, sb->high_sacked))
898 else if (
seq_lt (hole->start, sb->high_sacked))
901 if (
seq_leq (hole->end, sb->high_rxt))
920 if (hole &&
seq_lt (sb->high_rxt, hole->start))
921 sb->high_rxt = hole->start;
933 snd_una =
seq_gt (snd_una, hole->start) ? snd_una : hole->start;
934 sb->cur_rxt_hole = sb->head;
936 sb->high_rxt = snd_una;
937 sb->rescue_rxt = snd_una - 1;
958 sb->sacked_bytes = 0;
959 sb->last_sacked_bytes = 0;
960 sb->last_bytes_delivered = 0;
962 sb->last_lost_bytes = 0;
977 last_hole->is_lost = 1;
979 sb->high_sacked = start;
996 return (!hole || (
seq_geq (hole->start, tc->snd_una)
997 &&
seq_lt (hole->end, tc->snd_nxt)));
1000 #ifndef CLIB_MARCH_VARIANT 1008 u32 blk_index = 0,
i, j;
1011 sb->last_sacked_bytes = 0;
1012 sb->last_bytes_delivered = 0;
1022 blk = tc->rcv_opts.sacks;
1023 while (blk <
vec_end (tc->rcv_opts.sacks))
1025 if (
seq_lt (blk->start, blk->end)
1026 &&
seq_gt (blk->start, tc->snd_una)
1027 &&
seq_gt (blk->start, ack) &&
seq_leq (blk->end, tc->snd_nxt))
1032 vec_del1 (tc->rcv_opts.sacks, blk - tc->rcv_opts.sacks);
1036 if (
seq_gt (ack, tc->snd_una))
1038 vec_add2 (tc->rcv_opts.sacks, blk, 1);
1039 blk->start = tc->snd_una;
1043 if (
vec_len (tc->rcv_opts.sacks) == 0)
1049 rcv_sacks = tc->rcv_opts.sacks;
1051 for (j =
i + 1; j <
vec_len (rcv_sacks); j++)
1052 if (
seq_lt (rcv_sacks[j].start, rcv_sacks[
i].start))
1055 rcv_sacks[
i] = rcv_sacks[j];
1065 if (
seq_leq (tc->snd_nxt, sb->high_sacked))
1068 if (
seq_leq (ack, tc->snd_una))
1072 sb->last_bytes_delivered = ack - tc->snd_una;
1073 sb->sacked_bytes -= sb->last_bytes_delivered;
1074 sb->is_reneging =
seq_lt (ack, sb->high_sacked);
1080 sb->high_sacked, tc->snd_nxt);
1088 tc->snd_una, tc->snd_nxt);
1091 sb->high_sacked = rcv_sacks[
vec_len (rcv_sacks) - 1].end;
1098 if (
seq_gt (tc->snd_nxt, hole->end))
1100 if (
seq_geq (hole->start, sb->high_sacked))
1102 hole->end = tc->snd_nxt;
1105 else if (
seq_lt (sb->high_sacked, tc->snd_nxt))
1114 sb->high_sacked =
seq_max (rcv_sacks[vec_len (rcv_sacks) - 1].end,
1123 sb->last_bytes_delivered +=
clib_min (hole->start - tc->snd_una,
1125 sb->is_reneging =
seq_lt (ack, hole->start);
1128 while (hole && blk_index < vec_len (rcv_sacks))
1130 blk = &rcv_sacks[blk_index];
1131 if (
seq_leq (blk->start, hole->start))
1134 if (
seq_geq (blk->end, hole->end))
1139 if (blk->end == ack)
1141 u32 sacked = next_hole ? next_hole->start : sb->high_sacked;
1144 sb->last_bytes_delivered += ack - hole->end;
1145 sb->is_reneging = 1;
1149 sb->last_bytes_delivered += sacked - hole->end;
1150 sb->is_reneging = 0;
1161 if (
seq_gt (blk->end, hole->start))
1165 hole->start = blk->end;
1173 if (
seq_lt (blk->end, hole->end))
1180 hole->end = blk->start;
1188 else if (
seq_lt (blk->start, hole->end))
1192 hole->end = blk->start;
1202 || sb->sacked_bytes <= tc->snd_nxt -
seq_max (tc->snd_una, ack));
1203 ASSERT (sb->last_sacked_bytes + sb->lost_bytes <= tc->snd_nxt
1206 || sb->is_reneging || sb->holes[sb->head].start == ack);
1207 ASSERT (sb->last_lost_bytes <= sb->lost_bytes);
1208 ASSERT ((ack - tc->snd_una) + sb->last_sacked_bytes
1209 - sb->last_bytes_delivered >= sb->rxt_sacked);
1210 ASSERT ((ack - tc->snd_una) >= tc->sack_sb.last_bytes_delivered
1211 || (tc->flags & TCP_CONN_FINSNT));
1213 TCP_EVT (TCP_EVT_CC_SCOREBOARD, tc);
1228 if (
seq_lt (tc->snd_wl1, seq)
1229 || (tc->snd_wl1 == seq &&
seq_leq (tc->snd_wl2, ack)))
1231 tc->snd_wnd = snd_wnd;
1234 TCP_EVT (TCP_EVT_SND_WND, tc);
1265 tc->snd_congestion = tc->snd_nxt;
1266 tc->cwnd_acc_bytes = 0;
1267 tc->snd_rxt_bytes = 0;
1268 tc->rxt_delivered = 0;
1269 tc->prr_delivered = 0;
1270 tc->prr_start = tc->snd_una;
1271 tc->prev_ssthresh = tc->ssthresh;
1272 tc->prev_cwnd = tc->cwnd;
1281 tc->cwnd += 3 * tc->snd_mss;
1283 tc->fr_occurences += 1;
1284 TCP_EVT (TCP_EVT_CC_EVT, tc, 4);
1290 tc->cwnd = tc->prev_cwnd;
1291 tc->ssthresh = tc->prev_ssthresh;
1293 ASSERT (tc->rto_boff == 0);
1294 TCP_EVT (TCP_EVT_CC_EVT, tc, 5);
1315 return (tc->sack_sb.lost_bytes
1317 < tc->sack_sb.sacked_bytes));
1335 if (
seq_leq (tc->snd_una, tc->snd_congestion)
1336 && ((!(tc->cwnd > tc->snd_mss
1337 && tc->bytes_acked <= 4 * tc->snd_mss))
1338 || (tc->rcv_opts.tsecr != tc->tsecr_last_ack)))
1340 tc->rcv_dupacks = 0;
1363 tc->rcv_dupacks = 0;
1367 if (tc->sack_sb.sacked_bytes)
1369 tc->snd_congestion = tc->snd_nxt;
1374 tc->rxt_delivered = 0;
1375 tc->snd_rxt_bytes = 0;
1377 tc->prr_delivered = 0;
1379 tc->flags &= ~TCP_CONN_RXT_PENDING;
1382 if (hole && hole->start == tc->snd_una && hole->end == tc->snd_nxt)
1391 TCP_EVT (TCP_EVT_CC_EVT, tc, 3);
1393 ASSERT (tc->rto_boff == 0);
1408 tc->rcv_dupacks = 0;
1415 (
seq_leq (tc->snd_congestion, tc->snd_una - tc->bytes_acked)
1416 &&
seq_gt (tc->snd_congestion, tc->snd_una)))
1417 tc->snd_congestion = tc->snd_una - 1;
1441 TCP_EVT (TCP_EVT_DUPACK_RCVD, tc, 1);
1468 if (!tc->bytes_acked && tc->sack_sb.rxt_sacked)
1471 tc->rxt_delivered += tc->sack_sb.rxt_sacked;
1472 tc->prr_delivered += tc->bytes_acked + tc->sack_sb.last_sacked_bytes
1473 - tc->sack_sb.last_bytes_delivered;
1481 tc->rcv_dupacks += 1;
1482 TCP_EVT (TCP_EVT_DUPACK_RCVD, tc, 1);
1484 tc->rxt_delivered =
clib_min (tc->rxt_delivered + tc->bytes_acked,
1487 tc->prr_delivered +=
clib_min (tc->snd_mss,
1488 tc->snd_nxt - tc->snd_una);
1490 tc->prr_delivered += tc->bytes_acked -
clib_min (tc->bytes_acked,
1504 if (
seq_geq (tc->snd_una, tc->snd_congestion))
1509 tc->tsecr_last_ack = tc->rcv_opts.tsecr;
1522 if (!tc->bytes_acked)
1530 tc->rcv_dupacks = 0;
1547 tc->bytes_acked = 0;
1549 if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE)
1562 return ((
vnet_buffer (b)->tcp.ack_number == prev_snd_una)
1563 &&
seq_gt (tc->snd_nxt, tc->snd_una)
1565 && (prev_snd_wnd == tc->snd_wnd));
1573 u32 prev_snd_wnd,
u32 prev_snd_una,
u8 * is_dack)
1577 *is_dack = tc->sack_sb.last_sacked_bytes
1590 u32 prev_snd_wnd, prev_snd_una;
1594 TCP_EVT (TCP_EVT_CC_STAT, tc);
1608 tc->errors.above_ack_wnd += 1;
1609 *error = TCP_ERROR_ACK_FUTURE;
1617 tc->errors.below_ack_wnd += 1;
1618 *error = TCP_ERROR_ACK_OLD;
1639 prev_snd_wnd = tc->snd_wnd;
1640 prev_snd_una = tc->snd_una;
1643 clib_net_to_host_u16 (th->window) << tc->snd_wscale);
1644 tc->bytes_acked =
vnet_buffer (b)->tcp.ack_number - tc->snd_una;
1648 if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE)
1653 if (tc->bytes_acked)
1656 TCP_EVT (TCP_EVT_ACK_RCVD, tc);
1665 tc->dupacks_in += is_dack;
1668 *error = TCP_ERROR_ACK_OK;
1671 *error = TCP_ERROR_ACK_DUP;
1681 *error = TCP_ERROR_ACK_OK;
1698 u32 thread_index, *pending_disconnects;
1707 for (i = 0; i <
vec_len (pending_disconnects); i++)
1726 tc->flags |= TCP_CONN_FINRCVD;
1733 TCP_EVT (TCP_EVT_FIN_RCVD, tc);
1734 *error = TCP_ERROR_FIN_RCVD;
1737 #ifndef CLIB_MARCH_VARIANT 1742 for (i = 1; i <
vec_len (sacks); i++)
1744 if (sacks[i - 1].end == sacks[i].start)
1769 if (
seq_lt (tc->rcv_nxt, start))
1772 block->start = start;
1777 for (i = 0; i <
vec_len (tc->snd_sacks); i++)
1780 if (
seq_leq (tc->snd_sacks[i].start, tc->rcv_nxt))
1784 if (block && (
seq_geq (tc->snd_sacks[i].end, new_list[0].start)
1785 &&
seq_leq (tc->snd_sacks[i].start, new_list[0].end)))
1787 if (
seq_lt (tc->snd_sacks[i].start, new_list[0].start))
1788 new_list[0].start = tc->snd_sacks[i].start;
1789 if (
seq_lt (new_list[0].end, tc->snd_sacks[i].end))
1790 new_list[0].end = tc->snd_sacks[i].end;
1796 vec_add1 (new_list, tc->snd_sacks[i]);
1803 tc->snd_sacks_fl = tc->snd_sacks;
1804 tc->snd_sacks = new_list;
1814 for (
i = 0;
i <
vec_len (tc->snd_sacks);
i++)
1815 bytes += tc->snd_sacks[
i].end - tc->snd_sacks[
i].start;
1825 int written, error = TCP_ERROR_ENQUEUED;
1831 tc->bytes_in += written;
1833 TCP_EVT (TCP_EVT_INPUT, tc, 0, data_len, written);
1838 tc->rcv_nxt += written;
1841 else if (written > data_len)
1843 tc->rcv_nxt += written;
1844 TCP_EVT (TCP_EVT_CC_INPUT, tc, data_len, written);
1846 else if (written > 0)
1849 tc->rcv_nxt += written;
1850 error = TCP_ERROR_PARTIALLY_ENQUEUED;
1854 return TCP_ERROR_FIFO_FULL;
1887 TCP_EVT (TCP_EVT_INPUT, tc, 1, data_len, 0);
1888 return TCP_ERROR_FIFO_FULL;
1891 TCP_EVT (TCP_EVT_INPUT, tc, 1, data_len, data_len);
1892 tc->bytes_in += data_len;
1900 s0 =
session_get (tc->c_s_index, tc->c_thread_index);
1908 start = tc->rcv_nxt +
offset;
1912 TCP_EVT (TCP_EVT_CC_SACKS, tc);
1916 return TCP_ERROR_ENQUEUED_OOO;
1931 || (tc->flags & TCP_CONN_SNDACK) != 0
1948 if (!(b->
flags & VLIB_BUFFER_NEXT_PRESENT))
1955 n_bytes_to_drop -= discard;
1957 while (n_bytes_to_drop);
1958 if (n_bytes_to_drop > first)
1976 u32 error, n_bytes_to_drop, n_data_bytes;
1981 tc->data_segs_in += 1;
1995 tc->errors.below_data_wnd++;
1996 error = TCP_ERROR_SEGMENT_OLD;
2002 n_bytes_to_drop = tc->rcv_nxt -
vnet_buffer (b)->tcp.seq_number;
2003 n_data_bytes -= n_bytes_to_drop;
2007 error = TCP_ERROR_SEGMENT_OLD;
2018 tc->rcv_las + tc->rcv_wnd);
2069 s =
format (s,
"%d -> %d (%U)",
2070 clib_net_to_host_u16 (t->
tcp_header.dst_port),
2113 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
2137 #define tcp_maybe_inc_counter(node_id, err, count) \ 2139 if (next0 != tcp_next_drop (is_ip4)) \ 2140 tcp_node_inc_counter_i (vm, tcp4_##node_id##_node.index, \ 2141 tcp6_##node_id##_node.index, is_ip4, err, \ 2144 #define tcp_inc_counter(node_id, err, count) \ 2145 tcp_node_inc_counter_i (vm, tcp4_##node_id##_node.index, \ 2146 tcp6_##node_id##_node.index, is_ip4, \ 2148 #define tcp_maybe_inc_err_counter(cnts, err) \ 2150 cnts[err] += (next0 != tcp_next_drop (is_ip4)); \ 2152 #define tcp_inc_err_counter(cnts, err, val) \ 2156 #define tcp_store_err_counters(node_id, cnts) \ 2159 for (i = 0; i < TCP_N_ERROR; i++) \ 2161 tcp_inc_counter(node_id, i, cnts[i]); \ 2171 u32 n_left_from, *from, *first_buffer;
2180 while (n_left_from > 0)
2182 u32 bi0, error0 = TCP_ERROR_ACK_OK;
2187 if (n_left_from > 1)
2205 error0 = TCP_ERROR_INVALID_CONNECTION;
2240 err_counters[TCP_ERROR_MSG_QUEUE_FULL] = errors;
2266 .name =
"tcp4-established",
2268 .vector_size =
sizeof (
u32),
2274 #define _(s,n) [TCP_ESTABLISHED_NEXT_##s] = n, 2285 .name =
"tcp6-established",
2287 .vector_size =
sizeof (
u32),
2293 #define _(s,n) [TCP_ESTABLISHED_NEXT_##s] = n, 2313 if (tc->c_lcl_port == 0 && tc->state == TCP_STATE_LISTEN)
2316 u8 is_ip_valid = 0, val_l, val_r;
2318 if (tc->connection.is_ip4)
2323 &tc->connection.lcl_ip.ip4);
2324 val_l = val_l ||
ip_is_zero (&tc->connection.lcl_ip, 1);
2326 &tc->connection.rmt_ip.ip4);
2327 val_r = val_r || tc->state == TCP_STATE_LISTEN;
2328 is_ip_valid = val_l && val_r;
2335 &tc->connection.lcl_ip.ip6);
2336 val_l = val_l ||
ip_is_zero (&tc->connection.lcl_ip, 0);
2338 &tc->connection.rmt_ip.ip6);
2339 val_r = val_r || tc->state == TCP_STATE_LISTEN;
2340 is_ip_valid = val_l && val_r;
2343 u8 is_valid = (tc->c_lcl_port == hdr->dst_port
2344 && (tc->state == TCP_STATE_LISTEN
2345 || tc->c_rmt_port == hdr->src_port) && is_ip_valid);
2351 tc->c_proto, tc->c_is_ip4);
2355 if (tmp->lcl_port == hdr->dst_port
2356 && tmp->rmt_port == hdr->src_port)
2358 TCP_DBG (
"half-open is valid!");
2387 TRANSPORT_PROTO_TCP,
2388 thread_index, &is_filtered);
2402 TRANSPORT_PROTO_TCP,
2403 thread_index, &is_filtered);
2417 u32 sw_if_idx, lb_idx;
2441 tc->cfg_flags |= TCP_CFG_F_TSO;
2448 u32 n_left_from, *from, *first_buffer, errors = 0;
2455 while (n_left_from > 0)
2457 u32 bi0, ack0, seq0, error0 = TCP_ERROR_NONE;
2472 error0 = TCP_ERROR_INVALID_CONNECTION;
2482 my_thread_index, is_ip4));
2483 error0 = TCP_ERROR_SPURIOUS_SYN_ACK;
2494 || tcp0->src_port != tc0->c_rmt_port))
2496 error0 = TCP_ERROR_INVALID_CONNECTION;
2503 error0 = TCP_ERROR_SEGMENT_INVALID;
2524 if (
seq_leq (ack0, tc0->iss) ||
seq_gt (ack0, tc0->snd_nxt))
2528 error0 = TCP_ERROR_RCV_WND;
2533 if (
seq_gt (tc0->snd_una, ack0))
2535 error0 = TCP_ERROR_ACK_INVALID;
2550 error0 = TCP_ERROR_RST_RCVD;
2565 error0 = TCP_ERROR_SEGMENT_INVALID;
2572 error0 = TCP_ERROR_OPTIONS;
2580 new_tc0->irs = seq0;
2587 tc0->flags |= TCP_CONN_HALF_OPEN_DONE;
2591 new_tc0->tsval_recent = new_tc0->rcv_opts.tsval;
2596 new_tc0->snd_wscale = new_tc0->rcv_opts.wscale;
2598 new_tc0->rcv_wscale = 0;
2600 new_tc0->snd_wnd = clib_net_to_host_u16 (tcp0->window)
2601 << new_tc0->snd_wscale;
2602 new_tc0->snd_wl1 = seq0;
2603 new_tc0->snd_wl2 = ack0;
2613 new_tc0->snd_una = ack0;
2614 new_tc0->state = TCP_STATE_ESTABLISHED;
2617 new_tc0->rcv_las = new_tc0->rcv_nxt;
2625 error0 = TCP_ERROR_CREATE_SESSION_FAIL;
2629 new_tc0->tx_fifo_size =
2633 TCP_EVT (TCP_EVT_SYNACK_RCVD, new_tc0);
2634 error0 = TCP_ERROR_SYN_ACKS_RCVD;
2639 new_tc0->state = TCP_STATE_SYN_RCVD;
2646 TCP_EVT (TCP_EVT_RST_SENT, tc0);
2647 error0 = TCP_ERROR_CREATE_SESSION_FAIL;
2651 new_tc0->tx_fifo_size =
2653 new_tc0->rtt_ts = 0;
2656 error0 = TCP_ERROR_SYNS_RCVD;
2660 if (!(new_tc0->cfg_flags & TCP_CFG_F_NO_TSO))
2668 if (error0 == TCP_ERROR_ACK_OK)
2669 error0 = TCP_ERROR_SYN_ACKS_RCVD;
2715 .name =
"tcp4-syn-sent",
2717 .vector_size =
sizeof (
u32),
2723 #define _(s,n) [TCP_SYN_SENT_NEXT_##s] = n, 2734 .name =
"tcp6-syn-sent",
2736 .vector_size =
sizeof (
u32),
2742 #define _(s,n) [TCP_SYN_SENT_NEXT_##s] = n, 2760 u32 n_left_from, *from, max_dequeue;
2765 while (n_left_from > 0)
2767 u32 bi0, error0 = TCP_ERROR_NONE;
2782 error0 = TCP_ERROR_INVALID_CONNECTION;
2796 if (tmp->state != tc0->state)
2798 if (tc0->state != TCP_STATE_CLOSED)
2810 error0 = TCP_ERROR_CONNECTION_CLOSED;
2825 case TCP_STATE_SYN_RCVD:
2828 if (tc0->rcv_nxt !=
vnet_buffer (b0)->tcp.seq_number || is_fin0)
2831 error0 = TCP_ERROR_SEGMENT_INVALID;
2852 tc0->state = TCP_STATE_ESTABLISHED;
2853 TCP_EVT (TCP_EVT_STATE_CHANGE, tc0);
2855 if (!(tc0->cfg_flags & TCP_CFG_F_NO_TSO))
2860 tc0->snd_wnd = clib_net_to_host_u16 (tcp0->window)
2861 << tc0->rcv_opts.wscale;
2869 error0 = TCP_ERROR_MSG_QUEUE_FULL;
2873 error0 = TCP_ERROR_ACK_OK;
2875 case TCP_STATE_ESTABLISHED:
2882 case TCP_STATE_FIN_WAIT_1:
2890 if (tc0->flags & TCP_CONN_FINPNDG)
2894 if (max_dequeue <= tc0->burst_acked)
2897 else if ((tc0->flags & TCP_CONN_FINRCVD) && tc0->bytes_acked)
2902 else if (tc0->snd_una == tc0->snd_nxt)
2910 if (tc0->flags & TCP_CONN_FINRCVD)
2925 if (tc0->burst_acked > 1)
2927 tc0->burst_acked - 1);
2928 tc0->burst_acked = 0;
2931 case TCP_STATE_FIN_WAIT_2:
2937 tc0->burst_acked = 0;
2939 case TCP_STATE_CLOSE_WAIT:
2944 if (!(tc0->flags & TCP_CONN_FINPNDG))
2949 if (max_dequeue > tc0->burst_acked)
2957 case TCP_STATE_CLOSING:
2964 if (tc0->snd_una != tc0->snd_nxt)
2974 case TCP_STATE_LAST_ACK:
2983 if (is_fin0 && tc0->snd_una != tc0->snd_nxt)
3001 case TCP_STATE_TIME_WAIT:
3026 case TCP_STATE_ESTABLISHED:
3027 case TCP_STATE_FIN_WAIT_1:
3028 case TCP_STATE_FIN_WAIT_2:
3032 case TCP_STATE_CLOSE_WAIT:
3033 case TCP_STATE_CLOSING:
3034 case TCP_STATE_LAST_ACK:
3035 case TCP_STATE_TIME_WAIT:
3045 TCP_EVT (TCP_EVT_FIN_RCVD, tc0);
3049 case TCP_STATE_ESTABLISHED:
3057 case TCP_STATE_SYN_RCVD:
3067 case TCP_STATE_CLOSE_WAIT:
3068 case TCP_STATE_CLOSING:
3069 case TCP_STATE_LAST_ACK:
3072 case TCP_STATE_FIN_WAIT_1:
3075 if (tc0->flags & TCP_CONN_FINPNDG)
3080 tc0->flags |= TCP_CONN_FINRCVD;
3093 case TCP_STATE_FIN_WAIT_2:
3102 case TCP_STATE_TIME_WAIT:
3109 error0 = TCP_ERROR_FIN_RCVD;
3148 .name =
"tcp4-rcv-process",
3150 .vector_size =
sizeof (
u32),
3156 #define _(s,n) [TCP_RCV_PROCESS_NEXT_##s] = n, 3167 .name =
"tcp6-rcv-process",
3169 .vector_size =
sizeof (
u32),
3175 #define _(s,n) [TCP_RCV_PROCESS_NEXT_##s] = n, 3190 u32 n_left_from, *from, n_syns = 0, *first_buffer;
3196 while (n_left_from > 0)
3206 u32 error0 = TCP_ERROR_NONE;
3248 error0 = TCP_ERROR_CREATE_EXISTS;
3254 child0->c_lcl_port = th0->dst_port;
3255 child0->c_rmt_port = th0->src_port;
3256 child0->c_is_ip4 = is_ip4;
3257 child0->state = TCP_STATE_SYN_RCVD;
3258 child0->c_fib_index = lc0->c_fib_index;
3259 child0->cc_algo = lc0->cc_algo;
3276 error0 = TCP_ERROR_OPTIONS;
3282 child0->rcv_nxt =
vnet_buffer (b0)->tcp.seq_number + 1;
3283 child0->rcv_las = child0->rcv_nxt;
3290 child0->tsval_recent = child0->rcv_opts.tsval;
3295 child0->snd_wscale = child0->rcv_opts.wscale;
3297 child0->snd_wnd = clib_net_to_host_u16 (th0->window)
3298 << child0->snd_wscale;
3299 child0->snd_wl1 =
vnet_buffer (b0)->tcp.seq_number;
3300 child0->snd_wl2 =
vnet_buffer (b0)->tcp.ack_number;
3306 lc0->c_thread_index, 0 ))
3309 error0 = TCP_ERROR_CREATE_SESSION_FAIL;
3313 TCP_EVT (TCP_EVT_SYN_RCVD, child0, 1);
3327 n_syns += (error0 == TCP_ERROR_NONE);
3351 .name =
"tcp4-listen",
3353 .vector_size =
sizeof (
u32),
3359 #define _(s,n) [TCP_LISTEN_NEXT_##s] = n, 3370 .name =
"tcp6-listen",
3372 .vector_size =
sizeof (
u32),
3378 #define _(s,n) [TCP_LISTEN_NEXT_##s] = n, 3386 typedef enum _tcp_input_next
3398 #define foreach_tcp4_input_next \ 3399 _ (DROP, "ip4-drop") \ 3400 _ (LISTEN, "tcp4-listen") \ 3401 _ (RCV_PROCESS, "tcp4-rcv-process") \ 3402 _ (SYN_SENT, "tcp4-syn-sent") \ 3403 _ (ESTABLISHED, "tcp4-established") \ 3404 _ (RESET, "tcp4-reset") \ 3405 _ (PUNT, "ip4-punt") 3407 #define foreach_tcp6_input_next \ 3408 _ (DROP, "ip6-drop") \ 3409 _ (LISTEN, "tcp6-listen") \ 3410 _ (RCV_PROCESS, "tcp6-rcv-process") \ 3411 _ (SYN_SENT, "tcp6-syn-sent") \ 3412 _ (ESTABLISHED, "tcp6-established") \ 3413 _ (RESET, "tcp6-reset") \ 3414 _ (PUNT, "ip6-punt") 3416 #define filter_flags (TCP_FLAG_SYN|TCP_FLAG_ACK|TCP_FLAG_RST|TCP_FLAG_FIN) 3427 for (i = 0; i < n_bufs; i++)
3429 if (bs[i]->
flags & VLIB_BUFFER_IS_TRACED)
3443 if (*error == TCP_ERROR_FILTERED || *error == TCP_ERROR_WRONG_THREAD)
3447 else if ((is_ip4 && tm->punt_unknown4) || (!is_ip4 && tm->punt_unknown6))
3450 *error = TCP_ERROR_PUNT;
3455 *error = TCP_ERROR_NO_LISTENER;
3461 u8 is_ip4,
u8 is_nolookup)
3464 int n_advance_bytes, n_data_bytes;
3475 *error = TCP_ERROR_LENGTH;
3481 n_data_bytes = clib_net_to_host_u16 (ip4->
length) - n_advance_bytes;
3486 *error = TCP_ERROR_LENGTH;
3494 TRANSPORT_PROTO_TCP, thread_index,
3502 *error = TCP_ERROR_LENGTH;
3510 n_advance_bytes +=
sizeof (ip6[0]);
3514 *error = TCP_ERROR_LENGTH;
3530 tcp->dst_port, tcp->src_port,
3531 TRANSPORT_PROTO_TCP,
3532 thread_index, &result);
3539 tcp.connection_index,
3542 vnet_buffer (b)->tcp.seq_number = clib_net_to_host_u32 (tcp->seq_number);
3543 vnet_buffer (b)->tcp.ack_number = clib_net_to_host_u32 (tcp->ack_number);
3544 vnet_buffer (b)->tcp.data_offset = n_advance_bytes;
3550 *error = result ? TCP_ERROR_NONE + result : *error;
3566 *next = tm->dispatch_table[tc->state][
flags].next;
3567 error = tm->dispatch_table[tc->state][
flags].error;
3577 if (error == TCP_ERROR_DISPATCH)
3578 clib_warning (
"tcp conn %u disp error state %U flags %U",
3604 while (n_left_from >= 4)
3606 u32 error0 = TCP_ERROR_NO_LISTENER, error1 = TCP_ERROR_NO_LISTENER;
3629 vnet_buffer (b[0])->tcp.connection_index = tc0->c_c_index;
3630 vnet_buffer (b[1])->tcp.connection_index = tc1->c_c_index;
3640 vnet_buffer (b[0])->tcp.connection_index = tc0->c_c_index;
3652 vnet_buffer (b[1])->tcp.connection_index = tc1->c_c_index;
3666 while (n_left_from > 0)
3669 u32 error0 = TCP_ERROR_NO_LISTENER;
3671 if (n_left_from > 1)
3683 vnet_buffer (b[0])->tcp.connection_index = tc0->c_c_index;
3723 .name =
"tcp4-input-nolookup",
3725 .vector_size =
sizeof (
u32),
3731 #define _(s,n) [TCP_INPUT_NEXT_##s] = n, 3743 .name =
"tcp6-input-nolookup",
3745 .vector_size =
sizeof (
u32),
3751 #define _(s,n) [TCP_INPUT_NEXT_##s] = n, 3777 .name =
"tcp4-input",
3779 .vector_size =
sizeof (
u32),
3785 #define _(s,n) [TCP_INPUT_NEXT_##s] = n, 3797 .name =
"tcp6-input",
3799 .vector_size =
sizeof (
u32),
3805 #define _(s,n) [TCP_INPUT_NEXT_##s] = n, 3814 #ifndef CLIB_MARCH_VARIANT 3819 for (i = 0; i <
ARRAY_LEN (tm->dispatch_table); i++)
3820 for (j = 0; j <
ARRAY_LEN (tm->dispatch_table[i]); j++)
3823 tm->dispatch_table[
i][j].error = TCP_ERROR_DISPATCH;
3826 #define _(t,f,n,e) \ 3828 tm->dispatch_table[TCP_STATE_##t][f].next = (n); \ 3829 tm->dispatch_table[TCP_STATE_##t][f].error = (e); \ 3838 TCP_ERROR_ACK_INVALID);
3840 TCP_ERROR_SEGMENT_INVALID);
3842 TCP_ERROR_SEGMENT_INVALID);
3844 TCP_ERROR_INVALID_CONNECTION);
3847 TCP_ERROR_SEGMENT_INVALID);
3849 TCP_ERROR_SEGMENT_INVALID);
3851 TCP_ERROR_SEGMENT_INVALID);
3853 TCP_ERROR_SEGMENT_INVALID);
3855 TCP_ERROR_SEGMENT_INVALID);
3857 TCP_ERROR_SEGMENT_INVALID);
4037 TCP_ERROR_CONNECTION_CLOSED);
4041 TCP_ERROR_CONNECTION_CLOSED);
#define tcp_in_cong_recovery(tc)
u16 lb_n_buckets
number of buckets in the load-balance.
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
void tcp_program_retransmit(tcp_connection_t *tc)
u32 * pending_disconnects
vector of pending disconnect notifications
static u32 ip6_fib_table_fwding_lookup(u32 fib_index, const ip6_address_t *dst)
#define tcp_in_recovery(tc)
static f64 tcp_time_now_us(u32 thread_index)
#define TCP_OPTION_LEN_SACK_PERMITTED
#define seq_leq(_s1, _s2)
struct _sack_block sack_block_t
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
#define timestamp_leq(_t1, _t2)
#define tcp_node_index(node_id, is_ip4)
transport_connection_t * session_lookup_connection_wt6(u32 fib_index, ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 thread_index, u8 *result)
Lookup connection with ip6 and transport layer information.
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define tcp_opts_tstamp(_to)
#define clib_memcpy_fast(a, b, c)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
struct _sack_scoreboard sack_scoreboard_t
static tcp_connection_t * tcp_half_open_connection_get(u32 conn_index)
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
struct _tcp_main tcp_main_t
void tcp_connection_timers_reset(tcp_connection_t *tc)
Stop all connection timers.
u16 current_length
Nbytes between current data and the end of this buffer.
int session_main_flush_enqueue_events(u8 transport_proto, u32 thread_index)
Flushes queue of sessions that are to be notified of new data enqueued events.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define tcp_recovery_off(tc)
u32 dpo_get_urpf(const dpo_id_t *dpo)
Get a uRPF interface for the DPO.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define THZ
TCP tick frequency.
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
struct _tcp_connection tcp_connection_t
static session_t * session_get(u32 si, u32 thread_index)
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)
tcp_connection_t tcp_connection
static tcp_connection_t * tcp_get_connection_from_transport(transport_connection_t *tconn)
#define VLIB_NODE_FN(node)
#define tcp_disconnect_pending_on(tc)
int session_enqueue_stream_connection(transport_connection_t *tc, vlib_buffer_t *b, u32 offset, u8 queue_event, u8 is_in_order)
u64 session_lookup_half_open_handle(transport_connection_t *tc)
vlib_error_t * errors
Vector of errors for this node.
format_function_t format_tcp_flags
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
u8 n_sack_blocks
Number of SACKs blocks.
struct _tcp_header tcp_header_t
int tcp_half_open_connection_cleanup(tcp_connection_t *tc)
Try to cleanup half-open connection.
u32 * pending_deq_acked
vector of pending ack dequeues
struct _sack_scoreboard_hole sack_scoreboard_hole_t
u8 wscale
Option flags, see above.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define tcp_fastrecovery_on(tc)
void session_transport_closing_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
#define TCP_TICK
TCP tick period (s)
static void tcp_connection_set_state(tcp_connection_t *tc, tcp_state_t state)
void tcp_init_snd_vars(tcp_connection_t *tc)
Initialize connection send variables.
vl_api_interface_index_t sw_if_index
u8 * format_tcp_connection_id(u8 *s, va_list *args)
#define VLIB_INIT_FUNCTION(x)
#define TCP_OPTION_LEN_SACK_BLOCK
static u32 tcp_available_output_snd_space(const tcp_connection_t *tc)
transport_connection_t * session_lookup_connection_wt4(u32 fib_index, ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 thread_index, u8 *result)
Lookup connection with ip4 and transport layer information.
static tcp_header_t * tcp_buffer_hdr(vlib_buffer_t *b)
vnet_hw_interface_flags_t flags
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
enum _tcp_state tcp_state_t
#define TCP_ALWAYS_ACK
On/off delayed acks.
vhost_vring_state_t state
static u32 ooo_segment_length(svm_fifo_t *f, ooo_segment_t *s)
static void * ip4_next_header(ip4_header_t *i)
static u32 tcp_time_now(void)
sack_block_t * sacks
SACK blocks.
#define vec_end(v)
End (last data address) of vector.
#define vlib_call_init_function(vm, x)
#define TCP_MAX_SACK_BLOCKS
Max number of SACK blocks stored.
#define tcp_validate_txf_size(_tc, _a)
#define timestamp_lt(_t1, _t2)
static void tcp_timer_set(tcp_connection_t *tc, u8 timer_id, u32 interval)
#define TCP_OPTION_LEN_WINDOW_SCALE
static void svm_fifo_newest_ooo_segment_reset(svm_fifo_t *f)
static heap_elt_t * first(heap_header_t *h)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
vlib_main_t * vm
convenience pointer to this thread's vlib main
#define TCP_INVALID_SACK_HOLE_INDEX
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void tcp_send_ack(tcp_connection_t *tc)
void tcp_connection_tx_pacer_reset(tcp_connection_t *tc, u32 window, u32 start_bucket)
int tcp_fastrecovery_prr_snd_space(tcp_connection_t *tc)
Estimate send space using proportional rate reduction (RFC6937)
tcp_connection_t * tcp_connection_alloc_w_base(u8 thread_index, tcp_connection_t *base)
static const dpo_id_t * load_balance_get_bucket_i(const load_balance_t *lb, u32 bucket)
tcp_connection_t * tcp_connection_alloc(u8 thread_index)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
void tcp_connection_tx_pacer_update(tcp_connection_t *tc)
#define pool_put(P, E)
Free an object E in pool P.
#define TCP_TIMER_HANDLE_INVALID
int ip6_address_compare(ip6_address_t *a1, ip6_address_t *a2)
static void tcp_cc_rcv_cong_ack(tcp_connection_t *tc, tcp_cc_ack_t ack_type, tcp_rate_sample_t *rs)
#define vec_del1(v, i)
Delete the element at index I.
#define TCP_OPTION_LEN_TIMESTAMP
static ooo_segment_t * svm_fifo_newest_ooo_segment(svm_fifo_t *f)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define TCP_DBG(_fmt, _args...)
#define TCP_MAX_WND_SCALE
void tcp_connection_free(tcp_connection_t *tc)
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
int ip4_address_compare(ip4_address_t *a1, ip4_address_t *a2)
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_program_dupack(tcp_connection_t *tc)
void tcp_send_reset(tcp_connection_t *tc)
Build and set reset packet for connection.
#define TCP_DUPACK_THRESHOLD
static u32 tcp_tstamp(tcp_connection_t *tc)
Generate timestamp for tcp connection.
format_function_t format_tcp_state
static void tcp_cc_undo_recovery(tcp_connection_t *tc)
#define clib_warning(format, args...)
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
Don't register connection in lookup Does not apply to local apps and transports using the network lay...
struct _transport_connection transport_connection_t
f64 rtt_time
RTT for sample.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
u16 mss
Maximum segment size advertised.
static void * ip6_next_header(ip6_header_t *i)
static u32 transport_max_tx_dequeue(transport_connection_t *tc)
void tcp_send_synack(tcp_connection_t *tc)
static void tcp_timer_update(tcp_connection_t *tc, u8 timer_id, u32 interval)
#define TCP_PAWS_IDLE
24 days
#define tcp_fastrecovery_first_on(tc)
static load_balance_t * load_balance_get(index_t lbi)
#define seq_geq(_s1, _s2)
void tcp_bt_sample_delivery_rate(tcp_connection_t *tc, tcp_rate_sample_t *rs)
Generate a delivery rate sample from recently acked bytes.
static index_t ip4_fib_forwarding_lookup(u32 fib_index, const ip4_address_t *addr)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static uword ip6_address_is_link_local_unicast(const ip6_address_t *a)
#define tcp_fastrecovery_first_off(tc)
int session_stream_accept_notify(transport_connection_t *tc)
static vlib_main_t * vlib_get_main(void)
static u32 tcp_time_now_w_thread(u32 thread_index)
static clib_error_t * tcp_init(vlib_main_t *vm)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define vec_elt(v, i)
Get vector value at index i.
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
#define tcp_opts_wscale(_to)
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.
void tcp_connection_reset(tcp_connection_t *tc)
Notify session that connection has been reset.
u32 tsval
Timestamp value.
u32 tsecr
Echoed/reflected time stamp.
void tcp_send_fin(tcp_connection_t *tc)
Send FIN.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 next_buffer
Next buffer for this linked-list of buffers.
static u8 tcp_is_lost_fin(tcp_connection_t *tc)
static void tcp_cc_rcv_ack(tcp_connection_t *tc, tcp_rate_sample_t *rs)
static tcp_worker_ctx_t * tcp_get_worker(u32 thread_index)
void session_transport_closed_notify(transport_connection_t *tc)
Notification from transport that it is closed.
static void tcp_retransmit_timer_update(tcp_connection_t *tc)
VLIB buffer representation.
#define seq_max(_s1, _s2)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
void tcp_connection_init_vars(tcp_connection_t *tc)
Initialize tcp connection variables.
static void tcp_cc_recovered(tcp_connection_t *tc)
#define TCP_OPTION_LEN_MSS
void transport_connection_tx_pacer_reset_bucket(transport_connection_t *tc)
Reset tx pacer bucket.
#define tcp_disconnect_pending(tc)
static u32 ooo_segment_offset_prod(svm_fifo_t *f, ooo_segment_t *s)
struct clib_bihash_value offset
template key/value backing page structure
#define tcp_scoreboard_trace_add(_tc, _ack)
static tcp_connection_t * tcp_connection_get(u32 conn_index, u32 thread_index)
ip4_main_t ip4_main
Global ip4 main structure.
static int tcp_header_bytes(tcp_header_t *t)
int session_stream_connect_notify(transport_connection_t *tc, u8 is_fail)
#define tcp_disconnect_pending_off(tc)
static u32 vlib_num_workers()
void tcp_connection_cleanup(tcp_connection_t *tc)
Cleans up connection state.
u16 flags
Copy of main node flags.
u32 session_tx_fifo_dequeue_drop(transport_connection_t *tc, u32 max_bytes)
void tcp_program_ack(tcp_connection_t *tc)
#define tcp_opts_sack_permitted(_to)
static int ip4_header_bytes(const ip4_header_t *i)
int session_stream_accept(transport_connection_t *tc, u32 listener_index, u32 thread_index, u8 notify)
Accept a stream session.
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.
#define VLIB_NODE_FLAG_TRACE
tcp_bts_flags_t flags
Rate sample flags from bt sample.
#define CLIB_CACHE_LINE_BYTES
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
static void tcp_persist_timer_set(tcp_connection_t *tc)
static tcp_main_t * vnet_get_tcp_main()
#define tcp_fastrecovery_off(tc)
static void tcp_retransmit_timer_reset(tcp_connection_t *tc)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u32 tcp_set_time_now(tcp_worker_ctx_t *wrk)
static u32 transport_tx_fifo_size(transport_connection_t *tc)
static u8 tcp_timer_is_active(tcp_connection_t *tc, tcp_timers_e timer)
transport_connection_t * session_lookup_half_open_connection(u64 handle, u8 proto, u8 is_ip4)
static tcp_connection_t * tcp_listener_get(u32 tli)
static void tcp_cc_congestion(tcp_connection_t *tc)
static void tcp_persist_timer_reset(tcp_connection_t *tc)
#define TCP_EVT(_evt, _args...)
static uword pool_elts(void *v)
Number of active elements in a pool.