FD.io VPP  v17.04-9-g99c0734
Vector Packet Processing
tcp_output.c File Reference
+ Include dependency graph for tcp_output.c:

Go to the source code of this file.

Data Structures

struct  tcp_tx_trace_t
 

Macros

#define foreach_tcp4_output_next
 
#define foreach_tcp6_output_next
 
#define tcp_error(n, s)   s,
 
#define tcp_get_free_buffer_index(tm, bidx)
 
#define foreach_tcp4_reset_next
 
#define foreach_tcp6_reset_next
 

Typedefs

typedef enum _tcp_output_nect tcp_output_next_t
 
typedef enum _tcp_reset_next tcp_reset_next_t
 

Functions

u8format_tcp_tx_trace (u8 *s, va_list *args)
 
void tcp_set_snd_mss (tcp_connection_t *tc)
 
static u8 tcp_window_compute_scale (u32 available_space)
 
static u32 tcp_initial_wnd_unscaled (tcp_connection_t *tc)
 TCP's IW as recommended by RFC6928. More...
 
u32 tcp_initial_window_to_advertise (tcp_connection_t *tc)
 Compute initial window and scale factor. More...
 
u32 tcp_window_to_advertise (tcp_connection_t *tc, tcp_state_t state)
 Compute and return window to advertise, scaled as per RFC1323. More...
 
u32 tcp_options_write (u8 *data, tcp_options_t *opts)
 Write TCP options to segment. More...
 
static int tcp_make_syn_options (tcp_options_t *opts, u8 wnd_scale)
 
static int tcp_make_synack_options (tcp_connection_t *tc, tcp_options_t *opts)
 
static int tcp_make_established_options (tcp_connection_t *tc, tcp_options_t *opts)
 
static int tcp_make_options (tcp_connection_t *tc, tcp_options_t *opts, tcp_state_t state)
 
static void tcp_reuse_buffer (vlib_main_t *vm, vlib_buffer_t *b)
 
void tcp_make_ack_i (tcp_connection_t *tc, vlib_buffer_t *b, tcp_state_t state, u8 flags)
 Prepare ACK. More...
 
void tcp_make_ack (tcp_connection_t *tc, vlib_buffer_t *b)
 Convert buffer to ACK. More...
 
void tcp_make_fin (tcp_connection_t *tc, vlib_buffer_t *b)
 Convert buffer to FIN-ACK. More...
 
void tcp_make_synack (tcp_connection_t *tc, vlib_buffer_t *b)
 Convert buffer to SYN-ACK. More...
 
static void tcp_enqueue_to_ip_lookup (vlib_main_t *vm, vlib_buffer_t *b, u32 bi, u8 is_ip4)
 
int tcp_make_reset_in_place (vlib_main_t *vm, vlib_buffer_t *b0, tcp_state_t state, u32 my_thread_index, u8 is_ip4)
 
void tcp_send_reset (vlib_buffer_t *pkt, u8 is_ip4)
 Send reset without reusing existing buffer. More...
 
void tcp_push_ip_hdr (tcp_main_t *tm, tcp_connection_t *tc, vlib_buffer_t *b)
 
void tcp_send_syn (tcp_connection_t *tc)
 Send SYN. More...
 
static void tcp_enqueue_to_output (vlib_main_t *vm, vlib_buffer_t *b, u32 bi, u8 is_ip4)
 
void tcp_send_fin (tcp_connection_t *tc)
 Send FIN. More...
 
static u8 tcp_make_state_flags (tcp_state_t next_state)
 
static void tcp_push_hdr_i (tcp_connection_t *tc, vlib_buffer_t *b, tcp_state_t next_state)
 Push TCP header and update connection variables. More...
 
void tcp_timer_delack_handler (u32 index)
 
u32 tcp_prepare_retransmit_segment (tcp_connection_t *tc, vlib_buffer_t *b, u32 max_bytes)
 Build a retransmit segment. More...
 
static void tcp_timer_retransmit_handler_i (u32 index, u8 is_syn)
 
void tcp_timer_retransmit_handler (u32 index)
 
void tcp_timer_retransmit_syn_handler (u32 index)
 
void tcp_retransmit_first_unacked (tcp_connection_t *tc)
 Retansmit first unacked segment. More...
 
void tcp_fast_retransmit (tcp_connection_t *tc)
 
static u32 tcp_session_has_ooo_data (tcp_connection_t *tc)
 
static uword tcp46_output_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip4)
 
static uword tcp4_output (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
 
static uword tcp6_output (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
 
 VLIB_NODE_FUNCTION_MULTIARCH (tcp4_output_node, tcp4_output)
 
 VLIB_NODE_FUNCTION_MULTIARCH (tcp6_output_node, tcp6_output)
 
u32 tcp_push_header (transport_connection_t *tconn, vlib_buffer_t *b)
 
static uword tcp46_send_reset_inline (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u8 is_ip4)
 
static uword tcp4_send_reset (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
 
static uword tcp6_send_reset (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
 
 VLIB_NODE_FUNCTION_MULTIARCH (tcp4_reset_node, tcp4_send_reset)
 
 VLIB_NODE_FUNCTION_MULTIARCH (tcp6_reset_node, tcp6_send_reset)
 

Variables

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...
 
static char * tcp_error_strings []
 
u16 dummy_mtu = 400
 
vlib_node_registration_t tcp4_reset_node
 (constructor) VLIB_REGISTER_NODE (tcp4_reset_node) More...
 
vlib_node_registration_t tcp6_reset_node
 (constructor) VLIB_REGISTER_NODE (tcp6_reset_node) More...
 

Macro Definition Documentation

#define foreach_tcp4_output_next
Value:
_ (DROP, "error-drop") \
_ (IP_LOOKUP, "ip4-lookup")
DROP
Definition: error.def:41

Definition at line 29 of file tcp_output.c.

#define foreach_tcp4_reset_next
Value:
_(DROP, "error-drop") \
_(IP_LOOKUP, "ip4-lookup")
DROP
Definition: error.def:41

Definition at line 1352 of file tcp_output.c.

#define foreach_tcp6_output_next
Value:
_ (DROP, "error-drop") \
_ (IP_LOOKUP, "ip6-lookup")
DROP
Definition: error.def:41

Definition at line 33 of file tcp_output.c.

#define foreach_tcp6_reset_next
Value:
_(DROP, "error-drop") \
_(IP_LOOKUP, "ip6-lookup")
DROP
Definition: error.def:41

Definition at line 1356 of file tcp_output.c.

#define tcp_error (   n,
 
)    s,
#define tcp_get_free_buffer_index (   tm,
  bidx 
)
Value:
do { \
u32 *my_tx_buffers, n_free_buffers; \
u32 cpu_index = tm->vlib_main->cpu_index; \
my_tx_buffers = tm->tx_buffers[cpu_index]; \
if (PREDICT_FALSE(vec_len (my_tx_buffers) == 0)) \
{ \
n_free_buffers = 32; /* TODO config or macro */ \
vec_validate (my_tx_buffers, n_free_buffers - 1); \
_vec_len(my_tx_buffers) = vlib_buffer_alloc_from_free_list ( \
tm->vlib_main, my_tx_buffers, n_free_buffers, \
tm->tx_buffers[cpu_index] = my_tx_buffers; \
} \
/* buffer shortage */ \
if (PREDICT_FALSE (vec_len (my_tx_buffers) == 0)) \
return; \
*bidx = my_tx_buffers[_vec_len (my_tx_buffers)-1]; \
_vec_len (my_tx_buffers) -= 1; \
} while (0)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:436
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
Definition: buffer.h:390
#define PREDICT_FALSE(x)
Definition: clib.h:97
static u32 vlib_buffer_alloc_from_free_list(vlib_main_t *vm, u32 *buffers, u32 n_buffers, u32 free_list_index)
Allocate buffers from specific freelist into supplied array.
Definition: buffer_funcs.h:269
unsigned int u32
Definition: types.h:88
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)

Definition at line 363 of file tcp_output.c.

Typedef Documentation

typedef enum _tcp_output_nect tcp_output_next_t
typedef enum _tcp_reset_next tcp_reset_next_t

Function Documentation

u8* format_tcp_tx_trace ( u8 s,
va_list *  args 
)

Definition at line 53 of file tcp_output.c.

+ Here is the call graph for this function:

static uword tcp46_output_inline ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t from_frame,
int  is_ip4 
)
inlinestatic

Definition at line 1143 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uword tcp46_send_reset_inline ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t from_frame,
u8  is_ip4 
)
static

Definition at line 1361 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uword tcp4_output ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t from_frame 
)
static

Definition at line 1279 of file tcp_output.c.

+ Here is the call graph for this function:

static uword tcp4_send_reset ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t from_frame 
)
static

Definition at line 1422 of file tcp_output.c.

+ Here is the call graph for this function:

static uword tcp6_output ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t from_frame 
)
static

Definition at line 1286 of file tcp_output.c.

+ Here is the call graph for this function:

static uword tcp6_send_reset ( vlib_main_t vm,
vlib_node_runtime_t node,
vlib_frame_t from_frame 
)
static

Definition at line 1429 of file tcp_output.c.

+ Here is the call graph for this function:

static void tcp_enqueue_to_ip_lookup ( vlib_main_t vm,
vlib_buffer_t b,
u32  bi,
u8  is_ip4 
)
inlinestatic

Definition at line 510 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void tcp_enqueue_to_output ( vlib_main_t vm,
vlib_buffer_t b,
u32  bi,
u8  is_ip4 
)
inlinestatic

Definition at line 788 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void tcp_fast_retransmit ( tcp_connection_t tc)

Definition at line 1098 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 tcp_initial_window_to_advertise ( tcp_connection_t tc)

Compute initial window and scale factor.

As per RFC1323, window field in SYN and SYN-ACK segments is never scaled.

Definition at line 107 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 tcp_initial_wnd_unscaled ( tcp_connection_t tc)
inlinestatic

TCP's IW as recommended by RFC6928.

Definition at line 97 of file tcp_output.c.

+ Here is the caller graph for this function:

void tcp_make_ack ( tcp_connection_t tc,
vlib_buffer_t b 
)

Convert buffer to ACK.

Definition at line 433 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void tcp_make_ack_i ( tcp_connection_t tc,
vlib_buffer_t b,
tcp_state_t  state,
u8  flags 
)

Prepare ACK.

Definition at line 406 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int tcp_make_established_options ( tcp_connection_t tc,
tcp_options_t opts 
)
inlinestatic

Definition at line 315 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void tcp_make_fin ( tcp_connection_t tc,
vlib_buffer_t b 
)

Convert buffer to FIN-ACK.

Definition at line 447 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int tcp_make_options ( tcp_connection_t tc,
tcp_options_t opts,
tcp_state_t  state 
)
inlinestatic

Definition at line 345 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int tcp_make_reset_in_place ( vlib_main_t vm,
vlib_buffer_t b0,
tcp_state_t  state,
u32  my_thread_index,
u8  is_ip4 
)

Definition at line 534 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u8 tcp_make_state_flags ( tcp_state_t  next_state)
inlinestatic

Definition at line 831 of file tcp_output.c.

+ Here is the caller graph for this function:

static int tcp_make_syn_options ( tcp_options_t opts,
u8  wnd_scale 
)
inlinestatic

Definition at line 254 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void tcp_make_synack ( tcp_connection_t tc,
vlib_buffer_t b 
)

Convert buffer to SYN-ACK.

Definition at line 468 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int tcp_make_synack_options ( tcp_connection_t tc,
tcp_options_t opts 
)
inlinestatic

Definition at line 280 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 tcp_options_write ( u8 data,
tcp_options_t opts 
)

Write TCP options to segment.

Definition at line 171 of file tcp_output.c.

+ Here is the caller graph for this function:

u32 tcp_prepare_retransmit_segment ( tcp_connection_t tc,
vlib_buffer_t b,
u32  max_bytes 
)

Build a retransmit segment.

Returns
the number of bytes in the segment or 0 if there's nothing to retransmit

Definition at line 922 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void tcp_push_hdr_i ( tcp_connection_t tc,
vlib_buffer_t b,
tcp_state_t  next_state 
)
static

Push TCP header and update connection variables.

Definition at line 854 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 tcp_push_header ( transport_connection_t tconn,
vlib_buffer_t b 
)

Definition at line 1336 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void tcp_push_ip_hdr ( tcp_main_t tm,
tcp_connection_t tc,
vlib_buffer_t b 
)

Definition at line 702 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void tcp_retransmit_first_unacked ( tcp_connection_t tc)

Retansmit first unacked segment.

Definition at line 1077 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void tcp_reuse_buffer ( vlib_main_t vm,
vlib_buffer_t b 
)
inlinestatic

Definition at line 385 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void tcp_send_fin ( tcp_connection_t tc)

Send FIN.

Definition at line 811 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void tcp_send_reset ( vlib_buffer_t pkt,
u8  is_ip4 
)

Send reset without reusing existing buffer.

Definition at line 629 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 734 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static u32 tcp_session_has_ooo_data ( tcp_connection_t tc)
inlinestatic

Definition at line 1135 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void tcp_set_snd_mss ( tcp_connection_t tc)

Definition at line 64 of file tcp_output.c.

+ Here is the caller graph for this function:

void tcp_timer_delack_handler ( u32  index)

Definition at line 892 of file tcp_output.c.

+ Here is the call graph for this function:

void tcp_timer_retransmit_handler ( u32  index)

Definition at line 1063 of file tcp_output.c.

+ Here is the call graph for this function:

static void tcp_timer_retransmit_handler_i ( u32  index,
u8  is_syn 
)
static

Definition at line 968 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void tcp_timer_retransmit_syn_handler ( u32  index)

Definition at line 1069 of file tcp_output.c.

+ Here is the call graph for this function:

static u8 tcp_window_compute_scale ( u32  available_space)
static

Definition at line 84 of file tcp_output.c.

+ Here is the caller graph for this function:

u32 tcp_window_to_advertise ( tcp_connection_t tc,
tcp_state_t  state 
)

Compute and return window to advertise, scaled as per RFC1323.

Definition at line 126 of file tcp_output.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VLIB_NODE_FUNCTION_MULTIARCH ( tcp4_output_node  ,
tcp4_output   
)
VLIB_NODE_FUNCTION_MULTIARCH ( tcp6_output_node  ,
tcp6_output   
)
VLIB_NODE_FUNCTION_MULTIARCH ( tcp4_reset_node  ,
tcp4_send_reset   
)
VLIB_NODE_FUNCTION_MULTIARCH ( tcp6_reset_node  ,
tcp6_send_reset   
)

Variable Documentation

u16 dummy_mtu = 400

Definition at line 50 of file tcp_output.c.

vlib_node_registration_t tcp4_output_node
Initial value:
=
{
.function = tcp4_output,.name = "tcp4-output",
.vector_size = sizeof (u32),
.n_errors = TCP_N_ERROR,
.error_strings = tcp_error_strings,
.n_next_nodes = TCP_OUTPUT_N_NEXT,
.next_nodes = {
#define _(s,n)
},
.format_buffer = format_tcp_header,
.format_trace = format_tcp_tx_trace,
}
u8 * format_tcp_tx_trace(u8 *s, va_list *args)
Definition: tcp_output.c:53
#define foreach_tcp4_output_next
Definition: tcp_output.c:29
format_function_t format_tcp_header
Definition: format.h:102
unsigned int u32
Definition: types.h:88
static char * tcp_error_strings[]
Definition: tcp_output.c:37
static uword tcp4_output(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: tcp_output.c:1279

(constructor) VLIB_REGISTER_NODE (tcp4_output_node)

Definition at line 19 of file tcp_output.c.

vlib_node_registration_t tcp4_reset_node
Initial value:
= {
.function = tcp4_send_reset,
.name = "tcp4-reset",
.vector_size = sizeof (u32),
.n_errors = TCP_N_ERROR,
.error_strings = tcp_error_strings,
.n_next_nodes = TCP_RESET_N_NEXT,
.next_nodes = {
#define _(s,n)
},
}
static uword tcp4_send_reset(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: tcp_output.c:1422
#define foreach_tcp4_reset_next
Definition: tcp_output.c:1352
unsigned int u32
Definition: types.h:88
static char * tcp_error_strings[]
Definition: tcp_output.c:37

(constructor) VLIB_REGISTER_NODE (tcp4_reset_node)

Definition at line 1436 of file tcp_output.c.

vlib_node_registration_t tcp6_output_node
Initial value:
=
{
.function = tcp6_output,
.name = "tcp6-output",
.vector_size = sizeof (u32),
.n_errors = TCP_N_ERROR,
.error_strings = tcp_error_strings,
.n_next_nodes = TCP_OUTPUT_N_NEXT,
.next_nodes = {
#define _(s,n)
},
.format_buffer = format_tcp_header,
.format_trace = format_tcp_tx_trace,
}
u8 * format_tcp_tx_trace(u8 *s, va_list *args)
Definition: tcp_output.c:53
#define foreach_tcp6_output_next
Definition: tcp_output.c:33
format_function_t format_tcp_header
Definition: format.h:102
unsigned int u32
Definition: types.h:88
static uword tcp6_output(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: tcp_output.c:1286
static char * tcp_error_strings[]
Definition: tcp_output.c:37

(constructor) VLIB_REGISTER_NODE (tcp6_output_node)

Definition at line 20 of file tcp_output.c.

vlib_node_registration_t tcp6_reset_node
Initial value:
= {
.function = tcp6_send_reset,
.name = "tcp6-reset",
.vector_size = sizeof (u32),
.n_errors = TCP_N_ERROR,
.error_strings = tcp_error_strings,
.n_next_nodes = TCP_RESET_N_NEXT,
.next_nodes = {
#define _(s,n)
},
}
unsigned int u32
Definition: types.h:88
static uword tcp6_send_reset(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: tcp_output.c:1429
#define foreach_tcp6_reset_next
Definition: tcp_output.c:1356
static char * tcp_error_strings[]
Definition: tcp_output.c:37

(constructor) VLIB_REGISTER_NODE (tcp6_reset_node)

Definition at line 1454 of file tcp_output.c.

char* tcp_error_strings[]
static
Initial value:
= {
#define tcp_error(n,s)
}

Definition at line 37 of file tcp_output.c.