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)
585 u32 *pending_deq_acked;
593 for (i = 0; i <
vec_len (pending_deq_acked); i++)
596 tc->flags &= ~TCP_CONN_DEQ_PENDING;
607 if (
seq_leq (tc->psh_seq, tc->snd_una))
608 tc->flags &= ~TCP_CONN_PSH_PENDING;
626 if (!(tc->flags & TCP_CONN_DEQ_PENDING))
629 tc->flags |= TCP_CONN_DEQ_PENDING;
631 tc->burst_acked += tc->bytes_acked;
634 #ifndef CLIB_MARCH_VARIANT 639 return hole - sb->holes;
645 return hole->end - hole->start;
696 next->prev = hole->prev;
700 sb->tail = hole->prev;
706 prev->next = hole->next;
710 sb->head = hole->next;
740 hole->prev = prev_index;
741 hole->next = prev->next;
744 next->prev = hole_index;
746 sb->tail = hole_index;
748 prev->next = hole_index;
752 sb->head = hole_index;
764 if (!has_rxt ||
seq_geq (start, sb->high_rxt))
768 seq_lt (end, sb->high_rxt) ? (end - start) : (sb->high_rxt - start);
775 u32 sacked = 0, blks = 0, old_sacked;
777 old_sacked = sb->sacked_bytes;
779 sb->last_lost_bytes = 0;
781 sb->sacked_bytes = 0;
786 sb->sacked_bytes = sb->high_sacked - ack;
787 sb->last_sacked_bytes = sb->sacked_bytes
788 - (old_sacked - sb->last_bytes_delivered);
792 if (
seq_gt (sb->high_sacked, right->end))
794 sacked = sb->high_sacked - right->end;
807 ASSERT (right->start == ack || sb->is_reneging);
808 sacked += right->start - ack;
813 sacked += right->start - left->end;
822 sb->last_lost_bytes += right->is_lost ? 0 : (right->end - right->start);
827 ASSERT (right->start == ack || sb->is_reneging);
828 sacked += right->start - ack;
831 sacked += right->start - left->end;
835 sb->sacked_bytes = sacked;
836 sb->last_sacked_bytes = sacked - (old_sacked - sb->last_bytes_delivered);
847 u8 have_unsent,
u8 * can_rescue,
u8 * snd_limited)
852 while (hole &&
seq_leq (hole->end, sb->high_rxt) && hole->is_lost)
863 if (hole->is_lost &&
seq_lt (hole->start, sb->high_sacked))
876 else if (
seq_lt (hole->start, sb->high_sacked))
879 if (
seq_leq (hole->end, sb->high_rxt))
898 if (hole &&
seq_lt (sb->high_rxt, hole->start))
899 sb->high_rxt = hole->start;
911 snd_una =
seq_gt (snd_una, hole->start) ? snd_una : hole->start;
912 sb->cur_rxt_hole = sb->head;
914 sb->high_rxt = snd_una;
915 sb->rescue_rxt = snd_una - 1;
936 sb->sacked_bytes = 0;
937 sb->last_sacked_bytes = 0;
938 sb->last_bytes_delivered = 0;
940 sb->last_lost_bytes = 0;
955 last_hole->is_lost = 1;
957 sb->high_sacked = start;
974 return (!hole || (
seq_geq (hole->start, tc->snd_una)
975 &&
seq_lt (hole->end, tc->snd_nxt)));
978 #ifndef CLIB_MARCH_VARIANT 986 u32 blk_index = 0,
i, j;
989 sb->last_sacked_bytes = 0;
990 sb->last_bytes_delivered = 0;
1000 blk = tc->rcv_opts.sacks;
1001 while (blk <
vec_end (tc->rcv_opts.sacks))
1003 if (
seq_lt (blk->start, blk->end)
1004 &&
seq_gt (blk->start, tc->snd_una)
1005 &&
seq_gt (blk->start, ack)
1006 &&
seq_lt (blk->start, tc->snd_nxt)
1007 &&
seq_leq (blk->end, tc->snd_nxt))
1012 vec_del1 (tc->rcv_opts.sacks, blk - tc->rcv_opts.sacks);
1016 if (
seq_gt (ack, tc->snd_una))
1018 vec_add2 (tc->rcv_opts.sacks, blk, 1);
1019 blk->start = tc->snd_una;
1023 if (
vec_len (tc->rcv_opts.sacks) == 0)
1029 rcv_sacks = tc->rcv_opts.sacks;
1031 for (j =
i + 1; j <
vec_len (rcv_sacks); j++)
1032 if (
seq_lt (rcv_sacks[j].start, rcv_sacks[
i].start))
1035 rcv_sacks[
i] = rcv_sacks[j];
1045 if (
seq_leq (tc->snd_nxt, sb->high_sacked))
1048 if (
seq_leq (ack, tc->snd_una))
1052 sb->last_bytes_delivered = ack - tc->snd_una;
1053 sb->sacked_bytes -= sb->last_bytes_delivered;
1054 sb->is_reneging =
seq_lt (ack, sb->high_sacked);
1060 sb->high_sacked, tc->snd_nxt);
1068 tc->snd_una, tc->snd_nxt);
1071 sb->high_sacked = rcv_sacks[
vec_len (rcv_sacks) - 1].end;
1078 if (
seq_gt (tc->snd_nxt, hole->end))
1080 if (
seq_geq (hole->start, sb->high_sacked))
1082 hole->end = tc->snd_nxt;
1085 else if (
seq_lt (sb->high_sacked, tc->snd_nxt))
1094 sb->high_sacked =
seq_max (rcv_sacks[vec_len (rcv_sacks) - 1].
end,
1103 sb->last_bytes_delivered +=
clib_min (hole->start - tc->snd_una,
1105 sb->is_reneging =
seq_lt (ack, hole->start);
1108 while (hole && blk_index < vec_len (rcv_sacks))
1110 blk = &rcv_sacks[blk_index];
1111 if (
seq_leq (blk->start, hole->start))
1114 if (
seq_geq (blk->end, hole->end))
1119 if (blk->end == ack)
1121 u32 sacked = next_hole ? next_hole->start : sb->high_sacked;
1124 sb->last_bytes_delivered += ack - hole->end;
1125 sb->is_reneging = 1;
1129 sb->last_bytes_delivered += sacked - hole->end;
1130 sb->is_reneging = 0;
1141 if (
seq_gt (blk->end, hole->start))
1145 hole->start = blk->end;
1153 if (
seq_lt (blk->end, hole->end))
1160 hole->end = blk->start;
1168 else if (
seq_lt (blk->start, hole->end))
1172 hole->end = blk->start;
1182 || sb->sacked_bytes <= tc->snd_nxt -
seq_max (tc->snd_una, ack));
1183 ASSERT (sb->last_sacked_bytes + sb->lost_bytes <= tc->snd_nxt
1186 || sb->is_reneging || sb->holes[sb->head].start == ack);
1187 ASSERT (sb->last_lost_bytes <= sb->lost_bytes);
1188 ASSERT ((ack - tc->snd_una) + sb->last_sacked_bytes
1189 - sb->last_bytes_delivered >= sb->rxt_sacked);
1190 ASSERT ((ack - tc->snd_una) >= tc->sack_sb.last_bytes_delivered
1191 || (tc->flags & TCP_CONN_FINSNT));
1193 TCP_EVT (TCP_EVT_CC_SCOREBOARD, tc);
1208 if (
seq_lt (tc->snd_wl1, seq)
1209 || (tc->snd_wl1 == seq &&
seq_leq (tc->snd_wl2, ack)))
1211 tc->snd_wnd = snd_wnd;
1214 TCP_EVT (TCP_EVT_SND_WND, tc);
1245 tc->snd_congestion = tc->snd_nxt;
1246 tc->cwnd_acc_bytes = 0;
1247 tc->snd_rxt_bytes = 0;
1248 tc->rxt_delivered = 0;
1249 tc->prr_delivered = 0;
1250 tc->prr_start = tc->snd_una;
1251 tc->prev_ssthresh = tc->ssthresh;
1252 tc->prev_cwnd = tc->cwnd;
1261 tc->cwnd += 3 * tc->snd_mss;
1263 tc->fr_occurences += 1;
1264 TCP_EVT (TCP_EVT_CC_EVT, tc, 4);
1270 tc->cwnd = tc->prev_cwnd;
1271 tc->ssthresh = tc->prev_ssthresh;
1273 ASSERT (tc->rto_boff == 0);
1274 TCP_EVT (TCP_EVT_CC_EVT, tc, 5);
1295 return (tc->sack_sb.lost_bytes
1297 < tc->sack_sb.sacked_bytes));
1315 if (
seq_leq (tc->snd_una, tc->snd_congestion)
1316 && ((!(tc->cwnd > tc->snd_mss
1317 && tc->bytes_acked <= 4 * tc->snd_mss))
1318 || (tc->rcv_opts.tsecr != tc->tsecr_last_ack)))
1320 tc->rcv_dupacks = 0;
1343 tc->rcv_dupacks = 0;
1347 if (tc->sack_sb.sacked_bytes)
1349 tc->snd_congestion = tc->snd_nxt;
1354 tc->rxt_delivered = 0;
1355 tc->snd_rxt_bytes = 0;
1357 tc->prr_delivered = 0;
1359 tc->flags &= ~TCP_CONN_RXT_PENDING;
1362 if (hole && hole->start == tc->snd_una && hole->end == tc->snd_nxt)
1371 TCP_EVT (TCP_EVT_CC_EVT, tc, 3);
1373 ASSERT (tc->rto_boff == 0);
1388 tc->rcv_dupacks = 0;
1395 (
seq_leq (tc->snd_congestion, tc->snd_una - tc->bytes_acked)
1396 &&
seq_gt (tc->snd_congestion, tc->snd_una)))
1397 tc->snd_congestion = tc->snd_una - 1;
1421 TCP_EVT (TCP_EVT_DUPACK_RCVD, tc, 1);
1448 if (!tc->bytes_acked && tc->sack_sb.rxt_sacked)
1451 tc->rxt_delivered += tc->sack_sb.rxt_sacked;
1452 tc->prr_delivered += tc->bytes_acked + tc->sack_sb.last_sacked_bytes
1453 - tc->sack_sb.last_bytes_delivered;
1461 tc->rcv_dupacks += 1;
1462 TCP_EVT (TCP_EVT_DUPACK_RCVD, tc, 1);
1464 tc->rxt_delivered =
clib_max (tc->rxt_delivered + tc->bytes_acked,
1467 tc->prr_delivered +=
clib_min (tc->snd_mss,
1468 tc->snd_nxt - tc->snd_una);
1470 tc->prr_delivered += tc->bytes_acked -
clib_min (tc->bytes_acked,
1484 if (
seq_geq (tc->snd_una, tc->snd_congestion))
1489 tc->tsecr_last_ack = tc->rcv_opts.tsecr;
1502 if (!tc->bytes_acked)
1510 tc->rcv_dupacks = 0;
1527 tc->bytes_acked = 0;
1529 if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE)
1542 return ((
vnet_buffer (b)->tcp.ack_number == prev_snd_una)
1543 &&
seq_gt (tc->snd_nxt, tc->snd_una)
1545 && (prev_snd_wnd == tc->snd_wnd));
1553 u32 prev_snd_wnd,
u32 prev_snd_una,
u8 * is_dack)
1557 *is_dack = tc->sack_sb.last_sacked_bytes
1570 u32 prev_snd_wnd, prev_snd_una;
1574 TCP_EVT (TCP_EVT_CC_STAT, tc);
1588 tc->errors.above_ack_wnd += 1;
1589 *error = TCP_ERROR_ACK_FUTURE;
1597 tc->errors.below_ack_wnd += 1;
1598 *error = TCP_ERROR_ACK_OLD;
1619 prev_snd_wnd = tc->snd_wnd;
1620 prev_snd_una = tc->snd_una;
1623 clib_net_to_host_u16 (th->window) << tc->snd_wscale);
1624 tc->bytes_acked =
vnet_buffer (b)->tcp.ack_number - tc->snd_una;
1628 if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE)
1631 if (tc->bytes_acked)
1637 TCP_EVT (TCP_EVT_ACK_RCVD, tc);
1646 tc->dupacks_in += is_dack;
1649 *error = TCP_ERROR_ACK_OK;
1652 *error = TCP_ERROR_ACK_DUP;
1662 *error = TCP_ERROR_ACK_OK;
1679 u32 thread_index, *pending_disconnects;
1688 for (i = 0; i <
vec_len (pending_disconnects); i++)
1707 tc->flags |= TCP_CONN_FINRCVD;
1714 TCP_EVT (TCP_EVT_FIN_RCVD, tc);
1715 *error = TCP_ERROR_FIN_RCVD;
1718 #ifndef CLIB_MARCH_VARIANT 1723 for (i = 1; i <
vec_len (sacks); i++)
1725 if (sacks[i - 1].
end == sacks[i].start)
1750 if (
seq_lt (tc->rcv_nxt, start))
1753 block->start = start;
1758 for (i = 0; i <
vec_len (tc->snd_sacks); i++)
1761 if (
seq_leq (tc->snd_sacks[i].start, tc->rcv_nxt))
1765 if (block && (
seq_geq (tc->snd_sacks[i].end, new_list[0].start)
1766 &&
seq_leq (tc->snd_sacks[i].start, new_list[0].end)))
1768 if (
seq_lt (tc->snd_sacks[i].start, new_list[0].start))
1769 new_list[0].start = tc->snd_sacks[i].start;
1770 if (
seq_lt (new_list[0].end, tc->snd_sacks[i].end))
1771 new_list[0].end = tc->snd_sacks[i].end;
1777 vec_add1 (new_list, tc->snd_sacks[i]);
1784 tc->snd_sacks_fl = tc->snd_sacks;
1785 tc->snd_sacks = new_list;
1795 for (
i = 0;
i <
vec_len (tc->snd_sacks);
i++)
1796 bytes += tc->snd_sacks[
i].end - tc->snd_sacks[
i].start;
1806 int written, error = TCP_ERROR_ENQUEUED;
1812 tc->bytes_in += written;
1814 TCP_EVT (TCP_EVT_INPUT, tc, 0, data_len, written);
1819 tc->rcv_nxt += written;
1822 else if (written > data_len)
1824 tc->rcv_nxt += written;
1825 TCP_EVT (TCP_EVT_CC_INPUT, tc, data_len, written);
1827 else if (written > 0)
1830 tc->rcv_nxt += written;
1831 error = TCP_ERROR_PARTIALLY_ENQUEUED;
1835 return TCP_ERROR_FIFO_FULL;
1868 TCP_EVT (TCP_EVT_INPUT, tc, 1, data_len, 0);
1869 return TCP_ERROR_FIFO_FULL;
1872 TCP_EVT (TCP_EVT_INPUT, tc, 1, data_len, data_len);
1873 tc->bytes_in += data_len;
1881 s0 =
session_get (tc->c_s_index, tc->c_thread_index);
1889 start = tc->rcv_nxt +
offset;
1893 TCP_EVT (TCP_EVT_CC_SACKS, tc);
1897 return TCP_ERROR_ENQUEUED_OOO;
1912 || (tc->flags & TCP_CONN_SNDACK) != 0
1929 if (!(b->
flags & VLIB_BUFFER_NEXT_PRESENT))
1936 n_bytes_to_drop -= discard;
1938 while (n_bytes_to_drop);
1939 if (n_bytes_to_drop > first)
1957 u32 error, n_bytes_to_drop, n_data_bytes;
1962 tc->data_segs_in += 1;
1976 error = TCP_ERROR_SEGMENT_OLD;
1982 n_bytes_to_drop = tc->rcv_nxt -
vnet_buffer (b)->tcp.seq_number;
1983 n_data_bytes -= n_bytes_to_drop;
1987 error = TCP_ERROR_SEGMENT_OLD;
1998 tc->rcv_las + tc->rcv_wnd);
2049 s =
format (s,
"%d -> %d (%U)",
2050 clib_net_to_host_u16 (t->
tcp_header.dst_port),
2093 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
2117 #define tcp_maybe_inc_counter(node_id, err, count) \ 2119 if (next0 != tcp_next_drop (is_ip4)) \ 2120 tcp_node_inc_counter_i (vm, tcp4_##node_id##_node.index, \ 2121 tcp6_##node_id##_node.index, is_ip4, err, \ 2124 #define tcp_inc_counter(node_id, err, count) \ 2125 tcp_node_inc_counter_i (vm, tcp4_##node_id##_node.index, \ 2126 tcp6_##node_id##_node.index, is_ip4, \ 2128 #define tcp_maybe_inc_err_counter(cnts, err) \ 2130 cnts[err] += (next0 != tcp_next_drop (is_ip4)); \ 2132 #define tcp_inc_err_counter(cnts, err, val) \ 2136 #define tcp_store_err_counters(node_id, cnts) \ 2139 for (i = 0; i < TCP_N_ERROR; i++) \ 2141 tcp_inc_counter(node_id, i, cnts[i]); \ 2151 u32 n_left_from, *from, *first_buffer;
2160 while (n_left_from > 0)
2162 u32 bi0, error0 = TCP_ERROR_ACK_OK;
2167 if (n_left_from > 1)
2185 error0 = TCP_ERROR_INVALID_CONNECTION;
2220 err_counters[TCP_ERROR_MSG_QUEUE_FULL] = errors;
2246 .name =
"tcp4-established",
2248 .vector_size =
sizeof (
u32),
2254 #define _(s,n) [TCP_ESTABLISHED_NEXT_##s] = n, 2265 .name =
"tcp6-established",
2267 .vector_size =
sizeof (
u32),
2273 #define _(s,n) [TCP_ESTABLISHED_NEXT_##s] = n, 2293 if (tc->c_lcl_port == 0 && tc->state == TCP_STATE_LISTEN)
2296 u8 is_ip_valid = 0, val_l, val_r;
2298 if (tc->connection.is_ip4)
2303 &tc->connection.lcl_ip.ip4);
2304 val_l = val_l ||
ip_is_zero (&tc->connection.lcl_ip, 1);
2306 &tc->connection.rmt_ip.ip4);
2307 val_r = val_r || tc->state == TCP_STATE_LISTEN;
2308 is_ip_valid = val_l && val_r;
2315 &tc->connection.lcl_ip.ip6);
2316 val_l = val_l ||
ip_is_zero (&tc->connection.lcl_ip, 0);
2318 &tc->connection.rmt_ip.ip6);
2319 val_r = val_r || tc->state == TCP_STATE_LISTEN;
2320 is_ip_valid = val_l && val_r;
2323 u8 is_valid = (tc->c_lcl_port == hdr->dst_port
2324 && (tc->state == TCP_STATE_LISTEN
2325 || tc->c_rmt_port == hdr->src_port) && is_ip_valid);
2331 tc->c_proto, tc->c_is_ip4);
2335 if (tmp->lcl_port == hdr->dst_port
2336 && tmp->rmt_port == hdr->src_port)
2338 TCP_DBG (
"half-open is valid!");
2367 TRANSPORT_PROTO_TCP,
2368 thread_index, &is_filtered);
2382 TRANSPORT_PROTO_TCP,
2383 thread_index, &is_filtered);
2401 tcp->dst_port, TRANSPORT_PROTO_TCP, 1);
2409 tcp->dst_port, TRANSPORT_PROTO_TCP, 1);
2414 (TRANSPORT_PROTO_TCP,
2427 u32 sw_if_idx, lb_idx;
2451 tc->cfg_flags |= TCP_CFG_F_TSO;
2458 u32 n_left_from, *from, *first_buffer, errors = 0;
2465 while (n_left_from > 0)
2467 u32 bi0, ack0, seq0, error0 = TCP_ERROR_NONE;
2482 error0 = TCP_ERROR_INVALID_CONNECTION;
2492 my_thread_index, is_ip4));
2493 error0 = TCP_ERROR_SPURIOUS_SYN_ACK;
2504 || tcp0->src_port != tc0->c_rmt_port))
2506 error0 = TCP_ERROR_INVALID_CONNECTION;
2513 error0 = TCP_ERROR_SEGMENT_INVALID;
2534 if (
seq_leq (ack0, tc0->iss) ||
seq_gt (ack0, tc0->snd_nxt))
2538 error0 = TCP_ERROR_RCV_WND;
2543 if (
seq_gt (tc0->snd_una, ack0))
2545 error0 = TCP_ERROR_ACK_INVALID;
2560 error0 = TCP_ERROR_RST_RCVD;
2575 error0 = TCP_ERROR_SEGMENT_INVALID;
2582 error0 = TCP_ERROR_OPTIONS;
2590 new_tc0->irs = seq0;
2597 tc0->flags |= TCP_CONN_HALF_OPEN_DONE;
2601 new_tc0->tsval_recent = new_tc0->rcv_opts.tsval;
2606 new_tc0->snd_wscale = new_tc0->rcv_opts.wscale;
2608 new_tc0->rcv_wscale = 0;
2610 new_tc0->snd_wnd = clib_net_to_host_u16 (tcp0->window)
2611 << new_tc0->snd_wscale;
2612 new_tc0->snd_wl1 = seq0;
2613 new_tc0->snd_wl2 = ack0;
2623 new_tc0->snd_una = ack0;
2624 new_tc0->state = TCP_STATE_ESTABLISHED;
2627 new_tc0->rcv_las = new_tc0->rcv_nxt;
2635 error0 = TCP_ERROR_CREATE_SESSION_FAIL;
2639 new_tc0->tx_fifo_size =
2643 TCP_EVT (TCP_EVT_SYNACK_RCVD, new_tc0);
2644 error0 = TCP_ERROR_SYN_ACKS_RCVD;
2649 new_tc0->state = TCP_STATE_SYN_RCVD;
2656 TCP_EVT (TCP_EVT_RST_SENT, tc0);
2657 error0 = TCP_ERROR_CREATE_SESSION_FAIL;
2661 new_tc0->tx_fifo_size =
2663 new_tc0->rtt_ts = 0;
2666 error0 = TCP_ERROR_SYNS_RCVD;
2670 if (!(new_tc0->cfg_flags & TCP_CFG_F_NO_TSO))
2678 if (error0 == TCP_ERROR_ACK_OK)
2679 error0 = TCP_ERROR_SYN_ACKS_RCVD;
2725 .name =
"tcp4-syn-sent",
2727 .vector_size =
sizeof (
u32),
2733 #define _(s,n) [TCP_SYN_SENT_NEXT_##s] = n, 2744 .name =
"tcp6-syn-sent",
2746 .vector_size =
sizeof (
u32),
2752 #define _(s,n) [TCP_SYN_SENT_NEXT_##s] = n, 2770 u32 n_left_from, *from, max_dequeue;
2775 while (n_left_from > 0)
2777 u32 bi0, error0 = TCP_ERROR_NONE;
2792 error0 = TCP_ERROR_INVALID_CONNECTION;
2806 if (tmp->state != tc0->state)
2808 if (tc0->state != TCP_STATE_CLOSED)
2820 error0 = TCP_ERROR_CONNECTION_CLOSED;
2835 case TCP_STATE_SYN_RCVD:
2838 if (tc0->rcv_nxt !=
vnet_buffer (b0)->tcp.seq_number || is_fin0)
2841 error0 = TCP_ERROR_SEGMENT_INVALID;
2862 tc0->state = TCP_STATE_ESTABLISHED;
2863 TCP_EVT (TCP_EVT_STATE_CHANGE, tc0);
2865 if (!(tc0->cfg_flags & TCP_CFG_F_NO_TSO))
2870 tc0->snd_wnd = clib_net_to_host_u16 (tcp0->window)
2871 << tc0->rcv_opts.wscale;
2879 error0 = TCP_ERROR_MSG_QUEUE_FULL;
2883 error0 = TCP_ERROR_ACK_OK;
2885 case TCP_STATE_ESTABLISHED:
2892 case TCP_STATE_FIN_WAIT_1:
2900 if (tc0->flags & TCP_CONN_FINPNDG)
2904 if (max_dequeue <= tc0->burst_acked)
2907 else if ((tc0->flags & TCP_CONN_FINRCVD) && tc0->bytes_acked)
2912 else if (tc0->snd_una == tc0->snd_nxt)
2920 if (tc0->flags & TCP_CONN_FINRCVD)
2935 if (tc0->burst_acked > 1)
2937 tc0->burst_acked - 1);
2938 tc0->burst_acked = 0;
2941 case TCP_STATE_FIN_WAIT_2:
2947 tc0->burst_acked = 0;
2949 case TCP_STATE_CLOSE_WAIT:
2954 if (!(tc0->flags & TCP_CONN_FINPNDG))
2959 if (max_dequeue > tc0->burst_acked)
2967 case TCP_STATE_CLOSING:
2974 if (tc0->snd_una != tc0->snd_nxt)
2984 case TCP_STATE_LAST_ACK:
2993 if (is_fin0 && tc0->snd_una != tc0->snd_nxt)
3011 case TCP_STATE_TIME_WAIT:
3036 case TCP_STATE_ESTABLISHED:
3037 case TCP_STATE_FIN_WAIT_1:
3038 case TCP_STATE_FIN_WAIT_2:
3042 case TCP_STATE_CLOSE_WAIT:
3043 case TCP_STATE_CLOSING:
3044 case TCP_STATE_LAST_ACK:
3045 case TCP_STATE_TIME_WAIT:
3055 TCP_EVT (TCP_EVT_FIN_RCVD, tc0);
3059 case TCP_STATE_ESTABLISHED:
3067 case TCP_STATE_SYN_RCVD:
3077 case TCP_STATE_CLOSE_WAIT:
3078 case TCP_STATE_CLOSING:
3079 case TCP_STATE_LAST_ACK:
3082 case TCP_STATE_FIN_WAIT_1:
3085 if (tc0->flags & TCP_CONN_FINPNDG)
3090 tc0->flags |= TCP_CONN_FINRCVD;
3103 case TCP_STATE_FIN_WAIT_2:
3112 case TCP_STATE_TIME_WAIT:
3119 error0 = TCP_ERROR_FIN_RCVD;
3158 .name =
"tcp4-rcv-process",
3160 .vector_size =
sizeof (
u32),
3166 #define _(s,n) [TCP_RCV_PROCESS_NEXT_##s] = n, 3177 .name =
"tcp6-rcv-process",
3179 .vector_size =
sizeof (
u32),
3185 #define _(s,n) [TCP_RCV_PROCESS_NEXT_##s] = n, 3200 u32 n_left_from, *from, n_syns = 0, *first_buffer;
3207 while (n_left_from > 0)
3217 u32 error0 = TCP_ERROR_NONE;
3229 if (tc0->state != TCP_STATE_TIME_WAIT)
3231 error0 = TCP_ERROR_CREATE_EXISTS;
3272 error0 = TCP_ERROR_CREATE_EXISTS;
3278 child0->c_lcl_port = th0->dst_port;
3279 child0->c_rmt_port = th0->src_port;
3280 child0->c_is_ip4 =
is_ip4;
3281 child0->state = TCP_STATE_SYN_RCVD;
3282 child0->c_fib_index = lc0->c_fib_index;
3283 child0->cc_algo = lc0->cc_algo;
3300 error0 = TCP_ERROR_OPTIONS;
3306 child0->rcv_nxt =
vnet_buffer (b0)->tcp.seq_number + 1;
3307 child0->rcv_las = child0->rcv_nxt;
3314 child0->tsval_recent = child0->rcv_opts.tsval;
3319 child0->snd_wscale = child0->rcv_opts.wscale;
3321 child0->snd_wnd = clib_net_to_host_u16 (th0->window)
3322 << child0->snd_wscale;
3323 child0->snd_wl1 =
vnet_buffer (b0)->tcp.seq_number;
3324 child0->snd_wl2 =
vnet_buffer (b0)->tcp.ack_number;
3330 lc0->c_thread_index, 0 ))
3333 error0 = TCP_ERROR_CREATE_SESSION_FAIL;
3337 TCP_EVT (TCP_EVT_SYN_RCVD, child0, 1);
3351 n_syns += (error0 == TCP_ERROR_NONE);
3375 .name =
"tcp4-listen",
3377 .vector_size =
sizeof (
u32),
3383 #define _(s,n) [TCP_LISTEN_NEXT_##s] = n, 3394 .name =
"tcp6-listen",
3396 .vector_size =
sizeof (
u32),
3402 #define _(s,n) [TCP_LISTEN_NEXT_##s] = n, 3410 typedef enum _tcp_input_next
3422 #define foreach_tcp4_input_next \ 3423 _ (DROP, "ip4-drop") \ 3424 _ (LISTEN, "tcp4-listen") \ 3425 _ (RCV_PROCESS, "tcp4-rcv-process") \ 3426 _ (SYN_SENT, "tcp4-syn-sent") \ 3427 _ (ESTABLISHED, "tcp4-established") \ 3428 _ (RESET, "tcp4-reset") \ 3429 _ (PUNT, "ip4-punt") 3431 #define foreach_tcp6_input_next \ 3432 _ (DROP, "ip6-drop") \ 3433 _ (LISTEN, "tcp6-listen") \ 3434 _ (RCV_PROCESS, "tcp6-rcv-process") \ 3435 _ (SYN_SENT, "tcp6-syn-sent") \ 3436 _ (ESTABLISHED, "tcp6-established") \ 3437 _ (RESET, "tcp6-reset") \ 3438 _ (PUNT, "ip6-punt") 3440 #define filter_flags (TCP_FLAG_SYN|TCP_FLAG_ACK|TCP_FLAG_RST|TCP_FLAG_FIN) 3451 for (i = 0; i < n_bufs; i++)
3453 if (bs[i]->
flags & VLIB_BUFFER_IS_TRACED)
3467 if (*error == TCP_ERROR_FILTERED || *error == TCP_ERROR_WRONG_THREAD)
3471 else if ((is_ip4 && tm->punt_unknown4) || (!is_ip4 && tm->punt_unknown6))
3474 *error = TCP_ERROR_PUNT;
3479 *error = TCP_ERROR_NO_LISTENER;
3488 int n_advance_bytes, n_data_bytes;
3499 *error = TCP_ERROR_LENGTH;
3505 n_data_bytes = clib_net_to_host_u16 (ip4->
length) - n_advance_bytes;
3510 *error = TCP_ERROR_LENGTH;
3518 TRANSPORT_PROTO_TCP, thread_index,
3526 *error = TCP_ERROR_LENGTH;
3534 n_advance_bytes +=
sizeof (ip6[0]);
3538 *error = TCP_ERROR_LENGTH;
3554 tcp->dst_port, tcp->src_port,
3555 TRANSPORT_PROTO_TCP,
3556 thread_index, &result);
3563 tcp.connection_index,
3566 vnet_buffer (b)->tcp.seq_number = clib_net_to_host_u32 (tcp->seq_number);
3567 vnet_buffer (b)->tcp.ack_number = clib_net_to_host_u32 (tcp->ack_number);
3568 vnet_buffer (b)->tcp.data_offset = n_advance_bytes;
3574 *error = result ? TCP_ERROR_NONE + result : *error;
3588 *next = tm->dispatch_table[tc->state][
flags].next;
3589 *error = tm->dispatch_table[tc->state][
flags].error;
3599 if (*error == TCP_ERROR_DISPATCH)
3600 clib_warning (
"tcp conn %u disp error state %U flags %U",
3624 while (n_left_from >= 4)
3626 u32 error0 = TCP_ERROR_NO_LISTENER, error1 = TCP_ERROR_NO_LISTENER;
3649 vnet_buffer (b[0])->tcp.connection_index = tc0->c_c_index;
3650 vnet_buffer (b[1])->tcp.connection_index = tc1->c_c_index;
3660 vnet_buffer (b[0])->tcp.connection_index = tc0->c_c_index;
3669 vnet_buffer (b[1])->tcp.connection_index = tc1->c_c_index;
3680 while (n_left_from > 0)
3683 u32 error0 = TCP_ERROR_NO_LISTENER;
3685 if (n_left_from > 1)
3697 vnet_buffer (b[0])->tcp.connection_index = tc0->c_c_index;
3734 .name =
"tcp4-input-nolookup",
3736 .vector_size =
sizeof (
u32),
3742 #define _(s,n) [TCP_INPUT_NEXT_##s] = n, 3754 .name =
"tcp6-input-nolookup",
3756 .vector_size =
sizeof (
u32),
3762 #define _(s,n) [TCP_INPUT_NEXT_##s] = n, 3788 .name =
"tcp4-input",
3790 .vector_size =
sizeof (
u32),
3796 #define _(s,n) [TCP_INPUT_NEXT_##s] = n, 3808 .name =
"tcp6-input",
3810 .vector_size =
sizeof (
u32),
3816 #define _(s,n) [TCP_INPUT_NEXT_##s] = n, 3825 #ifndef CLIB_MARCH_VARIANT 3830 for (i = 0; i <
ARRAY_LEN (tm->dispatch_table); i++)
3831 for (j = 0; j <
ARRAY_LEN (tm->dispatch_table[i]); j++)
3834 tm->dispatch_table[
i][j].error = TCP_ERROR_DISPATCH;
3837 #define _(t,f,n,e) \ 3839 tm->dispatch_table[TCP_STATE_##t][f].next = (n); \ 3840 tm->dispatch_table[TCP_STATE_##t][f].error = (e); \ 3849 TCP_ERROR_ACK_INVALID);
3851 TCP_ERROR_SEGMENT_INVALID);
3853 TCP_ERROR_SEGMENT_INVALID);
3855 TCP_ERROR_INVALID_CONNECTION);
3858 TCP_ERROR_SEGMENT_INVALID);
3860 TCP_ERROR_SEGMENT_INVALID);
3864 TCP_ERROR_SEGMENT_INVALID);
3866 TCP_ERROR_SEGMENT_INVALID);
3868 TCP_ERROR_SEGMENT_INVALID);
4048 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.
u32 connection_index
Index of the transport connection associated to the session.
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)
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)
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
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.
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)
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)
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...)
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.
vlib_main_t vlib_node_runtime_t * node
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
session_t * session_lookup_listener6(u32 fib_index, ip6_address_t *lcl, u16 lcl_port, u8 proto, u8 use_wildcard)
#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)
vl_api_dhcp_client_state_t state
#define tcp_disconnect_pending_off(tc)
static u32 vlib_num_workers()
void tcp_connection_cleanup(tcp_connection_t *tc)
Cleans up connection state.
void tcp_connection_del(tcp_connection_t *tc)
Connection removal.
f64 end
end of the time range
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
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
static transport_connection_t * transport_get_listener(transport_proto_t tp, u32 conn_index)
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)
session_t * session_lookup_listener4(u32 fib_index, ip4_address_t *lcl, u16 lcl_port, u8 proto, u8 use_wildcard)
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.