65 .sw_if_index = tc->sw_if_index,
75 tc->cc_algo->init (tc);
81 if (tc->cc_algo->cleanup)
82 tc->cc_algo->cleanup (tc);
92 tm->cc_algos[
type] = *vft;
100 return &tm->cc_algos[
type];
108 return tm->cc_last_type;
118 pool_get (tm->listener_pool, listener);
121 listener->c_c_index = listener - tm->listener_pool;
122 listener->c_lcl_port = lcl->port;
129 ip_set (&lcl->ip, iface_ip, lcl->is_ip4);
131 ip_copy (&listener->c_lcl_ip, &lcl->ip, lcl->is_ip4);
132 listener->c_is_ip4 = lcl->is_ip4;
133 listener->c_proto = TRANSPORT_PROTO_TCP;
134 listener->c_s_index = session_index;
135 listener->c_fib_index = lcl->fib_index;
136 listener->state = TCP_STATE_LISTEN;
141 TCP_EVT (TCP_EVT_BIND, listener);
143 return listener->c_c_index;
182 return &tc->connection;
196 pool_put (tm->half_open_connections, tc);
226 pool_get (tm->half_open_connections, tc);
228 tc->c_c_index = tc - tm->half_open_connections;
249 if (tc->state == TCP_STATE_SYN_SENT)
255 tc->flags |= TCP_CONN_HALF_OPEN_DONE;
259 int thread_index = tc->c_thread_index;
273 if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE)
279 pool_put (tm->connections[thread_index], tc);
303 pool_get (tm->connections[thread_index], tc);
305 tc->c_c_index = tc - tm->connections[thread_index];
306 tc->c_thread_index = thread_index;
316 pool_get (tm->connections[thread_index], tc);
318 tc->c_c_index = tc - tm->connections[thread_index];
319 tc->c_thread_index = thread_index;
329 u8 thread_index = tc->c_thread_index;
331 pool_put (tm->connections[thread_index], tc);
334 pool_put (tm->connections[tc->c_thread_index], tc);
344 TCP_EVT (TCP_EVT_RST_RCVD, tc);
347 case TCP_STATE_SYN_RCVD:
352 case TCP_STATE_SYN_SENT:
356 case TCP_STATE_ESTABLISHED:
366 case TCP_STATE_CLOSE_WAIT:
367 case TCP_STATE_FIN_WAIT_1:
368 case TCP_STATE_FIN_WAIT_2:
369 case TCP_STATE_CLOSING:
370 case TCP_STATE_LAST_ACK:
379 case TCP_STATE_CLOSED:
380 case TCP_STATE_TIME_WAIT:
383 TCP_DBG (
"reset state: %u", tc->state);
408 case TCP_STATE_SYN_SENT:
413 case TCP_STATE_SYN_RCVD:
419 case TCP_STATE_ESTABLISHED:
433 tc->flags |= TCP_CONN_FINPNDG;
440 case TCP_STATE_CLOSE_WAIT:
449 tc->flags |= TCP_CONN_FINPNDG;
451 case TCP_STATE_FIN_WAIT_1:
454 case TCP_STATE_CLOSED:
462 TCP_DBG (
"state: %u", tc->state);
529 typedef struct ip4_tcp_hdr
535 typedef struct ip6_tcp_hdr
554 hdr.ip.protocol = IP_PROTOCOL_TCP;
555 hdr.ip.address_pair.src.as_u32 = tc->c_lcl_ip.ip4.as_u32;
556 hdr.ip.address_pair.dst.as_u32 = tc->c_rmt_ip.ip4.as_u32;
557 hdr.tcp.src_port = tc->c_lcl_port;
558 hdr.tcp.dst_port = tc->c_rmt_port;
565 hdr.ip.protocol = IP_PROTOCOL_TCP;
570 hdr.tcp.src_port = tc->c_lcl_port;
571 hdr.tcp.dst_port = tc->c_rmt_port;
586 prefix.
fp_len = tc->c_is_ip4 ? 32 : 128;
595 u32 output_node_index;
602 tcp_connection_select_lb_bucket (tc, &fe->
fe_lb, &choice);
621 tcp_connection_stack_on_fib_entry (tc);
635 tmp = (
u64) tc->c_lcl_ip.ip4.as_u32 << 32 | (
u64) tc->c_rmt_ip.ip4.as_u32;
637 tmp = tc->c_lcl_ip.ip6.as_u64[0] ^ tc->c_lcl_ip.ip6.as_u64[1]
638 ^ tc->c_rmt_ip.ip6.as_u64[0] ^ tc->c_rmt_ip.ip6.as_u64[1];
640 tmp ^= tm->iss_seed.first | ((
u64) tc->c_lcl_port << 16 | tc->c_rmt_port);
641 tmp ^= tm->iss_seed.second;
643 return ((tmp >> 32) ^ (tmp & 0xffffffff));
665 u16 default_min_mss = 536;
670 tc->snd_mss =
clib_min (tc->rcv_opts.mss, tc->mss);
672 if (tc->snd_mss < 45)
675 tc->snd_mss = default_min_mss;
676 tc->rcv_opts.mss = default_min_mss;
680 ASSERT (tc->snd_mss > 45);
703 tc->snd_una = tc->iss;
704 tc->snd_nxt = tc->iss + 1;
705 tc->snd_una_max = tc->snd_nxt;
709 tc->cfg_flags |= TCP_CFG_F_NO_CSUM_OFFLOAD;
716 byte_rate = tc->cwnd / (tc->srtt *
TCP_TICK);
718 tc->mrtt_us = (
u32) ~ 0;
731 if (tc->state == TCP_STATE_SYN_RCVD)
745 if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE)
749 tc->cfg_flags |= TCP_CFG_F_NO_TSO;
761 index = tm->last_v4_addr_rotor++;
763 tm->last_v4_addr_rotor = 0;
764 lcl_addr->ip4.as_u32 =
tcp_cfg.ip4_src_addrs[index].as_u32;
768 index = tm->last_v6_addr_rotor++;
770 tm->last_v6_addr_rotor = 0;
789 ip46_address_t lcl_addr;
802 rmt, &lcl_addr, &lcl_port);
812 ip_copy (&tc->c_rmt_ip, &rmt->ip, rmt->is_ip4);
813 ip_copy (&tc->c_lcl_ip, &lcl_addr, rmt->is_ip4);
814 tc->c_rmt_port = rmt->port;
815 tc->c_lcl_port = clib_host_to_net_u16 (lcl_port);
816 tc->c_is_ip4 = rmt->is_ip4;
817 tc->c_proto = TRANSPORT_PROTO_TCP;
818 tc->c_fib_index = rmt->fib_index;
824 tc->state = TCP_STATE_SYN_SENT;
829 return tc->c_c_index;
833 #define _(sym, str) str, 846 s =
format (s,
"UNKNOWN (%d (0x%x))", state, state);
851 #define _(sym, str) str, 863 if (tc->cfg_flags & (1 << i))
865 for (i = 0; i <
last; i++)
867 if (tc->cfg_flags & (1 << i))
876 #define _(sym, str) str, 888 if (tc->flags & (1 << i))
890 for (i = 0; i <
last; i++)
892 if (tc->flags & (1 << i))
901 #define _(sym, str) str, 916 for (i = 0; i <
last; i++)
933 s =
format (s,
"recovery");
935 s =
format (s,
"fastrecovery");
944 return (
i32) tc->rcv_wnd - (tc->rcv_nxt - tc->rcv_las);
954 s =
format (s,
"algo %s cwnd %u ssthresh %u bytes_acked %u\n",
955 tc->cc_algo->name, tc->cwnd, tc->ssthresh, tc->bytes_acked);
956 s =
format (s,
"%Ucc space %u prev_cwnd %u prev_ssthresh %u\n",
958 tc->prev_cwnd, tc->prev_ssthresh);
959 s =
format (s,
"%Usnd_cong %u dupack %u limited_tx %u\n",
961 tc->rcv_dupacks, tc->limited_transmit - tc->iss);
962 s =
format (s,
"%Urxt_bytes %u rxt_delivered %u rxt_head %u rxt_ts %u\n",
964 tc->rxt_delivered, tc->rxt_head - tc->iss,
968 s =
format (s,
"%Uprr_start %u prr_delivered %u prr space %u\n",
970 tc->prr_delivered, prr_space);
979 s =
format (s,
"in segs %lu dsegs %lu bytes %lu dupacks %u\n",
980 tc->segs_in, tc->data_segs_in, tc->bytes_in, tc->dupacks_in);
981 s =
format (s,
"%Uout segs %lu dsegs %lu bytes %lu dupacks %u\n",
983 tc->data_segs_out, tc->bytes_out, tc->dupacks_out);
984 s =
format (s,
"%Ufr %u tr %u rxt segs %lu bytes %lu duration %.3f\n",
986 tc->tr_occurences, tc->segs_retrans, tc->bytes_retrans,
988 s =
format (s,
"%Uerr wnd data below %u above %u ack below %u above %u",
990 tc->errors.above_data_wnd, tc->errors.below_ack_wnd,
991 tc->errors.above_ack_wnd);
999 s =
format (s,
" index: %u cfg: %U flags: %U timers: %U\n", tc->c_c_index,
1002 s =
format (s,
" snd_una %u snd_nxt %u snd_una_max %u",
1003 tc->snd_una - tc->iss, tc->snd_nxt - tc->iss,
1004 tc->snd_una_max - tc->iss);
1005 s =
format (s,
" rcv_nxt %u rcv_las %u\n",
1006 tc->rcv_nxt - tc->irs, tc->rcv_las - tc->irs);
1007 s =
format (s,
" snd_wnd %u rcv_wnd %u rcv_wscale %u ",
1008 tc->snd_wnd, tc->rcv_wnd, tc->rcv_wscale);
1009 s =
format (s,
"snd_wl1 %u snd_wl2 %u\n", tc->snd_wl1 - tc->irs,
1010 tc->snd_wl2 - tc->iss);
1011 s =
format (s,
" flight size %u out space %u rcv_wnd_av %u",
1014 s =
format (s,
" tsval_recent %u\n", tc->tsval_recent);
1015 s =
format (s,
" tsecr %u tsecr_last_ack %u tsval_recent_age %u",
1016 tc->rcv_opts.tsecr, tc->tsecr_last_ack,
1018 s =
format (s,
" snd_mss %u\n", tc->snd_mss);
1019 s =
format (s,
" rto %u rto_boff %u srtt %u us %.3f rttvar %u rtt_ts %.4f",
1020 tc->rto, tc->rto_boff, tc->srtt, tc->mrtt_us * 1000, tc->rttvar,
1022 s =
format (s,
" rtt_seq %u\n", tc->rtt_seq - tc->iss);
1023 s =
format (s,
" next_node %u opaque 0x%x\n", tc->next_node_index,
1024 tc->next_node_opaque);
1027 if (tc->state >= TCP_STATE_ESTABLISHED)
1047 s =
format (s,
"[%d:%d][%s] %U:%d->%U:%d", tc->c_thread_index,
1050 &tc->c_rmt_ip4, clib_net_to_host_u16 (tc->c_rmt_port));
1054 s =
format (s,
"[%d:%d][%s] %U:%d->%U:%d", tc->c_thread_index,
1057 &tc->c_rmt_ip6, clib_net_to_host_u16 (tc->c_rmt_port));
1067 u32 verbose = va_arg (*args,
u32);
1085 u32 tci = va_arg (*args,
u32);
1086 u32 thread_index = va_arg (*args,
u32);
1087 u32 verbose = va_arg (*args,
u32);
1094 s =
format (s,
"empty\n");
1101 u32 tci = va_arg (*args,
u32);
1102 u32 __clib_unused thread_index = va_arg (*args,
u32);
1103 u32 verbose = va_arg (*args,
u32);
1114 u32 tci = va_arg (*args,
u32);
1115 u32 __clib_unused thread_index = va_arg (*args,
u32);
1129 for (i = 0; i < len - 1; i++)
1132 s =
format (s,
" start %u end %u\n", block->start - tc->irs,
1133 block->end - tc->irs);
1137 block = &sacks[len - 1];
1138 s =
format (s,
" start %u end %u", block->start - tc->irs,
1139 block->end - tc->irs);
1153 for (i = 0; i < len - 1; i++)
1156 s =
format (s,
" start %u end %u\n", block->start - tc->iss,
1157 block->end - tc->iss);
1161 block = &sacks[len - 1];
1162 s =
format (s,
" start %u end %u", block->start - tc->iss,
1163 block->end - tc->iss);
1174 s =
format (s,
" [%u, %u]", hole->start - tc->iss, hole->end - tc->iss);
1176 s =
format (s,
" [%u, %u]", hole->start, hole->end);
1188 s =
format (s,
"sacked %u last_sacked %u lost %u last_lost %u" 1190 sb->sacked_bytes, sb->last_sacked_bytes, sb->lost_bytes,
1191 sb->last_lost_bytes, sb->rxt_sacked);
1192 s =
format (s,
"%Ulast_delivered %u high_sacked %u is_reneging %u\n",
1194 sb->high_sacked - tc->iss, sb->is_reneging);
1195 s =
format (s,
"%Ucur_rxt_hole %u high_rxt %u rescue_rxt %u",
1197 sb->high_rxt - tc->iss, sb->rescue_rxt - tc->iss);
1202 indent, sb->head, sb->tail,
pool_elts (sb->holes),
1220 return &tc->connection;
1227 return &tc->connection;
1233 u16 goal_size = tc->snd_mss;
1236 goal_size =
clib_min (goal_size, tc->snd_wnd / 2);
1238 return goal_size > tc->snd_mss ? goal_size : tc->snd_mss;
1269 return tc->snd_wnd <= snd_space ? tc->snd_wnd : 0;
1275 return snd_space < tc->cwnd ? 0 : snd_space;
1278 return snd_space - (snd_space % tc->snd_mss);
1297 || tc->state == TCP_STATE_CLOSED))
1306 if (
PREDICT_FALSE (tc->rcv_dupacks != 0 || tc->sack_sb.sacked_bytes))
1308 if (tc->limited_transmit != tc->snd_nxt
1309 && (
seq_lt (tc->limited_transmit, tc->snd_nxt - 2 * tc->snd_mss)
1310 ||
seq_gt (tc->limited_transmit, tc->snd_nxt)))
1311 tc->limited_transmit = tc->snd_nxt;
1315 int snt_limited = tc->snd_nxt - tc->limited_transmit;
1316 snd_space =
clib_max ((
int) 2 * tc->snd_mss - snt_limited, 0);
1332 tc->snd_wnd - (tc->snd_nxt - tc->snd_una));
1343 return (tc->snd_nxt - tc->snd_una);
1352 tw_timer_expire_timers_16t_2w_512sl (&wrk->
timer_wheel, now);
1360 if (tc->flags & TCP_CONN_PSH_PENDING)
1362 tc->flags |= TCP_CONN_PSH_PENDING;
1388 .transport_options = {
1430 case TCP_STATE_CLOSE_WAIT:
1434 if (!(tc->flags & TCP_CONN_FINPNDG))
1445 tc->snd_nxt = tc->snd_una;
1454 case TCP_STATE_FIN_WAIT_1:
1457 if (tc->flags & TCP_CONN_FINPNDG)
1473 case TCP_STATE_LAST_ACK:
1474 case TCP_STATE_CLOSING:
1501 u32 connection_index, timer_id;
1509 for (i = 0; i <
vec_len (expired_timers); i++)
1511 connection_index = expired_timers[
i] & 0x0FFFFFFF;
1512 timer_id = expired_timers[
i] >> 28;
1514 if (timer_id != TCP_TIMER_RETRANSMIT_SYN)
1519 TCP_EVT (TCP_EVT_TIMER_POP, connection_index, timer_id);
1527 for (i = 0; i <
vec_len (expired_timers); i++)
1529 connection_index = expired_timers[
i] & 0x0FFFFFFF;
1530 timer_id = expired_timers[
i] >> 28;
1539 tw_timer_wheel_16t_2w_512sl_t *tw;
1542 tw = &tm->wrk_ctx[ii].timer_wheel;
1556 tm->iss_seed.first = (
u64)
random_u32 (&default_seed) << 32;
1557 tm->iss_seed.second =
random_u64 (&time_now);
1564 u32 num_threads, n_workers, prealloc_conn_per_wrk;
1591 n_workers = num_threads == 1 ? 1 : vtm->
n_threads;
1592 prealloc_conn_per_wrk =
tcp_cfg.preallocated_connections / n_workers;
1594 for (thread = 0; thread < num_threads; thread++)
1596 vec_validate (tm->wrk_ctx[thread].pending_deq_acked, 255);
1597 vec_validate (tm->wrk_ctx[thread].pending_disconnects, 255);
1606 if ((thread > 0 || num_threads == 1) && prealloc_conn_per_wrk)
1613 if (
tcp_cfg.preallocated_half_open_connections)
1615 tcp_cfg.preallocated_half_open_connections);
1622 if (num_threads > 1)
1658 tm->punt_unknown4 = is_add;
1660 tm->punt_unknown6 = is_add;
1672 tcp_cfg.max_rx_fifo = 32 << 20;
1673 tcp_cfg.min_rx_fifo = 4 << 10;
1676 tcp_cfg.initial_cwnd_multiplier = 0;
1681 tcp_cfg.rwnd_min_update_ack = 1;
1736 if (
unformat (input,
"%s", &cc_algo_name)
1737 && ((p =
hash_get_mem (tm->cc_algo_by_name, cc_algo_name))))
1757 if (!
unformat (input, cc_alg->name))
1760 if (cc_alg->unformat_cfg
1763 if (cc_alg->unformat_cfg (&sub_input))
1773 u32 cwnd_multiplier, tmp_time;
1778 if (
unformat (input,
"preallocated-connections %d",
1779 &
tcp_cfg.preallocated_connections))
1781 else if (
unformat (input,
"preallocated-half-open-connections %d",
1782 &
tcp_cfg.preallocated_half_open_connections))
1784 else if (
unformat (input,
"buffer-fail-fraction %f",
1785 &
tcp_cfg.buffer_fail_fraction))
1790 if (memory_size >= 0x100000000)
1793 (0,
"max-rx-fifo %llu (0x%llx) too large", memory_size,
1801 if (memory_size >= 0x100000000)
1804 (0,
"min-rx-fifo %llu (0x%llx) too large", memory_size,
1811 else if (
unformat (input,
"rwnd-min-update-ack %d",
1812 &
tcp_cfg.rwnd_min_update_ack))
1814 else if (
unformat (input,
"initial-cwnd-multiplier %u",
1816 tcp_cfg.initial_cwnd_multiplier = cwnd_multiplier;
1817 else if (
unformat (input,
"no-tx-pacing"))
1821 else if (
unformat (input,
"no-csum-offload"))
1828 else if (
unformat (input,
"closewait-time %u", &tmp_time))
1830 else if (
unformat (input,
"timewait-time %u", &tmp_time))
1832 else if (
unformat (input,
"finwait1-time %u", &tmp_time))
1834 else if (
unformat (input,
"finwait2-time %u", &tmp_time))
1836 else if (
unformat (input,
"lastack-time %u", &tmp_time))
1838 else if (
unformat (input,
"closing-time %u", &tmp_time))
1840 else if (
unformat (input,
"cleanup-time %u", &tmp_time))
1866 u32 start_host_byte_order, end_host_byte_order;
1877 if (fib_index == ~0)
1878 return VNET_API_ERROR_NO_SUCH_FIB;
1880 start_host_byte_order = clib_net_to_host_u32 (start->
as_u32);
1881 end_host_byte_order = clib_net_to_host_u32 (end->
as_u32);
1884 if ((end_host_byte_order - start_host_byte_order) > (10 << 10))
1885 return VNET_API_ERROR_INVALID_ARGUMENT;
1896 return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
1931 start_host_byte_order++;
1932 start->
as_u32 = clib_host_to_net_u32 (start_host_byte_order);
1934 while (start_host_byte_order <= end_host_byte_order);
1962 if (fib_index == ~0)
1963 return VNET_API_ERROR_NO_SUCH_FIB;
1983 return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
1987 if (sw_if_index == (
u32) ~ 0)
1988 return VNET_API_ERROR_NO_MATCHING_INTERFACE;
2004 if (!memcmp (start, end,
sizeof (start[0])))
2009 for (i = 15; i >= 0; i--)
2012 if (tmp.
as_u8[i] != 0)
2038 memcpy (&v4end, &v4start,
sizeof (v4start));
2046 memcpy (&v6end, &v6start,
sizeof (v6start));
2049 else if (
unformat (input,
"fib-table %d", &table_id))
2055 if (!v4set && !v6set)
2067 case VNET_API_ERROR_NO_SUCH_FIB:
2070 case VNET_API_ERROR_INVALID_ARGUMENT:
2088 case VNET_API_ERROR_NO_SUCH_FIB:
2102 .path =
"tcp src-address",
2103 .short_help =
"tcp src-address <ip-addr> [- <ip-addr>] add src address range",
2111 #if TCP_SCOREBOARD_TRACE 2119 s =
format (s,
"scoreboard trace:");
2122 s =
format (s,
"{%u, %u, %u, %u, %u}, ", block->start, block->end,
2123 block->ack, block->snd_una_max, block->group);
2143 TRANSPORT_PROTO_TCP))
2165 .path =
"show tcp scoreboard trace",
2166 .short_help =
"show tcp scoreboard trace <connection>",
2176 u32 next_ack,
left, group, has_new_ack = 0;
2182 s =
format (s,
"scoreboard tracing not enabled");
2192 dummy_tc->rcv_opts.flags |= TCP_OPTS_FLAG_SACK;
2194 #if TCP_SCOREBOARD_TRACE 2195 trace = tc->sack_sb.trace;
2196 trace_len =
vec_len (tc->sack_sb.trace);
2199 for (i = 0; i < trace_len; i++)
2201 if (trace[i].ack != 0)
2203 dummy_tc->snd_una = trace[
i].ack - 1448;
2204 dummy_tc->snd_una_max = trace[
i].ack;
2209 while (left < trace_len)
2211 group = trace[
left].group;
2214 while (trace[left].group == group)
2216 if (trace[left].ack != 0)
2219 s =
format (s,
"Adding ack %u, snd_una_max %u, segs: ",
2220 trace[left].ack, trace[left].snd_una_max);
2221 dummy_tc->snd_una_max = trace[
left].snd_una_max;
2222 next_ack = trace[
left].ack;
2228 s =
format (s,
"[%u, %u], ", trace[left].start,
2230 vec_add2 (dummy_tc->rcv_opts.sacks, block, 1);
2231 block->start = trace[
left].start;
2232 block->end = trace[
left].end;
2240 dummy_tc->snd_una = next_ack;
2244 &dummy_tc->sack_sb);
2262 TRANSPORT_PROTO_TCP))
2289 .path =
"tcp replay scoreboard",
2290 .short_help =
"tcp replay scoreboard <connection>",
2304 tm->punt_unknown4 ?
"enabled" :
"disabled");
2306 tm->punt_unknown6 ?
"enabled" :
"disabled");
2312 .path =
"show tcp punt",
2313 .short_help =
"show tcp punt",
static void tcp_session_close(u32 conn_index, u32 thread_index)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void dpo_stack_from_node(u32 child_node_index, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child parent relationship.
fib_protocol_t fp_proto
protocol type
#define foreach_tcp_cfg_flag
Connection configuration flags.
void() timer_expiration_handler(u32 index, u32 thread_index)
#define ENDPOINT_INVALID_INDEX
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
static void tcp_add_del_adjacency(tcp_connection_t *tc, u8 is_add)
void receive_dpo_add_or_lock(dpo_proto_t proto, u32 sw_if_index, const ip46_address_t *nh_addr, dpo_id_t *dpo)
static u8 * format_tcp_listener_session(u8 *s, va_list *args)
const char * tcp_fsm_states[]
static clib_error_t * tcp_config_fn(vlib_main_t *vm, unformat_input_t *input)
#define tcp_in_recovery(tc)
static f64 tcp_time_now_us(u32 thread_index)
void ip_copy(ip46_address_t *dst, ip46_address_t *src, u8 is_ip4)
static uword random_default_seed(void)
Default random seed (unix/linux user-mode)
#define seq_leq(_s1, _s2)
struct _sack_block sack_block_t
u8 * format_tcp_rcv_sacks(u8 *s, va_list *args)
void ip6_register_protocol(u32 protocol, u32 node_index)
struct _scoreboard_trace_elt scoreboard_trace_elt_t
u8 * format_tcp_sacks(u8 *s, va_list *args)
static clib_error_t * ip4_lookup_init(vlib_main_t *vm)
const char * tcp_connection_flags_str[]
vlib_node_registration_t tcp4_output_node
(constructor) VLIB_REGISTER_NODE (tcp4_output_node)
void scoreboard_init(sack_scoreboard_t *sb)
uword unformat_transport_connection(unformat_input_t *input, va_list *args)
#define tcp_opts_tstamp(_to)
static u32 tcp_session_send_space(transport_connection_t *trans_conn)
static transport_connection_t * tcp_half_open_session_get_transport(u32 conn_index)
void ip_set(ip46_address_t *dst, void *src, u8 is_ip4)
#define clib_memcpy_fast(a, b, c)
static u32 tcp_session_tx_fifo_offset(transport_connection_t *trans_conn)
static u32 ip4_compute_flow_hash(const ip4_header_t *ip, flow_hash_config_t flow_hash_config)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
struct _sack_scoreboard sack_scoreboard_t
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
static int tcp_alloc_custom_local_endpoint(tcp_main_t *tm, ip46_address_t *lcl_addr, u16 *lcl_port, u8 is_ip4)
static f64 vlib_time_now(vlib_main_t *vm)
static tcp_connection_t * tcp_half_open_connection_new(void)
static u8 * format_tcp_timers(u8 *s, va_list *args)
static tcp_connection_t * tcp_half_open_connection_get(u32 conn_index)
sack_scoreboard_hole_t * scoreboard_next_hole(sack_scoreboard_t *sb, sack_scoreboard_hole_t *hole)
flow_hash_config_t lb_hash_config
the hash config to use when selecting a bucket.
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
struct _tcp_main tcp_main_t
void tcp_connection_timers_reset(tcp_connection_t *tc)
Stop all connection timers.
vlib_node_registration_t tcp6_output_node
(constructor) VLIB_REGISTER_NODE (tcp6_output_node)
void dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static u64 clib_cpu_time_now(void)
timer_expiration_handler tcp_timer_retransmit_handler
static u64 clib_xxhash(u64 key)
static heap_elt_t * last(heap_header_t *h)
u32 tcp_session_push_header(transport_connection_t *tconn, vlib_buffer_t *b)
void session_transport_reset_notify(transport_connection_t *tc)
Notify application that connection has been reset.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
void tcp_update_burst_snd_vars(tcp_connection_t *tc)
Update burst send vars.
#define hash_set_mem(h, key, value)
void * ip_interface_get_first_ip(u32 sw_if_index, u8 is_ip4)
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.
static u64 random_u64(u64 *seed)
64-bit random number generator Again, constants courtesy of Donald Knuth.
static u16 tcp_session_send_mss(transport_connection_t *trans_conn)
Compute maximum segment size for session layer.
static tcp_connection_t * tcp_get_connection_from_transport(transport_connection_t *tconn)
static void tcp_initialize_iss_seed(tcp_main_t *tm)
void ip4_register_protocol(u32 protocol, u32 node_index)
static void tcp_initialize_timer_wheels(tcp_main_t *tm)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
struct _tcp_header tcp_header_t
int tcp_half_open_connection_cleanup(tcp_connection_t *tc)
Try to cleanup half-open connection.
vlib_main_t ** vlib_mains
static void tcp_half_open_connection_del(tcp_connection_t *tc)
Cleanup half-open connection.
struct _sack_scoreboard_hole sack_scoreboard_hole_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
tcp_cc_algorithm_t * tcp_cc_algo_get(tcp_cc_algorithm_type_e type)
int ip4_neighbor_proxy_add(u32 fib_index, const ip4_address_t *start, const ip4_address_t *end)
The set of function that vnet requires from the IP neighbour module.
#define TCP_TICK
TCP tick period (s)
unformat_function_t * unformat_pg_edit
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)
static u8 * format_tcp_vars(u8 *s, va_list *args)
u16 lb_n_buckets_minus_1
number of buckets in the load-balance - 1.
void tcp_connection_timers_init(tcp_connection_t *tc)
Initialize all connection timers as invalid.
static u32 tcp_available_output_snd_space(const tcp_connection_t *tc)
static void tcp_connection_unbind(u32 listener_index)
Aggregate type for a prefix.
tw_timer_wheel_16t_2w_512sl_t timer_wheel
worker timer wheel
#define clib_error_return(e, args...)
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
static u8 * tcp_scoreboard_dump_trace(u8 *s, sack_scoreboard_t *sb)
timer_expiration_handler tcp_timer_retransmit_syn_handler
pthread_t thread[MAX_CONNS]
int transport_alloc_local_endpoint(u8 proto, transport_endpoint_cfg_t *rmt_cfg, ip46_address_t *lcl_addr, u16 *lcl_port)
static u32 tcp_time_now(void)
u32 tcp_snd_space(tcp_connection_t *tc)
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
u16 fp_len
The mask length.
#define vlib_call_init_function(vm, x)
void tcp_api_reference(void)
fib_node_index_t fib_table_lookup(u32 fib_index, const fib_prefix_t *prefix)
Perfom a longest prefix match in the non-forwarding table.
static u32 tcp_connection_bind(u32 session_index, transport_endpoint_t *lcl)
static i32 tcp_rcv_wnd_available(tcp_connection_t *tc)
#define hash_create_string(elts, value_bytes)
static void tcp_cc_init(tcp_connection_t *tc)
struct _transport_proto_vft transport_proto_vft_t
static void clib_spinlock_init(clib_spinlock_t *p)
static void tcp_timer_set(tcp_connection_t *tc, u8 timer_id, u32 interval)
uword unformat_tcp_cc_algo_cfg(unformat_input_t *input, va_list *va)
vl_api_fib_path_type_t type
static u32 tcp_session_unbind(u32 listener_index)
static timer_expiration_handler * timer_expiration_handlers[TCP_N_TIMERS]
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
static clib_error_t * tcp_main_enable(vlib_main_t *vm)
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void tcp_bt_init(tcp_connection_t *tc)
Byte tracker initialize.
timer_expiration_handler tcp_timer_persist_handler
#define CLIB_US_TIME_FREQ
static transport_connection_t * tcp_session_get_transport(u32 conn_index, u32 thread_index)
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
#define tcp_in_fastrecovery(tc)
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
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)
dpo_type_t dpoi_type
the type
format_function_t * format_header
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)
void tcp_rcv_sacks(tcp_connection_t *tc, u32 ack)
static void tcp_init_rcv_mss(tcp_connection_t *tc)
Initialize max segment size we're able to process.
void tcp_send_syn(tcp_connection_t *tc)
Send SYN.
tcp_connection_t * tcp_connection_alloc(u8 thread_index)
load-balancing over a choice of [un]equal cost paths
static transport_connection_t * tcp_session_get_listener(u32 listener_index)
static u32 transport_max_rx_dequeue(transport_connection_t *tc)
void tcp_connection_tx_pacer_update(tcp_connection_t *tc)
static u32 ip6_compute_flow_hash(const ip6_header_t *ip, flow_hash_config_t flow_hash_config)
#define pool_put(P, E)
Free an object E in pool P.
static void tcp_expired_timers_dispatch(u32 *expired_timers)
void transport_connection_tx_pacer_init(transport_connection_t *tc, u64 rate_bytes_per_sec, u32 initial_bucket)
Initialize tx pacer for connection.
#define TCP_TIMER_HANDLE_INVALID
static void tcp_session_cleanup(u32 conn_index, u32 thread_index)
static u32 tcp_flight_size(const tcp_connection_t *tc)
Our estimate of the number of bytes in flight (pipe size)
#define VLIB_CONFIG_FUNCTION(x, n,...)
static u8 * format_tcp_stats(u8 *s, va_list *args)
u8 * format_tcp_scoreboard(u8 *s, va_list *args)
clib_error_t * vnet_tcp_enable_disable(vlib_main_t *vm, u8 is_en)
static u8 transport_connection_is_tx_paced(transport_connection_t *tc)
Check if transport connection is paced.
void transport_connection_tx_pacer_reset(transport_connection_t *tc, u64 rate_bytes_per_sec, u32 start_bucket, clib_us_time_t rtt)
static u8 * format_tcp_cfg_flags(u8 *s, va_list *args)
#define foreach_vlib_main(body)
static void tcp_timer_waitclose_handler(u32 conn_index, u32 thread_index)
#define TCP_OPTION_LEN_TIMESTAMP
const char * tcp_cfg_flags_str[]
#define TCP_DBG(_fmt, _args...)
u32 fib_entry_get_resolving_interface(fib_node_index_t entry_index)
static void tcp_timer_reset(tcp_connection_t *tc, u8 timer_id)
void tcp_connection_free(tcp_connection_t *tc)
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
#define pool_free(p)
Free a pool.
clib_error_t * ip_main_init(vlib_main_t *vm)
fib_node_index_t fib_table_entry_special_dpo_update(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Update a 'special' entry to the FIB that links to the DPO passed A special entry is an entry that the...
int tcp_configure_v4_source_address_range(vlib_main_t *vm, ip4_address_t *start, ip4_address_t *end, u32 table_id)
Configure an ipv4 source address range.
static_always_inline uword vlib_get_thread_index(void)
static void tcp_add_del_adj_cb(tcp_add_del_adj_args_t *args)
static clib_error_t * tcp_src_address(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd_arg)
void tcp_connection_close(tcp_connection_t *tc)
Begin connection closing procedure.
void tcp_send_reset(tcp_connection_t *tc)
Build and set reset packet for connection.
#define vec_free(V)
Free vector's memory (no header).
static void tcp_session_flush_data(transport_connection_t *tconn)
#define clib_warning(format, args...)
static u8 * format_tcp_congestion(u8 *s, va_list *args)
struct _transport_connection transport_connection_t
static u8 * format_tcp_connection_flags(u8 *s, va_list *args)
u32 fib_node_index_t
A typedef of a node index.
uword unformat_tcp_cc_algo(unformat_input_t *input, va_list *va)
vlib_node_registration_t tcp6_input_node
(constructor) VLIB_REGISTER_NODE (tcp6_input_node)
fib_node_index_t tcp_lookup_rmt_in_fib(tcp_connection_t *tc)
fib_entry_t * fib_entry_get(fib_node_index_t index)
#define pool_init_fixed(pool, max_elts)
initialize a fixed-size, preallocated pool
void transport_endpoint_cleanup(u8 proto, ip46_address_t *lcl_ip, u16 port)
void transport_register_protocol(transport_proto_t transport_proto, const transport_proto_vft_t *vft, fib_protocol_t fib_proto, u32 output_node)
Register transport virtual function table.
#define VLIB_CLI_COMMAND(x,...)
static u32 transport_max_tx_dequeue(transport_connection_t *tc)
static void tcp_timer_update(tcp_connection_t *tc, u8 timer_id, u32 interval)
#define pool_put_index(p, i)
Free pool element with given index.
static int tcp_session_open(transport_endpoint_cfg_t *rmt)
tcp_cc_algorithm_type_e tcp_cc_algo_new_type(const tcp_cc_algorithm_t *vft)
Register new cc algo type.
enum _tcp_cc_algorithm_type tcp_cc_algorithm_type_e
static clib_error_t * tcp_scoreboard_trace_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd_arg)
static void tcp_configuration_init(void)
Initialize default values for tcp parameters.
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
void tcp_flush_frames_to_output(tcp_worker_ctx_t *wrk)
Flush v4 and v6 tcp and ip-lookup tx frames for thread index.
static load_balance_t * load_balance_get(index_t lbi)
#define seq_geq(_s1, _s2)
static void tcp_init_mss(tcp_connection_t *tc)
int ip6_neighbor_proxy_add(u32 sw_if_index, const ip6_address_t *addr)
From the control plane API.
static u8 * format_tcp_congestion_status(u8 *s, va_list *args)
static u32 tcp_generate_random_iss(tcp_connection_t *tc)
Generate random iss as per rfc6528.
reliable transport protos
static uword ip6_address_is_link_local_unicast(const ip6_address_t *a)
void tcp_cc_algo_register(tcp_cc_algorithm_type_e type, const tcp_cc_algorithm_t *vft)
Register exiting cc algo type.
u8 * tcp_scoreboard_replay(u8 *s, tcp_connection_t *tc, u8 verbose)
int tcp_configure_v6_source_address_range(vlib_main_t *vm, ip6_address_t *start, ip6_address_t *end, u32 table_id)
Configure an ipv6 source address range.
struct _tcp_cc_algorithm tcp_cc_algorithm_t
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)
void transport_connection_tx_pacer_update(transport_connection_t *tc, u64 bytes_per_sec, clib_us_time_t rtt)
Update tx pacer pacing rate.
dpo_id_t fe_lb
The load-balance used for forwarding.
int ip4_neighbor_proxy_enable(u32 sw_if_index)
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
static const transport_proto_vft_t tcp_proto
void tcp_punt_unknown(vlib_main_t *vm, u8 is_ip4, u8 is_add)
void tcp_connection_reset(tcp_connection_t *tc)
Notify session that connection has been reset.
vlib_node_registration_t tcp4_input_node
(constructor) VLIB_REGISTER_NODE (tcp4_input_node)
static u32 tcp_session_bind(u32 session_index, transport_endpoint_t *tep)
index_t dpoi_index
the index of objects of that type
#define FIB_NODE_INDEX_INVALID
#define foreach_tcp_fsm_state
TCP FSM state definitions as per RFC793.
void tcp_send_fin(tcp_connection_t *tc)
Send FIN.
#define foreach_tcp_connection_flag
TCP connection flags.
#define foreach_tcp_timer
TCP timers.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void vlib_rpc_call_main_thread(void *callback, u8 *args, u32 arg_size)
static void tcp_cc_cleanup(tcp_connection_t *tc)
uword unformat_vlib_cli_sub_input(unformat_input_t *i, va_list *args)
sack_scoreboard_hole_t * scoreboard_first_hole(sack_scoreboard_t *sb)
static u32 tcp_round_snd_space(tcp_connection_t *tc, u32 snd_space)
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.
void tcp_connection_init_vars(tcp_connection_t *tc)
Initialize tcp connection variables.
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
const char * tcp_conn_timers[]
static u8 * format_tcp_session(u8 *s, va_list *args)
#define hash_get_mem(h, key)
u8 * format_tcp_connection(u8 *s, va_list *args)
static u8 * format_tcp_sack_hole(u8 *s, va_list *args)
static tcp_connection_t * tcp_connection_get(u32 conn_index, u32 thread_index)
static u32 random_u32(u32 *seed)
32-bit random number generator
#define TCP_SCOREBOARD_TRACE
#define TCP_TIMER_TICK
Timer tick in seconds.
int session_stream_connect_notify(transport_connection_t *tc, u8 is_fail)
static u16 tcp_session_cal_goal_size(tcp_connection_t *tc)
static vlib_thread_main_t * vlib_get_thread_main()
vl_api_dhcp_client_state_t state
void tcp_connection_cleanup(tcp_connection_t *tc)
Cleans up connection state.
void tcp_connection_del(tcp_connection_t *tc)
Connection removal.
adj_index_t adj_nbr_add_or_lock(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Neighbour Adjacency sub-type.
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
#define vec_foreach(var, vec)
Vector iterator.
f64 end
end of the time range
#define TCP_TSTAMP_RESOLUTION
Time stamp resolution.
static u8 * format_tcp_half_open_session(u8 *s, va_list *args)
static u32 tcp_snd_space_inline(tcp_connection_t *tc)
Compute tx window session is allowed to fill.
int transport_alloc_local_port(u8 proto, ip46_address_t *ip)
Allocate local port and add if successful add entry to local endpoint table to mark the pair as used...
u8 * format_tcp_state(u8 *s, va_list *args)
static clib_error_t * ip6_lookup_init(vlib_main_t *vm)
static clib_error_t * show_tcp_punt_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd_arg)
static void tcp_update_time(f64 now, u8 thread_index)
void tcp_enable_pacing(tcp_connection_t *tc)
static u64 tcp_cc_get_pacing_rate(tcp_connection_t *tc)
static tcp_main_t * vnet_get_tcp_main()
static void tcp_cong_recovery_off(tcp_connection_t *tc)
timer_expiration_handler tcp_timer_delack_handler
static void tcp_session_reset(u32 conn_index, u32 thread_index)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
static u32 tcp_set_time_now(tcp_worker_ctx_t *wrk)
static clib_error_t * tcp_show_scoreboard_trace_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd_arg)
void tcp_bt_cleanup(tcp_connection_t *tc)
Byte tracker cleanup.
static tcp_connection_t * tcp_listener_get(u32 tli)
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.
#define TCP_EVT(_evt, _args...)
int tcp_session_custom_tx(void *conn, u32 max_burst_size)
static uword pool_elts(void *v)
Number of active elements in a pool.