37 pool_get (tm->listener_pool, listener);
38 memset (listener, 0,
sizeof (*listener));
40 listener->c_c_index = listener - tm->listener_pool;
41 listener->c_lcl_port = lcl->port;
45 listener->c_lcl_ip4.as_u32 = lcl->ip.ip4.as_u32;
46 listener->c_is_ip4 = 1;
55 listener->c_s_index = session_index;
56 listener->state = TCP_STATE_LISTEN;
62 return listener->c_c_index;
83 memset (tc, 0xFA,
sizeof (*tc));
101 return &tc->connection;
118 pool_get (tm->local_endpoints, tep);
133 memset (tc, 0xFA,
sizeof (*tc));
164 pool_get (tm->half_open_connections, tc);
165 memset (tc, 0,
sizeof (*tc));
166 tc->c_c_index = tc - tm->half_open_connections;
184 clib_net_to_host_u16 (tc->c_lcl_port));
193 if (tc->state == TCP_STATE_SYN_SENT)
202 int thread_index = tc->c_thread_index;
209 memset (tc, 0xFA,
sizeof (*tc));
210 pool_put (tm->connections[thread_index], tc);
235 pool_get (tm->connections[thread_index], tc);
236 memset (tc, 0,
sizeof (*tc));
237 tc->c_c_index = tc - tm->connections[thread_index];
238 tc->c_thread_index = thread_index;
252 case TCP_STATE_SYN_RCVD:
257 case TCP_STATE_SYN_SENT:
261 case TCP_STATE_ESTABLISHED:
262 case TCP_STATE_CLOSE_WAIT:
263 case TCP_STATE_FIN_WAIT_1:
264 case TCP_STATE_FIN_WAIT_2:
265 case TCP_STATE_CLOSING:
266 tc->state = TCP_STATE_CLOSED;
276 case TCP_STATE_CLOSED:
302 case TCP_STATE_SYN_SENT:
303 tc->state = TCP_STATE_CLOSED;
305 case TCP_STATE_SYN_RCVD:
307 tc->state = TCP_STATE_FIN_WAIT_1;
309 case TCP_STATE_ESTABLISHED:
313 tc->flags |= TCP_CONN_FINPNDG;
314 tc->state = TCP_STATE_FIN_WAIT_1;
316 case TCP_STATE_CLOSE_WAIT:
318 tc->state = TCP_STATE_LAST_ACK;
320 case TCP_STATE_FIN_WAIT_1:
330 && tc->state == TCP_STATE_CLOSED)
349 tc->state = TCP_STATE_CLOSED;
387 #define PORT_MASK ((1 << 16)- 1) 398 u16 min = 1024, max = 65535;
407 for (tries = 0; tries < limit; tries++)
429 tep - tm->local_endpoints);
469 typedef struct ip4_tcp_hdr
475 typedef struct ip6_tcp_hdr
493 memset (&hdr, 0,
sizeof (hdr));
494 hdr.ip.protocol = IP_PROTOCOL_TCP;
495 hdr.ip.address_pair.src.as_u32 = tc->c_lcl_ip.ip4.as_u32;
496 hdr.ip.address_pair.dst.as_u32 = tc->c_rmt_ip.ip4.as_u32;
497 hdr.tcp.src_port = tc->c_lcl_port;
498 hdr.tcp.dst_port = tc->c_rmt_port;
504 memset (&hdr, 0,
sizeof (hdr));
505 hdr.ip.protocol = IP_PROTOCOL_TCP;
506 clib_memcpy (&hdr.ip.src_address, &tc->c_lcl_ip.ip6,
508 clib_memcpy (&hdr.ip.dst_address, &tc->c_rmt_ip.ip6,
510 hdr.tcp.src_port = tc->c_lcl_port;
511 hdr.tcp.dst_port = tc->c_rmt_port;
526 prefix.
fp_len = tc->c_is_ip4 ? 32 : 128;
535 u32 output_node_index;
542 tcp_connection_select_lb_bucket (tc, &fe->
fe_lb, &choice);
561 tcp_connection_stack_on_fib_entry (tc);
583 tc->snd_una = tc->iss;
584 tc->snd_nxt = tc->iss + 1;
585 tc->snd_una_max = tc->snd_nxt;
599 if (tc->state == TCP_STATE_SYN_RCVD)
612 u32 sw_if_index, fib_index;
613 ip46_address_t lcl_addr;
619 memset (&lcl_addr, 0,
sizeof (lcl_addr));
624 prefix.
fp_len = rmt->is_ip4 ? 32 : 128;
627 if (fib_index == (
u32) ~ 0)
644 if (sw_if_index == (
u32) ~ 0)
655 if (
vec_len (tm->ip4_src_addresses))
657 index = tm->last_v4_address_rotor++;
658 if (tm->last_v4_address_rotor >=
vec_len (tm->ip4_src_addresses))
659 tm->last_v4_address_rotor = 0;
660 lcl_addr.ip4.
as_u32 = tm->ip4_src_addresses[index].as_u32;
665 lcl_addr.ip4.as_u32 = ip4->
as_u32;
673 if (
vec_len (tm->ip6_src_addresses))
675 index = tm->last_v6_address_rotor++;
676 if (tm->last_v6_address_rotor >=
vec_len (tm->ip6_src_addresses))
677 tm->last_v6_address_rotor = 0;
678 clib_memcpy (&lcl_addr.ip6, &tm->ip6_src_addresses[index],
709 clib_memcpy (&tc->c_rmt_ip, &rmt->ip, sizeof (ip46_address_t));
710 clib_memcpy (&tc->c_lcl_ip, &lcl_addr, sizeof (ip46_address_t));
711 tc->c_rmt_port = rmt->port;
712 tc->c_lcl_port = clib_host_to_net_u16 (lcl_port);
713 tc->c_is_ip4 = rmt->is_ip4;
715 tc->c_vrf = rmt->vrf;
720 tc->state = TCP_STATE_SYN_SENT;
725 return tc->c_c_index;
735 #define _(sym, str) str, 741 #define _(sym, str) str, 754 s =
format (s,
"UNKNOWN (%d (0x%x))", state, state);
759 #define _(sym, str) str, 775 for (i = 0; i <
last; i++)
794 s =
format (s,
"recovery");
796 s =
format (s,
"fastrecovery");
806 s =
format (s,
" snd_una %u snd_nxt %u snd_una_max %u",
807 tc->snd_una - tc->iss, tc->snd_nxt - tc->iss,
808 tc->snd_una_max - tc->iss);
809 s =
format (s,
" rcv_nxt %u rcv_las %u\n",
810 tc->rcv_nxt - tc->irs, tc->rcv_las - tc->irs);
811 s =
format (s,
" snd_wnd %u rcv_wnd %u snd_wl1 %u snd_wl2 %u\n",
812 tc->snd_wnd, tc->rcv_wnd, tc->snd_wl1 - tc->irs,
813 tc->snd_wl2 - tc->iss);
814 s =
format (s,
" flight size %u send space %u rcv_wnd_av %d\n",
818 s =
format (s,
"cwnd %u ssthresh %u rtx_bytes %u bytes_acked %u\n",
819 tc->cwnd, tc->ssthresh, tc->snd_rxt_bytes, tc->bytes_acked);
820 s =
format (s,
" prev_ssthresh %u snd_congestion %u dupack %u",
821 tc->prev_ssthresh, tc->snd_congestion - tc->iss,
823 s =
format (s,
" limited_transmit %u\n", tc->limited_transmit - tc->iss);
824 s =
format (s,
" tsecr %u tsecr_last_ack %u\n", tc->rcv_opts.tsecr,
826 s =
format (s,
" rto %u rto_boff %u srtt %u rttvar %u rtt_ts %u ", tc->rto,
827 tc->rto_boff, tc->srtt, tc->rttvar, tc->rtt_ts);
828 s =
format (s,
"rtt_seq %u\n", tc->rtt_seq);
829 s =
format (s,
" tsval_recent %u tsval_recent_age %u\n", tc->tsval_recent,
831 if (tc->state >= TCP_STATE_ESTABLISHED)
848 s =
format (s,
"[#%d][%s] %U:%d->%U:%d", tc->c_thread_index,
"T",
851 &tc->c_rmt_ip4, clib_net_to_host_u16 (tc->c_rmt_port));
855 s =
format (s,
"[#%d][%s] %U:%d->%U:%d", tc->c_thread_index,
"T",
858 &tc->c_rmt_ip6, clib_net_to_host_u16 (tc->c_rmt_port));
868 u32 verbose = va_arg (*args,
u32);
886 u32 tci = va_arg (*args,
u32);
887 u32 thread_index = va_arg (*args,
u32);
888 u32 verbose = va_arg (*args,
u32);
895 s =
format (s,
"empty\n");
902 u32 tci = va_arg (*args,
u32);
910 u32 tci = va_arg (*args,
u32);
924 for (i = 0; i < len - 1; i++)
927 s =
format (s,
" start %u end %u\n", block->start - tc->irs,
928 block->end - tc->irs);
932 block = &sacks[len - 1];
933 s =
format (s,
" start %u end %u", block->start - tc->irs,
934 block->end - tc->irs);
948 for (i = 0; i < len - 1; i++)
951 s =
format (s,
" start %u end %u\n", block->start - tc->iss,
952 block->end - tc->iss);
956 block = &sacks[len - 1];
957 s =
format (s,
" start %u end %u", block->start - tc->iss,
958 block->end - tc->iss);
969 s =
format (s,
" [%u, %u]", hole->start - tc->iss, hole->end - tc->iss);
971 s =
format (s,
" [%u, %u]", hole->start, hole->end);
981 s =
format (s,
"sacked_bytes %u last_sacked_bytes %u lost_bytes %u\n",
982 sb->sacked_bytes, sb->last_sacked_bytes, sb->lost_bytes);
983 s =
format (s,
" last_bytes_delivered %u high_sacked %u snd_una_adv %u\n",
984 sb->last_bytes_delivered, sb->high_sacked, sb->snd_una_adv);
985 s =
format (s,
" cur_rxt_hole %u high_rxt %u rescue_rxt %u",
986 sb->cur_rxt_hole, sb->high_rxt, sb->rescue_rxt);
990 s =
format (s,
"\n head %u tail %u holes:\n", sb->head, sb->tail);
1005 return &tc->connection;
1012 return &tc->connection;
1040 return tc->snd_wnd <= snd_space ? tc->snd_wnd : 0;
1046 return snd_space < tc->cwnd ? 0 : snd_space;
1049 return snd_space - (snd_space % tc->snd_mss);
1065 int snd_space, snt_limited;
1075 && tc->sack_sb.last_sacked_bytes == 0)))
1077 if (tc->rcv_dupacks == 1 && tc->limited_transmit != tc->snd_nxt)
1078 tc->limited_transmit = tc->snd_nxt;
1081 snt_limited = tc->snd_nxt - tc->limited_transmit;
1082 snd_space =
clib_max (2 * tc->snd_mss - snt_limited, 0);
1089 tc->snd_nxt = tc->snd_una_max;
1091 - (tc->snd_una_max - tc->snd_congestion);
1092 if (snd_space <= 0 || (tc->snd_una_max - tc->snd_una) >= tc->snd_wnd)
1116 tc->snd_wnd - (tc->snd_nxt - tc->snd_una));
1122 return (
i32) tc->rcv_wnd - (tc->rcv_nxt - tc->rcv_las);
1133 return (tc->snd_nxt - tc->snd_una);
1176 ASSERT (tc->state == TCP_STATE_SYN_SENT);
1187 ASSERT (tc->state == TCP_STATE_SYN_RCVD);
1209 if (tc->state == TCP_STATE_CLOSE_WAIT)
1211 if (tc->flags & TCP_CONN_FINSNT)
1213 clib_warning (
"FIN was sent and still in CLOSE WAIT. Weird!");
1217 tc->state = TCP_STATE_LAST_ACK;
1246 u32 connection_index, timer_id;
1248 for (i = 0; i <
vec_len (expired_timers); i++)
1251 connection_index = expired_timers[
i] & 0x0FFFFFFF;
1252 timer_id = expired_timers[
i] >> 28;
1254 TCP_EVT_DBG (TCP_EVT_TIMER_POP, connection_index, timer_id);
1264 tw_timer_wheel_16t_2w_512sl_t *tw;
1267 tw = &tm->timer_wheels[ii];
1286 u32 preallocated_connections_per_thread;
1324 if (num_threads == 1)
1327 preallocated_connections_per_thread = tm->preallocated_connections;
1332 preallocated_connections_per_thread =
1333 tm->preallocated_connections / (num_threads - 1);
1335 for (; thread < num_threads; thread++)
1337 if (preallocated_connections_per_thread)
1339 preallocated_connections_per_thread);
1345 if (tm->preallocated_half_open_connections)
1347 tm->preallocated_half_open_connections);
1361 if (tm->local_endpoints_table_buckets == 0)
1362 tm->local_endpoints_table_buckets = 250000;
1363 if (tm->local_endpoints_table_memory == 0)
1364 tm->local_endpoints_table_memory = 512 << 20;
1366 clib_bihash_init_24_8 (&tm->local_endpoints_table,
"local endpoint table",
1367 tm->local_endpoints_table_buckets,
1368 tm->local_endpoints_table_memory);
1373 if (num_threads > 1)
1381 vec_validate (tm->ip_lookup_tx_frames[0], num_threads - 1);
1382 vec_validate (tm->ip_lookup_tx_frames[1], num_threads - 1);
1414 tm->punt_unknown4 = is_add;
1416 tm->punt_unknown6 = is_add;
1439 (input,
"preallocated-connections %d",
1440 &tm->preallocated_connections))
1442 else if (
unformat (input,
"preallocated-half-open-connections %d",
1443 &tm->preallocated_half_open_connections))
1445 else if (
unformat (input,
"local-endpoints-table-memory %U",
1448 if (tmp >= 0x100000000)
1451 tm->local_endpoints_table_memory = tmp;
1453 else if (
unformat (input,
"local-endpoints-table-buckets %d",
1454 &tm->local_endpoints_table_buckets))
1484 u32 start_host_byte_order, end_host_byte_order;
1495 memset (&prefix, 0,
sizeof (prefix));
1499 if (fib_index == ~0)
1500 return VNET_API_ERROR_NO_SUCH_FIB;
1502 start_host_byte_order = clib_net_to_host_u32 (start->
as_u32);
1503 end_host_byte_order = clib_net_to_host_u32 (end->
as_u32);
1506 if ((end_host_byte_order - start_host_byte_order) > (10 << 10))
1507 return VNET_API_ERROR_INVALID_ARGUMENT;
1518 return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
1536 vec_add1 (tm->ip4_src_addresses, start[0]);
1552 start_host_byte_order++;
1553 start->
as_u32 = clib_host_to_net_u32 (start_host_byte_order);
1555 while (start_host_byte_order <= end_host_byte_order);
1580 memset (&prefix, 0,
sizeof (prefix));
1584 if (fib_index == ~0)
1585 return VNET_API_ERROR_NO_SUCH_FIB;
1594 vec_add1 (tm->ip6_src_addresses, start[0]);
1605 return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
1609 if (sw_if_index == (
u32) ~ 0)
1610 return VNET_API_ERROR_NO_MATCHING_INTERFACE;
1626 if (!memcmp (start, end,
sizeof (start[0])))
1631 for (i = 15; i >= 0; i--)
1634 if (tmp.
as_u8[i] != 0)
1660 memcpy (&v4end, &v4start,
sizeof (v4start));
1668 memcpy (&v6end, &v6start,
sizeof (v6start));
1671 else if (
unformat (input,
"fib-table %d", &table_id))
1677 if (!v4set && !v6set)
1689 case VNET_API_ERROR_NO_SUCH_FIB:
1692 case VNET_API_ERROR_INVALID_ARGUMENT:
1710 case VNET_API_ERROR_NO_SUCH_FIB:
1724 .path =
"tcp src-address",
1725 .short_help =
"tcp src-address <ip-addr> [- <ip-addr>] add src address range",
1733 #if TCP_SCOREBOARD_TRACE 1741 s =
format (s,
"scoreboard trace:");
1744 s =
format (s,
"{%u, %u, %u, %u, %u}, ", block->start, block->end,
1745 block->ack, block->snd_una_max, block->group);
1787 .path =
"show tcp scoreboard trace",
1788 .short_help =
"show tcp scoreboard trace <connection>",
1798 u32 next_ack,
left, group, has_new_ack = 0;
1805 memset (dummy_tc, 0,
sizeof (*dummy_tc));
1808 dummy_tc->rcv_opts.flags |= TCP_OPTS_FLAG_SACK;
1810 #if TCP_SCOREBOARD_TRACE 1811 trace = tc->sack_sb.trace;
1812 trace_len =
vec_len (tc->sack_sb.trace);
1818 for (i = 0; i < trace_len; i++)
1820 if (trace[i].ack != 0)
1822 dummy_tc->snd_una = trace[
i].ack - 1448;
1823 dummy_tc->snd_una_max = trace[
i].ack;
1828 while (left < trace_len)
1830 group = trace[
left].group;
1833 while (trace[left].group == group)
1835 if (trace[left].ack != 0)
1838 s =
format (s,
"Adding ack %u, snd_una_max %u, segs: ",
1839 trace[left].ack, trace[left].snd_una_max);
1840 dummy_tc->snd_una_max = trace[
left].snd_una_max;
1841 next_ack = trace[
left].ack;
1847 s =
format (s,
"[%u, %u], ", trace[left].start,
1849 vec_add2 (dummy_tc->rcv_opts.sacks, block, 1);
1850 block->start = trace[
left].start;
1851 block->end = trace[
left].end;
1859 dummy_tc->snd_una = next_ack + dummy_tc->sack_sb.snd_una_adv;
1863 &dummy_tc->sack_sb);
1908 .path =
"tcp replay scoreboard",
1909 .short_help =
"tcp replay scoreboard <connection>",
1923 tm->punt_unknown4 ?
"enabled" :
"disabled");
1925 tm->punt_unknown6 ?
"enabled" :
"disabled");
1931 .path =
"show tcp punt",
1932 .short_help =
"show tcp punt",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
#define tcp_in_cong_recovery(tc)
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
void session_register_transport(transport_proto_t transport_proto, u8 is_ip4, const transport_proto_vft_t *vft)
Register transport virtual function table.
void tcp_timer_keep_handler(u32 conn_index)
sll srl srl sll sra u16x4 i
void receive_dpo_add_or_lock(dpo_proto_t proto, u32 sw_if_index, const ip46_address_t *nh_addr, dpo_id_t *dpo)
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)
u8 * format_tcp_vars(u8 *s, va_list *args)
#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)
void * ip_interface_get_first_ip(u32 sw_if_index, u8 is_ip4)
struct _scoreboard_trace_elt scoreboard_trace_elt_t
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
u8 * format_tcp_sacks(u8 *s, va_list *args)
vnet_main_t * vnet_get_main(void)
struct _transport_connection transport_connection_t
vlib_node_registration_t tcp4_output_node
(constructor) VLIB_REGISTER_NODE (tcp4_output_node)
uword unformat_transport_connection(unformat_input_t *input, va_list *args)
u32 tcp_session_unbind(u32 listener_index)
tcp_connection_t * tcp_connection_new(u8 thread_index)
u32 tcp_session_bind(u32 session_index, transport_endpoint_t *tep)
static u32 ip4_compute_flow_hash(const ip4_header_t *ip, flow_hash_config_t flow_hash_config)
struct _sack_scoreboard sack_scoreboard_t
static f64 vlib_time_now(vlib_main_t *vm)
static tcp_connection_t * tcp_half_open_connection_get(u32 conn_index)
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
struct _transport_proto_vft transport_proto_vft_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 void scoreboard_init(sack_scoreboard_t *sb)
static heap_elt_t * last(heap_header_t *h)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
int ip6_neighbor_proxy_add_del(u32 sw_if_index, ip6_address_t *addr, u8 is_del)
ip_lookup_main_t lookup_main
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
struct _tcp_connection tcp_connection_t
static u32 tcp_available_snd_wnd(const tcp_connection_t *tc)
transport_connection_t * tcp_half_open_session_get_transport(u32 conn_index)
static tcp_connection_t * tcp_get_connection_from_transport(transport_connection_t *tconn)
pthread_t thread[MAX_THREADS]
void tcp_timer_establish_handler(u32 conn_index)
void ip4_register_protocol(u32 protocol, u32 node_index)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
struct _tcp_header tcp_header_t
u32 transport_endpoint_lookup(transport_endpoint_table_t *ht, ip46_address_t *ip, u16 port)
int tcp_half_open_connection_cleanup(tcp_connection_t *tc)
Try to cleanup half-open connection.
format_function_t format_vnet_sw_if_index_name
struct _sack_scoreboard_hole sack_scoreboard_hole_t
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
u32 tcp_session_tx_fifo_offset(transport_connection_t *trans_conn)
unformat_function_t * unformat_pg_edit
void transport_endpoint_table_add(transport_endpoint_table_t *ht, transport_endpoint_t *te, u32 value)
#define VNET_SW_INTERFACE_FLAG_PROXY_ARP
void tcp_init_snd_vars(tcp_connection_t *tc)
Initialize connection send variables.
u8 * format_tcp_connection_id(u8 *s, va_list *args)
#define VLIB_INIT_FUNCTION(x)
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)
clib_error_t * tcp_main_enable(vlib_main_t *vm)
Aggregrate type for a prefix.
#define clib_error_return(e, args...)
int tcp_connection_open(transport_endpoint_t *rmt)
void stream_session_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
static u8 * tcp_scoreboard_dump_trace(u8 *s, sack_scoreboard_t *sb)
timer_expiration_handler tcp_timer_retransmit_syn_handler
static u32 tcp_time_now(void)
u32 tcp_snd_space(tcp_connection_t *tc)
Compute tx window session is allowed to fill.
void tcp_half_open_connection_del(tcp_connection_t *tc)
Cleanup half-open connection.
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
#define TRANSPORT_ENDPOINT_INVALID_INDEX
u16 fp_len
The mask length.
#define vlib_call_init_function(vm, x)
tcp_connection_t * tcp_half_open_connection_new(void)
void tcp_api_reference(void)
#define TCP_EVT_DBG(_evt, _args...)
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 void clib_spinlock_init(clib_spinlock_t *p)
static void tcp_timer_set(tcp_connection_t *tc, u8 timer_id, u32 interval)
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...
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
transport_connection_t * tcp_session_get_listener(u32 listener_index)
timer_expiration_handler tcp_timer_persist_handler
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.
static transport_endpoint_t * transport_endpoint_new(void)
dpo_type_t dpoi_type
the type
format_function_t * format_header
void transport_endpoint_table_del(transport_endpoint_table_t *ht, transport_endpoint_t *te)
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)
void tcp_session_cleanup(u32 conn_index, u32 thread_index)
void tcp_send_syn(tcp_connection_t *tc)
Send SYN.
static sack_scoreboard_hole_t * scoreboard_next_hole(sack_scoreboard_t *sb, sack_scoreboard_hole_t *hole)
load-balancing over a choice of [un]equal cost paths
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
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)
#define TCP_TIMER_HANDLE_INVALID
void tcp_timer_waitclose_handler(u32 conn_index)
static u32 tcp_flight_size(const tcp_connection_t *tc)
Our estimate of the number of bytes in flight (pipe size)
u8 * format_tcp_congestion_status(u8 *s, va_list *args)
#define VLIB_CONFIG_FUNCTION(x, n,...)
static u32 vlib_buffer_free_list_buffer_size(vlib_main_t *vm, u32 free_list_index)
u8 * format_tcp_scoreboard(u8 *s, va_list *args)
clib_error_t * vnet_tcp_enable_disable(vlib_main_t *vm, u8 is_en)
u32 tcp_push_header(transport_connection_t *tconn, vlib_buffer_t *b)
void tcp_session_close(u32 conn_index, u32 thread_index)
void( timer_expiration_handler)(u32 index)
#define foreach_vlib_main(body)
#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)
static sack_scoreboard_hole_t * scoreboard_first_hole(sack_scoreboard_t *sb)
#define tcp_fastrecovery_sent_1_smss(tc)
u8 * format_tcp_half_open_session(u8 *s, va_list *args)
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)
void tcp_cc_init(tcp_connection_t *tc)
int stream_session_connect_notify(transport_connection_t *tc, u8 is_fail)
u32 stream_session_tx_fifo_max_dequeue(transport_connection_t *tc)
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.
#define clib_warning(format, args...)
#define clib_memcpy(a, b, c)
u8 * format_tcp_session(u8 *s, va_list *args)
const char * tcp_dbg_evt_str[]
u32 fib_node_index_t
A typedef of a node index.
vlib_node_registration_t tcp6_input_node
(constructor) VLIB_REGISTER_NODE (tcp6_input_node)
u16 tcp_session_send_mss(transport_connection_t *trans_conn)
Compute maximum segment size for session layer.
fib_node_index_t tcp_lookup_rmt_in_fib(tcp_connection_t *tc)
fib_entry_t * fib_entry_get(fib_node_index_t index)
int vnet_proxy_arp_add_del(ip4_address_t *lo_addr, ip4_address_t *hi_addr, u32 fib_index, int is_del)
#define pool_init_fixed(pool, max_elts)
initialize a fixed-size, preallocated pool
#define VLIB_CLI_COMMAND(x,...)
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.
ip_lookup_main_t lookup_main
static clib_error_t * tcp_scoreboard_trace_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd_arg)
static load_balance_t * load_balance_get(index_t lbi)
#define seq_geq(_s1, _s2)
vhost_vring_state_t state
static void transport_endpoint_del(u32 tepi)
void stream_session_reset_notify(transport_connection_t *tc)
Notify application that connection has been reset.
From the control plane API.
i32 tcp_rcv_wnd_available(tcp_connection_t *tc)
u8 * tcp_scoreboard_replay(u8 *s, tcp_connection_t *tc, u8 verbose)
clib_error_t * ip4_lookup_init(vlib_main_t *vm)
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.
u8 * format_tcp_timers(u8 *s, va_list *args)
dpo_id_t fe_lb
The load-balance used for forwarding.
static const transport_proto_vft_t tcp_proto
void tcp_update_snd_mss(tcp_connection_t *tc)
Update snd_mss to reflect the effective segment size that we can send by taking into account all TCP ...
void tcp_punt_unknown(vlib_main_t *vm, u8 is_ip4, u8 is_add)
#define tcp_fastrecovery_1_smss_on(tc)
int tcp_session_open(transport_endpoint_t *tep)
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)
index_t dpoi_index
the index of objects of that type
#define FIB_NODE_INDEX_INVALID
static uword ip6_address_is_link_local_unicast(ip6_address_t *a)
#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_timer
TCP timers.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static u32 tcp_set_time_now(u32 thread_index)
static u32 tcp_round_snd_space(tcp_connection_t *tc, u32 snd_space)
struct _transport_endpoint transport_endpoint_t
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[]
clib_error_t * tcp_init(vlib_main_t *vm)
u8 * format_tcp_connection(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
ip4_main_t ip4_main
Global ip4 main structure.
static vlib_thread_main_t * vlib_get_thread_main()
void tcp_connection_cleanup(tcp_connection_t *tc)
Cleans up connection state.
void tcp_connection_del(tcp_connection_t *tc)
Connection removal.
void tcp_init_mss(tcp_connection_t *tc)
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
#define vec_foreach(var, vec)
Vector iterator.
u8 * format_tcp_sack_hole(u8 *s, va_list *args)
#define TCP_TSTAMP_RESOLUTION
Time stamp resolution.
#define tcp_opts_sack_permitted(_to)
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
u8 * format_tcp_state(u8 *s, va_list *args)
u32 tcp_session_send_space(transport_connection_t *trans_conn)
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 tcp_main_t * vnet_get_tcp_main()
timer_expiration_handler tcp_timer_delack_handler
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
transport_connection_t * tcp_session_get_transport(u32 conn_index, u32 thread_index)
static clib_error_t * tcp_show_scoreboard_trace_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd_arg)
u8 * format_tcp_listener_session(u8 *s, va_list *args)
void tcp_initialize_timer_wheels(tcp_main_t *tm)
static tcp_connection_t * tcp_listener_get(u32 tli)
int tcp_allocate_local_port(ip46_address_t *ip)
Allocate local port and add if successful add entry to local endpoint table to mark the pair as used...