|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
16 #ifndef SRC_VNET_TCP_TCP_INLINES_H_
17 #define SRC_VNET_TCP_TCP_INLINES_H_
54 TCP_EVT (TCP_EVT_STATE_CHANGE, tc);
79 return tc->sack_sb.sacked_bytes + tc->sack_sb.lost_bytes;
81 return clib_min (tc->rcv_dupacks * tc->snd_mss,
82 tc->snd_nxt - tc->snd_una);
93 flight_size = (int) (tc->snd_nxt - tc->snd_una) -
tcp_bytes_out (tc)
94 + tc->snd_rxt_bytes - tc->rxt_delivered;
107 if (
tcp_cfg.initial_cwnd_multiplier > 0)
108 return tcp_cfg.initial_cwnd_multiplier * tc->snd_mss;
110 if (tc->snd_mss > 2190)
111 return 2 * tc->snd_mss;
112 else if (tc->snd_mss > 1095)
113 return 3 * tc->snd_mss;
115 return 4 * tc->snd_mss;
127 tc->cwnd_acc_bytes += bytes;
128 if (tc->cwnd_acc_bytes >= thresh)
130 u32 inc = tc->cwnd_acc_bytes / thresh;
131 tc->cwnd_acc_bytes -= inc * thresh;
132 tc->cwnd += inc * tc->snd_mss;
133 tc->cwnd =
clib_min (tc->cwnd, tc->tx_fifo_size);
147 return clib_min (tc->cwnd, tc->snd_wnd);
154 int flight_size = (int) (tc->snd_nxt - tc->snd_una);
156 if (available_wnd <= flight_size)
159 return available_wnd - flight_size;
171 if (available_wnd <= flight_size)
174 return available_wnd - flight_size;
180 if ((tc->flags & TCP_CONN_FINSNT) && (tc->snd_nxt - tc->snd_una == 1))
200 return (
tcp_main.wrk_ctx[tc->c_thread_index].time_tstamp -
201 tc->timestamp_delta);
232 u8 is_ip4,
u8 is_nolookup)
235 int n_advance_bytes, n_data_bytes;
246 *
error = TCP_ERROR_LENGTH;
252 n_data_bytes = clib_net_to_host_u16 (
ip4->length) - n_advance_bytes;
257 *
error = TCP_ERROR_LENGTH;
263 &
ip4->src_address, tcp->dst_port,
273 *
error = TCP_ERROR_LENGTH;
279 n_data_bytes = clib_net_to_host_u16 (
ip6->payload_length)
281 n_advance_bytes +=
sizeof (
ip6[0]);
285 *
error = TCP_ERROR_LENGTH;
295 fib_index =
vec_elt (
im->fib_index_by_sw_if_index,
301 tcp->dst_port, tcp->src_port,
310 tcp.connection_index,
313 vnet_buffer (
b)->tcp.seq_number = clib_net_to_host_u32 (tcp->seq_number);
314 vnet_buffer (
b)->tcp.ack_number = clib_net_to_host_u32 (tcp->ack_number);
320 *
error = result ? TCP_ERROR_NONE + result : *
error;
337 tc->c_lcl_port = th->dst_port;
338 tc->c_rmt_port = th->src_port;
339 tc->c_is_ip4 = is_ip4;
344 tc->c_lcl_ip4.as_u32 =
ip4->dst_address.as_u32;
345 tc->c_rmt_ip4.as_u32 =
ip4->src_address.as_u32;
351 sizeof (ip6_address_t));
353 sizeof (ip6_address_t));
358 tc->rcv_las = tc->rcv_nxt;
367 tc->tsval_recent = tc->rcv_opts.tsval;
372 tc->snd_wscale = tc->rcv_opts.wscale;
374 tc->snd_wnd = clib_net_to_host_u16 (th->window) << tc->snd_wscale;
416 th->seq_number = seq;
417 th->ack_number = ack;
418 th->data_offset_and_reserved = (tcp_hdr_opts_len >> 2) << 4;
422 th->urgent_pointer = 0;
424 b->
flags |= VNET_BUFFER_F_L4_HDR_OFFSET_VALID;
447 clib_host_to_net_u32 (seq),
448 clib_host_to_net_u32 (ack),
449 tcp_hdr_opts_len,
flags,
450 clib_host_to_net_u16 (wnd));
static uword ip6_address_is_link_local_unicast(const ip6_address_t *a)
vnet_interface_main_t * im
static int tcp_header_bytes(tcp_header_t *t)
static tcp_connection_t * tcp_half_open_connection_get(u32 conn_index)
#define tcp_opts_tstamp(_to)
transport_connection_t * session_lookup_connection_wt4(u32 fib_index, ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 thread_index, u8 *result)
Lookup connection with ip4 and transport layer information.
static void tcp_set_time_now(tcp_worker_ctx_t *wrk, f64 now)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static u32 tcp_initial_cwnd(const tcp_connection_t *tc)
Initial cwnd as per RFC5681.
struct _tcp_header tcp_header_t
static u32 tcp_available_output_snd_space(const tcp_connection_t *tc)
struct _tcp_connection tcp_connection_t
static tcp_connection_t * tcp_listener_get(u32 tli)
static tcp_worker_ctx_t * tcp_get_worker(u32 thread_index)
static u32 tcp_bytes_out(const tcp_connection_t *tc)
Our estimate of the number of bytes that have left the network.
static u32 tcp_time_tstamp(u32 thread_index)
Time used to generate timestamps, not the timestamp.
vl_api_dhcp_client_state_t state
static u8 tcp_is_lost_fin(tcp_connection_t *tc)
struct _transport_connection transport_connection_t
static void * ip6_next_header(ip6_header_t *i)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
static u32 tcp_loss_wnd(const tcp_connection_t *tc)
static tcp_connection_t * tcp_input_lookup_buffer(vlib_buffer_t *b, u8 thread_index, u32 *error, u8 is_ip4, u8 is_nolookup)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
#define vec_elt(v, i)
Get vector value at index i.
enum _tcp_state tcp_state_t
static void tcp_update_rto(tcp_connection_t *tc)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define TCP_TSTP_HZ
Timestamp freq.
#define tcp_opts_wscale(_to)
static tcp_connection_t * tcp_connection_get_if_valid(u32 conn_index, u32 thread_index)
static void tcp_connection_set_state(tcp_connection_t *tc, tcp_state_t state)
static u32 tcp_available_snd_wnd(const tcp_connection_t *tc)
static void * vlib_buffer_push_tcp_net_order(vlib_buffer_t *b, u16 sp, u16 dp, u32 seq, u32 ack, u8 tcp_hdr_opts_len, u8 flags, u16 wnd)
Push TCP header to buffer.
#define tcp_opts_sack_permitted(_to)
#define TCP_EVT(_evt, _args...)
static u32 tcp_tstamp(tcp_connection_t *tc)
Generate timestamp for tcp connection.
void transport_update_pacer_time(u32 thread_index, clib_time_type_t now)
Request pacer time update.
static void tcp_init_w_buffer(tcp_connection_t *tc, vlib_buffer_t *b, u8 is_ip4)
Initialize connection by gleaning network and rcv params from buffer.
u16 current_length
Nbytes between current data and the end of this buffer.
static f64 tcp_time_now_us(u32 thread_index)
static tcp_header_t * tcp_buffer_hdr(vlib_buffer_t *b)
static void * vlib_buffer_push_uninit(vlib_buffer_t *b, u8 size)
Prepend uninitialized data to buffer.
transport_connection_t * session_lookup_connection_wt6(u32 fib_index, ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 thread_index, u8 *result)
Lookup connection with ip6 and transport layer information.
#define VLIB_BUFFER_PRE_DATA_SIZE
static tcp_connection_t * tcp_connection_get(u32 conn_index, u32 thread_index)
vlib_main_t * vm
Convenience pointer to this worker's vlib_main.
static void tcp_cwnd_accumulate(tcp_connection_t *tc, u32 thresh, u32 bytes)
static void tcp_update_time_now(tcp_worker_ctx_t *wrk)
static u8 transport_connection_is_descheduled(transport_connection_t *tc)
static tcp_connection_t * tcp_get_connection_from_transport(transport_connection_t *tconn)
static u32 tcp_flight_size(const tcp_connection_t *tc)
Our estimate of the number of bytes in flight (pipe size)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static int ip4_header_bytes(const ip4_header_t *i)
static f64 vlib_time_now(vlib_main_t *vm)
static void * vlib_buffer_push_tcp(vlib_buffer_t *b, u16 sp_net, u16 dp_net, u32 seq, u32 ack, u8 tcp_hdr_opts_len, u8 flags, u16 wnd)
Push TCP header to buffer.
vl_api_interface_index_t sw_if_index
static u8 tcp_is_descheduled(tcp_connection_t *tc)
static void * ip4_next_header(ip4_header_t *i)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
VLIB buffer representation.
static u32 tcp_available_cc_snd_space(const tcp_connection_t *tc)
Estimate of how many bytes we can still push into the network.
vl_api_wireguard_peer_flags_t flags