FD.io VPP  v21.01.1
Vector Packet Processing
tcp.h File Reference
+ Include dependency graph for tcp.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tcp_wrk_stats_
 
struct  tcp_free_req_
 
struct  tcp_worker_ctx_
 
struct  tcp_iss_seed_
 
struct  tcp_configuration_
 

Macros

#define tcp_error(n, s)   TCP_ERROR_##n,
 
#define foreach_tcp_wrk_stat
 
#define tcp_worker_stats_inc(_wrk, _stat, _val)   _wrk->stats._stat += _val
 
#define tcp_cfg   tcp_main.cfg
 
#define tcp_node_index(node_id, is_ip4)   ((is_ip4) ? tcp4_##node_id##_node.index : tcp6_##node_id##_node.index)
 
#define tcp_trajectory_add_start(b, start)
 
#define tcp_validate_txf_size(_tc, _a)
 

Typedefs

typedef void() timer_expiration_handler(tcp_connection_t *tc)
 
typedef enum _tcp_error tcp_error_t
 
typedef struct _tcp_lookup_dispatch tcp_lookup_dispatch_t
 
typedef struct tcp_wrk_stats_ tcp_wrk_stats_t
 
typedef struct tcp_free_req_ tcp_cleanup_req_t
 
typedef struct tcp_worker_ctx_ tcp_worker_ctx_t
 
typedef struct tcp_iss_seed_ tcp_iss_seed_t
 
typedef struct tcp_configuration_ tcp_configuration_t
 
typedef struct _tcp_main tcp_main_t
 

Functions

static tcp_main_tvnet_get_tcp_main ()
 
static tcp_worker_ctx_ttcp_get_worker (u32 thread_index)
 
tcp_connection_ttcp_connection_alloc (u8 thread_index)
 
tcp_connection_ttcp_connection_alloc_w_base (u8 thread_index, tcp_connection_t *base)
 
void tcp_connection_free (tcp_connection_t *tc)
 
void tcp_connection_close (tcp_connection_t *tc)
 Begin connection closing procedure. More...
 
void tcp_connection_cleanup (tcp_connection_t *tc)
 Cleans up connection state. More...
 
void tcp_connection_del (tcp_connection_t *tc)
 Connection removal. More...
 
int tcp_half_open_connection_cleanup (tcp_connection_t *tc)
 Try to cleanup half-open connection. More...
 
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. More...
 
void tcp_send_reset (tcp_connection_t *tc)
 Build and set reset packet for connection. More...
 
void tcp_send_syn (tcp_connection_t *tc)
 Send SYN. More...
 
void tcp_send_synack (tcp_connection_t *tc)
 
void tcp_send_fin (tcp_connection_t *tc)
 Send FIN. More...
 
void tcp_send_ack (tcp_connection_t *tc)
 
void tcp_send_window_update_ack (tcp_connection_t *tc)
 Send window update ack. More...
 
void tcp_program_ack (tcp_connection_t *tc)
 
void tcp_program_dupack (tcp_connection_t *tc)
 
void tcp_program_retransmit (tcp_connection_t *tc)
 
void tcp_update_burst_snd_vars (tcp_connection_t *tc)
 Update burst send vars. More...
 
u32 tcp_snd_space (tcp_connection_t *tc)
 
int tcp_fastrecovery_prr_snd_space (tcp_connection_t *tc)
 Estimate send space using proportional rate reduction (RFC6937) More...
 
void tcp_reschedule (tcp_connection_t *tc)
 
fib_node_index_t tcp_lookup_rmt_in_fib (tcp_connection_t *tc)
 
u32 tcp_session_push_header (transport_connection_t *tconn, vlib_buffer_t *b)
 
int tcp_session_custom_tx (void *conn, transport_send_params_t *sp)
 
void tcp_connection_timers_init (tcp_connection_t *tc)
 Initialize all connection timers as invalid. More...
 
void tcp_connection_timers_reset (tcp_connection_t *tc)
 Stop all connection timers. More...
 
void tcp_init_snd_vars (tcp_connection_t *tc)
 Initialize connection send variables. More...
 
void tcp_connection_init_vars (tcp_connection_t *tc)
 Initialize tcp connection variables. More...
 
void tcp_connection_tx_pacer_update (tcp_connection_t *tc)
 
void tcp_connection_tx_pacer_reset (tcp_connection_t *tc, u32 window, u32 start_bucket)
 
void tcp_program_cleanup (tcp_worker_ctx_t *wrk, tcp_connection_t *tc)
 
void tcp_punt_unknown (vlib_main_t *vm, u8 is_ip4, u8 is_add)
 
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. More...
 
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. More...
 
clib_error_tvnet_tcp_enable_disable (vlib_main_t *vm, u8 is_en)
 

Variables

timer_expiration_handler tcp_timer_retransmit_handler
 
timer_expiration_handler tcp_timer_persist_handler
 
timer_expiration_handler tcp_timer_retransmit_syn_handler
 
tcp_main_t tcp_main
 
vlib_node_registration_t tcp4_input_node
 (constructor) VLIB_REGISTER_NODE (tcp4_input_node) More...
 
vlib_node_registration_t tcp6_input_node
 (constructor) VLIB_REGISTER_NODE (tcp6_input_node) More...
 
vlib_node_registration_t tcp4_output_node
 (constructor) VLIB_REGISTER_NODE (tcp4_output_node) More...
 
vlib_node_registration_t tcp6_output_node
 (constructor) VLIB_REGISTER_NODE (tcp6_output_node) More...
 
vlib_node_registration_t tcp4_established_node
 (constructor) VLIB_REGISTER_NODE (tcp4_established_node) More...
 
vlib_node_registration_t tcp6_established_node
 (constructor) VLIB_REGISTER_NODE (tcp6_established_node) More...
 
vlib_node_registration_t tcp4_syn_sent_node
 (constructor) VLIB_REGISTER_NODE (tcp4_syn_sent_node) More...
 
vlib_node_registration_t tcp6_syn_sent_node
 (constructor) VLIB_REGISTER_NODE (tcp6_syn_sent_node) More...
 
vlib_node_registration_t tcp4_rcv_process_node
 (constructor) VLIB_REGISTER_NODE (tcp4_rcv_process_node) More...
 
vlib_node_registration_t tcp6_rcv_process_node
 (constructor) VLIB_REGISTER_NODE (tcp6_rcv_process_node) More...
 
vlib_node_registration_t tcp4_listen_node
 (constructor) VLIB_REGISTER_NODE (tcp4_listen_node) More...
 
vlib_node_registration_t tcp6_listen_node
 (constructor) VLIB_REGISTER_NODE (tcp6_listen_node) More...
 
format_function_t format_tcp_state
 
format_function_t format_tcp_flags
 
format_function_t format_tcp_sacks
 
format_function_t format_tcp_rcv_sacks
 
format_function_t format_tcp_connection
 
format_function_t format_tcp_connection_id
 

Macro Definition Documentation

◆ foreach_tcp_wrk_stat

#define foreach_tcp_wrk_stat
Value:
_(timer_expirations, u64, "timer expirations") \
_(rxt_segs, u64, "segments retransmitted") \
_(tr_events, u32, "timer retransmit events") \
_(to_closewait, u32, "timeout close-wait") \
_(to_closewait2, u32, "timeout close-wait w/data") \
_(to_finwait1, u32, "timeout fin-wait-1") \
_(to_finwait2, u32, "timeout fin-wait-2") \
_(to_lastack, u32, "timeout last-ack") \
_(to_closing, u32, "timeout closing") \
_(tr_abort, u32, "timer retransmit abort") \
_(rst_unread, u32, "reset on close due to unread data") \
_(no_buffer, u32, "out of buffers") \
unsigned long u64
Definition: types.h:89
unsigned int u32
Definition: types.h:88

Definition at line 48 of file tcp.h.

◆ tcp_cfg

#define tcp_cfg   tcp_main.cfg

Definition at line 271 of file tcp.h.

◆ tcp_error

#define tcp_error (   n,
 
)    TCP_ERROR_##n,

Definition at line 37 of file tcp.h.

◆ tcp_node_index

#define tcp_node_index (   node_id,
  is_ip4 
)    ((is_ip4) ? tcp4_##node_id##_node.index : tcp6_##node_id##_node.index)

Definition at line 272 of file tcp.h.

◆ tcp_trajectory_add_start

#define tcp_trajectory_add_start (   b,
  start 
)

Definition at line 294 of file tcp.h.

◆ tcp_validate_txf_size

#define tcp_validate_txf_size (   _tc,
  _a 
)
Value:
ASSERT(_tc->state != TCP_STATE_ESTABLISHED \
|| transport_max_tx_dequeue (&_tc->connection) >= _a)
static u32 transport_max_tx_dequeue(transport_connection_t *tc)
Definition: session.h:509
#define ASSERT(truth)

Definition at line 354 of file tcp.h.

◆ tcp_worker_stats_inc

#define tcp_worker_stats_inc (   _wrk,
  _stat,
  _val 
)    _wrk->stats._stat += _val

Definition at line 125 of file tcp.h.

Typedef Documentation

◆ tcp_cleanup_req_t

◆ tcp_configuration_t

◆ tcp_error_t

typedef enum _tcp_error tcp_error_t

◆ tcp_iss_seed_t

typedef struct tcp_iss_seed_ tcp_iss_seed_t

◆ tcp_lookup_dispatch_t

typedef struct _tcp_lookup_dispatch tcp_lookup_dispatch_t

◆ tcp_main_t

typedef struct _tcp_main tcp_main_t

◆ tcp_worker_ctx_t

◆ tcp_wrk_stats_t

◆ timer_expiration_handler

typedef void() timer_expiration_handler(tcp_connection_t *tc)

Definition at line 29 of file tcp.h.

Function Documentation

◆ tcp_configure_v4_source_address_range()

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.

Parameters
vmvlib_main_t pointer
startfirst ipv4 address in the source address range
endlast ipv4 address in the source address range
table_idVRF / table ID, 0 for the default FIB
Returns
0 if all OK, else an error indication from api_errno.h

Definition at line 377 of file tcp_cli.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_configure_v6_source_address_range()

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.

Parameters
vmvlib_main_t pointer
startfirst ipv6 address in the source address range
endlast ipv6 address in the source address range
table_idVRF / table ID, 0 for the default FIB
Returns
0 if all OK, else an error indication from api_errno.h

Definition at line 464 of file tcp_cli.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_connection_alloc()

tcp_connection_t* tcp_connection_alloc ( u8  thread_index)

Definition at line 296 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_connection_alloc_w_base()

tcp_connection_t* tcp_connection_alloc_w_base ( u8  thread_index,
tcp_connection_t base 
)

Definition at line 309 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_connection_cleanup()

void tcp_connection_cleanup ( tcp_connection_t tc)

Cleans up connection state.

No notifications.

Definition at line 242 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_connection_close()

void tcp_connection_close ( tcp_connection_t tc)

Begin connection closing procedure.

If at the end the connection is not in CLOSED state, it is not removed. Instead, we rely on on TCP to advance through state machine to either 1) LAST_ACK (passive close) whereby when the last ACK is received tcp_connection_del is called. This notifies session of the delete and calls cleanup. 2) TIME_WAIT (active close) whereby after 2MSL the 2MSL timer triggers and cleanup is called.

N.B. Half-close connections are not supported

Definition at line 360 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_connection_del()

void tcp_connection_del ( tcp_connection_t tc)

Connection removal.

This should be called only once connection enters CLOSED state. Note that it notifies the session of the removal event, so if the goal is to just remove the connection, call tcp_connection_cleanup instead.

Definition at line 289 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_connection_free()

void tcp_connection_free ( tcp_connection_t tc)

Definition at line 322 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_connection_init_vars()

void tcp_connection_init_vars ( tcp_connection_t tc)

Initialize tcp connection variables.

Should be called after having received a msg from the peer, i.e., a SYN or a SYNACK, such that connection options have already been exchanged.

Definition at line 703 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_connection_timers_init()

void tcp_connection_timers_init ( tcp_connection_t tc)

Initialize all connection timers as invalid.

Definition at line 476 of file tcp.c.

+ Here is the caller graph for this function:

◆ tcp_connection_timers_reset()

void tcp_connection_timers_reset ( tcp_connection_t tc)

Stop all connection timers.

Definition at line 493 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_connection_tx_pacer_reset()

void tcp_connection_tx_pacer_reset ( tcp_connection_t tc,
u32  window,
u32  start_bucket 
)

Definition at line 1209 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_connection_tx_pacer_update()

void tcp_connection_tx_pacer_update ( tcp_connection_t tc)

Definition at line 1196 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_fastrecovery_prr_snd_space()

int tcp_fastrecovery_prr_snd_space ( tcp_connection_t tc)

Estimate send space using proportional rate reduction (RFC6937)

Definition at line 1657 of file tcp_output.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_get_worker()

static tcp_worker_ctx_t* tcp_get_worker ( u32  thread_index)
inlinestatic

Definition at line 282 of file tcp.h.

+ Here is the caller graph for this function:

◆ tcp_half_open_connection_cleanup()

int tcp_half_open_connection_cleanup ( tcp_connection_t tc)

Try to cleanup half-open connection.

If called from a thread that doesn't own tc, the call won't have any effect.

Parameters
tc- connection to be cleaned up
Returns
non-zero if cleanup failed.

Definition at line 209 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_init_snd_vars()

void tcp_init_snd_vars ( tcp_connection_t tc)

Initialize connection send variables.

Definition at line 669 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_lookup_rmt_in_fib()

fib_node_index_t tcp_lookup_rmt_in_fib ( tcp_connection_t tc)
+ Here is the caller graph for this function:

◆ tcp_program_ack()

void tcp_program_ack ( tcp_connection_t tc)

Definition at line 1043 of file tcp_output.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_program_cleanup()

void tcp_program_cleanup ( tcp_worker_ctx_t wrk,
tcp_connection_t tc 
)

Definition at line 335 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_program_dupack()

void tcp_program_dupack ( tcp_connection_t tc)

Definition at line 1053 of file tcp_output.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_program_retransmit()

void tcp_program_retransmit ( tcp_connection_t tc)

Definition at line 1065 of file tcp_output.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_punt_unknown()

void tcp_punt_unknown ( vlib_main_t vm,
u8  is_ip4,
u8  is_add 
)

Definition at line 1396 of file tcp.c.

+ Here is the caller graph for this function:

◆ tcp_reschedule()

void tcp_reschedule ( tcp_connection_t tc)

Definition at line 1220 of file tcp.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_send_ack()

void tcp_send_ack ( tcp_connection_t tc)

Definition at line 1023 of file tcp_output.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_send_fin()

void tcp_send_fin ( tcp_connection_t tc)

Send FIN.

Definition at line 873 of file tcp_output.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_send_reset()

void tcp_send_reset ( tcp_connection_t tc)

Build and set reset packet for connection.

Definition at line 749 of file tcp_output.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_send_reset_w_pkt()

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.

It extracts connection info out of original packet

Definition at line 661 of file tcp_output.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_send_syn()

void tcp_send_syn ( tcp_connection_t tc)

Send SYN.

Builds a SYN packet for a half-open connection and sends it to ipx_lookup. The packet is not forwarded through tcpx_output to avoid doing lookups in the half_open pool.

Definition at line 808 of file tcp_output.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_send_synack()

void tcp_send_synack ( tcp_connection_t tc)

Definition at line 844 of file tcp_output.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tcp_send_window_update_ack()

void tcp_send_window_update_ack ( tcp_connection_t tc)

Send window update ack.

Ensures that it will be sent only once, after a zero rwnd has been advertised in a previous ack, and only if rwnd has grown beyond a configurable value.

Definition at line 1082 of file tcp_output.c.

+ Here is the call graph for this function:

◆ tcp_session_custom_tx()

int tcp_session_custom_tx ( void *  conn,
transport_send_params_t sp 
)

Definition at line 2017 of file tcp_output.c.

+ Here is the call graph for this function:

◆ tcp_session_push_header()

u32 tcp_session_push_header ( transport_connection_t tconn,
vlib_buffer_t b 
)

Definition at line 995 of file tcp_output.c.

+ Here is the call graph for this function:

◆ tcp_snd_space()

u32 tcp_snd_space ( tcp_connection_t tc)

Definition at line 951 of file tcp.c.

+ Here is the call graph for this function:

◆ tcp_update_burst_snd_vars()

void tcp_update_burst_snd_vars ( tcp_connection_t tc)

Update burst send vars.

  • Updates snd_mss to reflect the effective segment size that we can send by taking into account all TCP options, including SACKs.
  • Cache 'on the wire' options for reuse
  • Updates receive window which can be reused for a burst.

This should only be called when doing bursts

Definition at line 300 of file tcp_output.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vnet_get_tcp_main()

static tcp_main_t* vnet_get_tcp_main ( )
inlinestatic

Definition at line 276 of file tcp.h.

+ Here is the caller graph for this function:

◆ vnet_tcp_enable_disable()

clib_error_t* vnet_tcp_enable_disable ( vlib_main_t vm,
u8  is_en 
)

Definition at line 1378 of file tcp.c.

+ Here is the call graph for this function:

Variable Documentation

◆ format_tcp_connection

format_function_t format_tcp_connection

Definition at line 351 of file tcp.h.

◆ format_tcp_connection_id

format_function_t format_tcp_connection_id

Definition at line 352 of file tcp.h.

◆ format_tcp_flags

format_function_t format_tcp_flags

Definition at line 348 of file tcp.h.

◆ format_tcp_rcv_sacks

format_function_t format_tcp_rcv_sacks

Definition at line 350 of file tcp.h.

◆ format_tcp_sacks

format_function_t format_tcp_sacks

Definition at line 349 of file tcp.h.

◆ format_tcp_state

format_function_t format_tcp_state

Definition at line 347 of file tcp.h.

◆ tcp4_established_node

vlib_node_registration_t tcp4_established_node

(constructor) VLIB_REGISTER_NODE (tcp4_established_node)

Definition at line 1573 of file tcp_input.c.

◆ tcp4_input_node

vlib_node_registration_t tcp4_input_node

(constructor) VLIB_REGISTER_NODE (tcp4_input_node)

Definition at line 3007 of file tcp_input.c.

◆ tcp4_listen_node

vlib_node_registration_t tcp4_listen_node

(constructor) VLIB_REGISTER_NODE (tcp4_listen_node)

Definition at line 2683 of file tcp_input.c.

◆ tcp4_output_node

vlib_node_registration_t tcp4_output_node

(constructor) VLIB_REGISTER_NODE (tcp4_output_node)

Definition at line 2307 of file tcp_output.c.

◆ tcp4_rcv_process_node

vlib_node_registration_t tcp4_rcv_process_node

(constructor) VLIB_REGISTER_NODE (tcp4_rcv_process_node)

Definition at line 2505 of file tcp_input.c.

◆ tcp4_syn_sent_node

vlib_node_registration_t tcp4_syn_sent_node

(constructor) VLIB_REGISTER_NODE (tcp4_syn_sent_node)

Definition at line 2059 of file tcp_input.c.

◆ tcp6_established_node

vlib_node_registration_t tcp6_established_node

(constructor) VLIB_REGISTER_NODE (tcp6_established_node)

Definition at line 1592 of file tcp_input.c.

◆ tcp6_input_node

vlib_node_registration_t tcp6_input_node

(constructor) VLIB_REGISTER_NODE (tcp6_input_node)

Definition at line 3027 of file tcp_input.c.

◆ tcp6_listen_node

vlib_node_registration_t tcp6_listen_node

(constructor) VLIB_REGISTER_NODE (tcp6_listen_node)

Definition at line 2702 of file tcp_input.c.

◆ tcp6_output_node

vlib_node_registration_t tcp6_output_node

(constructor) VLIB_REGISTER_NODE (tcp6_output_node)

Definition at line 2327 of file tcp_output.c.

◆ tcp6_rcv_process_node

vlib_node_registration_t tcp6_rcv_process_node

(constructor) VLIB_REGISTER_NODE (tcp6_rcv_process_node)

Definition at line 2524 of file tcp_input.c.

◆ tcp6_syn_sent_node

vlib_node_registration_t tcp6_syn_sent_node

(constructor) VLIB_REGISTER_NODE (tcp6_syn_sent_node)

Definition at line 2078 of file tcp_input.c.

◆ tcp_main

tcp_main_t tcp_main

Definition at line 28 of file tcp.c.

◆ tcp_timer_persist_handler

timer_expiration_handler tcp_timer_persist_handler

◆ tcp_timer_retransmit_handler

timer_expiration_handler tcp_timer_retransmit_handler

◆ tcp_timer_retransmit_syn_handler

timer_expiration_handler tcp_timer_retransmit_syn_handler