|
FD.io VPP
v21.06-3-gbb25fbf28
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);
82 return tc->sack_sb.sacked_bytes + tc->sack_sb.lost_bytes;
84 return clib_min (tc->rcv_dupacks * tc->snd_mss,
85 tc->snd_nxt - tc->snd_una);
96 flight_size = (int) (tc->snd_nxt - tc->snd_una) -
tcp_bytes_out (tc)
97 + tc->snd_rxt_bytes - tc->rxt_delivered;
110 if (
tcp_cfg.initial_cwnd_multiplier > 0)
111 return tcp_cfg.initial_cwnd_multiplier * tc->snd_mss;
113 if (tc->snd_mss > 2190)
114 return 2 * tc->snd_mss;
115 else if (tc->snd_mss > 1095)
116 return 3 * tc->snd_mss;
118 return 4 * tc->snd_mss;
130 tc->cwnd_acc_bytes += bytes;
131 if (tc->cwnd_acc_bytes >= thresh)
133 u32 inc = tc->cwnd_acc_bytes / thresh;
134 tc->cwnd_acc_bytes -= inc * thresh;
135 tc->cwnd += inc * tc->snd_mss;
136 tc->cwnd =
clib_min (tc->cwnd, tc->tx_fifo_size);
150 return clib_min (tc->cwnd, tc->snd_wnd);
157 int flight_size = (int) (tc->snd_nxt - tc->snd_una);
159 if (available_wnd <= flight_size)
162 return available_wnd - flight_size;
174 if (available_wnd <= flight_size)
177 return available_wnd - flight_size;
183 if ((tc->flags & TCP_CONN_FINSNT) && (tc->snd_nxt - tc->snd_una == 1))
203 return (
tcp_main.wrk_ctx[tc->c_thread_index].time_tstamp -
204 tc->timestamp_delta);
235 u8 is_ip4,
u8 is_nolookup)
238 int n_advance_bytes, n_data_bytes;
249 *
error = TCP_ERROR_LENGTH;
255 n_data_bytes = clib_net_to_host_u16 (
ip4->length) - n_advance_bytes;
260 *
error = TCP_ERROR_LENGTH;
266 &
ip4->src_address, tcp->dst_port,
276 *
error = TCP_ERROR_LENGTH;
282 n_data_bytes = clib_net_to_host_u16 (
ip6->payload_length)
284 n_advance_bytes +=
sizeof (
ip6[0]);
288 *
error = TCP_ERROR_LENGTH;
298 fib_index =
vec_elt (
im->fib_index_by_sw_if_index,
304 tcp->dst_port, tcp->src_port,
313 tcp.connection_index,
316 vnet_buffer (
b)->tcp.seq_number = clib_net_to_host_u32 (tcp->seq_number);
317 vnet_buffer (
b)->tcp.ack_number = clib_net_to_host_u32 (tcp->ack_number);
323 *
error = result ? TCP_ERROR_NONE + result : *
error;
340 tc->c_lcl_port = th->dst_port;
341 tc->c_rmt_port = th->src_port;
342 tc->c_is_ip4 = is_ip4;
347 tc->c_lcl_ip4.as_u32 =
ip4->dst_address.as_u32;
348 tc->c_rmt_ip4.as_u32 =
ip4->src_address.as_u32;
354 sizeof (ip6_address_t));
356 sizeof (ip6_address_t));
361 tc->rcv_las = tc->rcv_nxt;
370 tc->tsval_recent = tc->rcv_opts.tsval;
375 tc->snd_wscale = tc->rcv_opts.wscale;
377 tc->snd_wnd = clib_net_to_host_u16 (th->window) << tc->snd_wscale;
419 th->seq_number = seq;
420 th->ack_number = ack;
421 th->data_offset_and_reserved = (tcp_hdr_opts_len >> 2) << 4;
425 th->urgent_pointer = 0;
427 b->
flags |= VNET_BUFFER_F_L4_HDR_OFFSET_VALID;
450 clib_host_to_net_u32 (seq),
451 clib_host_to_net_u32 (ack),
452 tcp_hdr_opts_len,
flags,
453 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