|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
25 #define tcp_error(n,s) s,
31 #define foreach_tcp_state_next \
32 _ (DROP4, "ip4-drop") \
33 _ (DROP6, "ip6-drop") \
34 _ (TCP4_OUTPUT, "tcp4-output") \
35 _ (TCP6_OUTPUT, "tcp6-output")
37 typedef enum _tcp_established_next
39 #define _(s,n) TCP_ESTABLISHED_NEXT_##s,
45 typedef enum _tcp_rcv_process_next
47 #define _(s,n) TCP_RCV_PROCESS_NEXT_##s,
53 typedef enum _tcp_syn_sent_next
55 #define _(s,n) TCP_SYN_SENT_NEXT_##s,
61 typedef enum _tcp_listen_next
63 #define _(s,n) TCP_LISTEN_NEXT_##s,
70 typedef enum _tcp_state_next
72 #define _(s,n) TCP_NEXT_##s,
78 #define tcp_next_output(is_ip4) (is_ip4 ? TCP_NEXT_TCP4_OUTPUT \
79 : TCP_NEXT_TCP6_OUTPUT)
81 #define tcp_next_drop(is_ip4) (is_ip4 ? TCP_NEXT_DROP4 \
114 return (
seq_geq (end_seq, tc->rcv_las)
115 &&
seq_leq (seq, tc->rcv_nxt + tc->rcv_wnd));
148 &&
seq_leq (tc->rcv_las, seq_end))
151 tc->tsval_recent = tc->rcv_opts.tsval;
159 switch (tc->rst_state)
161 case TCP_STATE_SYN_RCVD:
166 case TCP_STATE_SYN_SENT:
170 case TCP_STATE_ESTABLISHED:
174 case TCP_STATE_CLOSE_WAIT:
175 case TCP_STATE_FIN_WAIT_1:
176 case TCP_STATE_FIN_WAIT_2:
177 case TCP_STATE_CLOSING:
178 case TCP_STATE_LAST_ACK:
181 case TCP_STATE_CLOSED:
182 case TCP_STATE_TIME_WAIT:
185 TCP_DBG (
"reset state: %u", tc->state);
194 tc->rst_state = tc->state;
209 TCP_EVT (TCP_EVT_RST_RCVD, tc);
212 case TCP_STATE_SYN_RCVD:
216 case TCP_STATE_SYN_SENT:
218 tc->rst_state = tc->state;
221 case TCP_STATE_ESTABLISHED:
228 case TCP_STATE_CLOSE_WAIT:
229 case TCP_STATE_FIN_WAIT_1:
230 case TCP_STATE_FIN_WAIT_2:
231 case TCP_STATE_CLOSING:
232 case TCP_STATE_LAST_ACK:
241 case TCP_STATE_CLOSED:
242 case TCP_STATE_TIME_WAIT:
245 TCP_DBG (
"reset state: %u", tc->state);
266 *error0 = TCP_ERROR_CONNECTION_CLOSED;
272 *error0 = TCP_ERROR_SEGMENT_INVALID;
278 *error0 = TCP_ERROR_OPTIONS;
284 *error0 = TCP_ERROR_PAWS;
293 tc0->tsval_recent = tc0->rcv_opts.tsval;
314 &&
vnet_buffer (b0)->tcp.seq_number == tc0->rcv_nxt - 1)
317 if (tc0->state == TCP_STATE_SYN_RCVD)
320 TCP_EVT (TCP_EVT_SYN_RCVD, tc0, 0);
321 *error0 = TCP_ERROR_SYNS_RCVD;
326 TCP_EVT (TCP_EVT_SYNACK_RCVD, tc0);
327 *error0 = TCP_ERROR_SYN_ACKS_RCVD;
334 if (tc0->rcv_wnd < tc0->snd_mss
335 && tc0->rcv_nxt ==
vnet_buffer (b0)->tcp.seq_number)
343 tc0->rcv_las - tc0->rcv_wnd)
345 tc0->rcv_nxt + tc0->rcv_wnd))
348 *error0 = TCP_ERROR_RCV_WND;
352 if ((tc0->flags & TCP_CONN_ZERO_RWND_SENT)
354 tc0->rcv_las + tc0->rcv_opts.mss))
355 *error0 = TCP_ERROR_ZERO_RWND;
376 *error0 = TCP_ERROR_RST_RCVD;
387 *error0 = TCP_ERROR_SPURIOUS_SYN;
413 *
error = TCP_ERROR_ACK_INVALID;
418 tc->bytes_acked =
vnet_buffer (
b)->tcp.ack_number - tc->snd_una;
420 *
error = TCP_ERROR_ACK_OK;
443 err = mrtt - tc->srtt;
444 tc->srtt =
clib_max ((
int) tc->srtt + (err >> 3), 1);
445 diff = (
clib_abs (err) - (int) tc->rttvar) >> 2;
446 tc->rttvar =
clib_max ((
int) tc->rttvar + diff, 1);
452 tc->mrtt_us = tc->mrtt_us + (mrtt - tc->mrtt_us) * 0.125;
482 if (!(tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE)
491 if (tc->rtt_ts &&
seq_geq (ack, tc->rtt_seq))
535 tc->mrtt_us =
clib_max (tc->mrtt_us, 0.0001);
544 if (tc->rto_boff && mrtt > 1 *
THZ)
553 tc->rttvar = mrtt >> 1;
565 u32 *pending_deq_acked;
572 pending_deq_acked =
wrk->pending_deq_acked;
573 for (
i = 0;
i <
vec_len (pending_deq_acked);
i++)
576 tc->flags &= ~TCP_CONN_DEQ_PENDING;
597 _vec_len (
wrk->pending_deq_acked) = 0;
603 if (!(tc->flags & TCP_CONN_DEQ_PENDING))
606 tc->flags |= TCP_CONN_DEQ_PENDING;
608 tc->burst_acked += tc->bytes_acked;
622 if (
seq_lt (tc->snd_wl1, seq)
623 || (tc->snd_wl1 == seq &&
seq_leq (tc->snd_wl2, ack)))
625 tc->snd_wnd = snd_wnd;
670 tc->snd_congestion = tc->snd_nxt;
671 tc->cwnd_acc_bytes = 0;
672 tc->snd_rxt_bytes = 0;
673 tc->rxt_delivered = 0;
674 tc->prr_delivered = 0;
675 tc->prr_start = tc->snd_una;
676 tc->prev_ssthresh = tc->ssthresh;
677 tc->prev_cwnd = tc->cwnd;
688 tc->fr_occurences += 1;
689 TCP_EVT (TCP_EVT_CC_EVT, tc, 4);
695 tc->cwnd = tc->prev_cwnd;
696 tc->ssthresh = tc->prev_ssthresh;
698 ASSERT (tc->rto_boff == 0);
699 TCP_EVT (TCP_EVT_CC_EVT, tc, 5);
732 if (
seq_leq (tc->snd_una, tc->snd_congestion)
733 && ((!(tc->cwnd > tc->snd_mss
734 && tc->bytes_acked <= 4 * tc->snd_mss))
735 || (tc->rcv_opts.tsecr != tc->tsecr_last_ack)))
741 return tc->sack_sb.lost_bytes || tc->rcv_dupacks >= tc->sack_sb.reorder;
763 if (tc->sack_sb.sacked_bytes)
765 tc->snd_congestion = tc->snd_nxt;
770 tc->rxt_delivered = 0;
771 tc->snd_rxt_bytes = 0;
773 tc->prr_delivered = 0;
775 tc->flags &= ~TCP_CONN_RXT_PENDING;
778 if (hole && hole->start == tc->snd_una && hole->end == tc->snd_nxt)
787 TCP_EVT (TCP_EVT_CC_EVT, tc, 3);
789 ASSERT (tc->rto_boff == 0);
812 (
seq_leq (tc->snd_congestion, tc->snd_una - tc->bytes_acked)
813 &&
seq_gt (tc->snd_congestion, tc->snd_una)))
814 tc->snd_congestion = tc->snd_una - 1;
838 TCP_EVT (TCP_EVT_DUPACK_RCVD, tc, 1);
865 if (!tc->bytes_acked && tc->sack_sb.rxt_sacked)
868 tc->rxt_delivered += tc->sack_sb.rxt_sacked;
869 tc->prr_delivered += tc->bytes_acked + tc->sack_sb.last_sacked_bytes
870 - tc->sack_sb.last_bytes_delivered;
876 tc->rcv_dupacks += 1;
877 TCP_EVT (TCP_EVT_DUPACK_RCVD, tc, 1);
879 tc->rxt_delivered =
clib_min (tc->rxt_delivered + tc->bytes_acked,
882 tc->prr_delivered +=
clib_min (tc->snd_mss,
883 tc->snd_nxt - tc->snd_una);
885 tc->prr_delivered += tc->bytes_acked -
clib_min (tc->bytes_acked,
897 if (
seq_geq (tc->snd_una, tc->snd_congestion))
902 tc->tsecr_last_ack = tc->rcv_opts.tsecr;
917 if (!tc->bytes_acked)
944 if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE)
957 return ((
vnet_buffer (
b)->tcp.ack_number == prev_snd_una)
958 &&
seq_gt (tc->snd_nxt, tc->snd_una)
960 && (prev_snd_wnd == tc->snd_wnd));
968 u32 prev_snd_wnd,
u32 prev_snd_una,
u8 * is_dack)
972 *is_dack = tc->sack_sb.last_sacked_bytes
985 u32 prev_snd_wnd, prev_snd_una;
1003 tc->errors.above_ack_wnd += 1;
1004 *
error = TCP_ERROR_ACK_FUTURE;
1012 tc->errors.below_ack_wnd += 1;
1013 *
error = TCP_ERROR_ACK_OLD;
1034 prev_snd_wnd = tc->snd_wnd;
1035 prev_snd_una = tc->snd_una;
1038 clib_net_to_host_u16 (th->window) << tc->snd_wscale);
1039 tc->bytes_acked =
vnet_buffer (
b)->tcp.ack_number - tc->snd_una;
1043 if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE)
1046 if (tc->bytes_acked + tc->sack_sb.last_sacked_bytes)
1049 if (tc->bytes_acked)
1053 TCP_EVT (TCP_EVT_ACK_RCVD, tc);
1062 tc->dupacks_in += is_dack;
1065 *
error = TCP_ERROR_ACK_OK;
1068 *
error = TCP_ERROR_ACK_DUP;
1078 *
error = TCP_ERROR_ACK_OK;
1087 vec_add1 (
wrk->pending_disconnects, tc->c_c_index);
1102 pending_disconnects =
wrk->pending_disconnects;
1103 for (
i = 0;
i <
vec_len (pending_disconnects);
i++)
1109 _vec_len (
wrk->pending_disconnects) = 0;
1115 pending_resets =
wrk->pending_resets;
1116 for (
i = 0;
i <
vec_len (pending_resets);
i++)
1122 _vec_len (
wrk->pending_resets) = 0;
1136 tc->flags |= TCP_CONN_FINRCVD;
1144 TCP_EVT (TCP_EVT_FIN_RCVD, tc);
1145 *
error = TCP_ERROR_FIN_RCVD;
1153 int written,
error = TCP_ERROR_ENQUEUED;
1159 tc->bytes_in += written;
1166 tc->rcv_nxt += written;
1171 tc->rcv_nxt += written;
1174 else if (written > 0)
1177 tc->rcv_nxt += written;
1178 error = TCP_ERROR_PARTIALLY_ENQUEUED;
1183 if (tc->rcv_wnd < tc->snd_mss)
1184 return TCP_ERROR_ZERO_RWND;
1186 return TCP_ERROR_FIFO_FULL;
1220 return TCP_ERROR_FIFO_FULL;
1232 s0 =
session_get (tc->c_s_index, tc->c_thread_index);
1240 start = tc->rcv_nxt +
offset;
1244 TCP_EVT (TCP_EVT_CC_SACKS, tc);
1248 return TCP_ERROR_ENQUEUED_OOO;
1260 if (!(
b->
flags & VLIB_BUFFER_NEXT_PRESENT))
1267 n_bytes_to_drop -= discard;
1269 while (n_bytes_to_drop);
1270 if (n_bytes_to_drop >
first)
1288 u32 error, n_bytes_to_drop, n_data_bytes;
1293 tc->data_segs_in += 1;
1311 tc->errors.below_data_wnd++;
1312 error = TCP_ERROR_SEGMENT_OLD;
1318 n_bytes_to_drop = tc->rcv_nxt -
vnet_buffer (
b)->tcp.seq_number;
1319 n_data_bytes -= n_bytes_to_drop;
1323 error = TCP_ERROR_SEGMENT_OLD;
1334 tc->rcv_las + tc->rcv_wnd);
1378 s =
format (s,
"%d -> %d (%U)",
1379 clib_net_to_host_u16 (t->
tcp_header.dst_port),
1422 if (b0->
flags & VLIB_BUFFER_IS_TRACED)
1446 #define tcp_maybe_inc_counter(node_id, err, count) \
1448 if (next0 != tcp_next_drop (is_ip4)) \
1449 tcp_node_inc_counter_i (vm, tcp4_##node_id##_node.index, \
1450 tcp6_##node_id##_node.index, is_ip4, err, \
1453 #define tcp_inc_counter(node_id, err, count) \
1454 tcp_node_inc_counter_i (vm, tcp4_##node_id##_node.index, \
1455 tcp6_##node_id##_node.index, is_ip4, \
1457 #define tcp_maybe_inc_err_counter(cnts, err) \
1459 cnts[err] += (next0 != tcp_next_drop (is_ip4)); \
1461 #define tcp_inc_err_counter(cnts, err, val) \
1465 #define tcp_store_err_counters(node_id, cnts) \
1468 for (i = 0; i < TCP_N_ERROR; i++) \
1470 tcp_inc_counter(node_id, i, cnts[i]); \
1510 error = TCP_ERROR_INVALID_CONNECTION;
1548 err_counters[TCP_ERROR_MSG_QUEUE_FULL] = errors;
1554 return frame->n_vectors;
1574 .name =
"tcp4-established",
1576 .vector_size =
sizeof (
u32),
1582 #define _(s,n) [TCP_ESTABLISHED_NEXT_##s] = n,
1593 .name =
"tcp6-established",
1595 .vector_size =
sizeof (
u32),
1601 #define _(s,n) [TCP_ESTABLISHED_NEXT_##s] = n,
1621 if (tc->c_lcl_port == 0 && tc->state == TCP_STATE_LISTEN)
1624 u8 is_ip_valid = 0, val_l, val_r;
1626 if (tc->connection.is_ip4)
1631 &tc->connection.lcl_ip.ip4);
1632 val_l = val_l ||
ip_is_zero (&tc->connection.lcl_ip, 1);
1634 &tc->connection.rmt_ip.ip4);
1635 val_r = val_r || tc->state == TCP_STATE_LISTEN;
1636 is_ip_valid = val_l && val_r;
1643 &tc->connection.lcl_ip.ip6);
1644 val_l = val_l ||
ip_is_zero (&tc->connection.lcl_ip, 0);
1646 &tc->connection.rmt_ip.ip6);
1647 val_r = val_r || tc->state == TCP_STATE_LISTEN;
1648 is_ip_valid = val_l && val_r;
1651 u8 is_valid = (tc->c_lcl_port == hdr->dst_port
1652 && (tc->state == TCP_STATE_LISTEN
1653 || tc->c_rmt_port == hdr->src_port) && is_ip_valid);
1659 tc->c_proto, tc->c_is_ip4);
1663 if (
tmp->lcl_port == hdr->dst_port
1664 &&
tmp->rmt_port == hdr->src_port)
1666 TCP_DBG (
"half-open is valid!");
1695 TRANSPORT_PROTO_TCP,
1710 TRANSPORT_PROTO_TCP,
1729 tcp->dst_port, TRANSPORT_PROTO_TCP, 1);
1737 tcp->dst_port, TRANSPORT_PROTO_TCP, 1);
1742 (TRANSPORT_PROTO_TCP,
1757 for (
i = 0;
i < n_bufs;
i++)
1760 if (!(
b->
flags & VLIB_BUFFER_IS_TRACED))
1776 u32 sw_if_idx, lb_idx;
1785 ip6_address_t *
dst_addr = &(tc->c_rmt_ip.ip6);
1800 tc->cfg_flags |= TCP_CFG_F_TSO;
1822 u32 ack, seq,
error = TCP_ERROR_NONE;
1830 error = TCP_ERROR_INVALID_CONNECTION;
1838 error = TCP_ERROR_SPURIOUS_SYN_ACK;
1849 tcp->src_port != tc->c_rmt_port))
1851 error = TCP_ERROR_INVALID_CONNECTION;
1857 error = TCP_ERROR_SEGMENT_INVALID;
1882 error = TCP_ERROR_RCV_WND;
1887 if (
seq_gt (tc->snd_una, ack))
1889 error = TCP_ERROR_ACK_INVALID;
1904 error = TCP_ERROR_RST_RCVD;
1919 error = TCP_ERROR_SEGMENT_INVALID;
1926 error = TCP_ERROR_OPTIONS;
1940 new_tc->tsval_recent = new_tc->rcv_opts.tsval;
1945 new_tc->snd_wscale = new_tc->rcv_opts.wscale;
1947 new_tc->rcv_wscale = 0;
1949 new_tc->snd_wnd = clib_net_to_host_u16 (tcp->window)
1950 << new_tc->snd_wscale;
1951 new_tc->snd_wl1 = seq;
1952 new_tc->snd_wl2 = ack;
1962 new_tc->snd_una = ack;
1963 new_tc->state = TCP_STATE_ESTABLISHED;
1966 new_tc->rcv_las = new_tc->rcv_nxt;
1975 error = TCP_ERROR_CREATE_SESSION_FAIL;
1983 TCP_EVT (TCP_EVT_SYNACK_RCVD, new_tc);
1984 error = TCP_ERROR_SYN_ACKS_RCVD;
1989 new_tc->state = TCP_STATE_SYN_RCVD;
1997 TCP_EVT (TCP_EVT_RST_SENT, tc);
1998 error = TCP_ERROR_CREATE_SESSION_FAIL;
2007 error = TCP_ERROR_SYNS_RCVD;
2011 if (!(new_tc->cfg_flags & TCP_CFG_F_NO_TSO))
2019 if (
error == TCP_ERROR_ACK_OK)
2020 error = TCP_ERROR_SYN_ACKS_RCVD;
2034 tc->flags |= TCP_CONN_HALF_OPEN_DONE;
2049 return frame->n_vectors;
2069 .name =
"tcp4-syn-sent",
2071 .vector_size =
sizeof (
u32),
2077 #define _(s,n) [TCP_SYN_SENT_NEXT_##s] = n,
2088 .name =
"tcp6-syn-sent",
2090 .vector_size =
sizeof (
u32),
2096 #define _(s,n) [TCP_SYN_SENT_NEXT_##s] = n,
2114 for (
i = 0;
i < n_bufs;
i++)
2117 if (!(
b->
flags & VLIB_BUFFER_IS_TRACED))
2158 error = TCP_ERROR_INVALID_CONNECTION;
2172 if (
tmp->state != tc->state)
2174 if (tc->state != TCP_STATE_CLOSED)
2186 error = TCP_ERROR_CONNECTION_CLOSED;
2201 case TCP_STATE_SYN_RCVD:
2204 if (tc->rcv_nxt !=
vnet_buffer (
b[0])->tcp.seq_number || is_fin)
2207 error = TCP_ERROR_SEGMENT_INVALID;
2220 error = TCP_ERROR_SEGMENT_INVALID;
2229 tc->state = TCP_STATE_ESTABLISHED;
2230 TCP_EVT (TCP_EVT_STATE_CHANGE, tc);
2232 if (!(tc->cfg_flags & TCP_CFG_F_NO_TSO))
2237 tc->snd_wnd = clib_net_to_host_u16 (tcp->window)
2238 << tc->rcv_opts.wscale;
2246 error = TCP_ERROR_MSG_QUEUE_FULL;
2252 error = TCP_ERROR_ACK_OK;
2254 case TCP_STATE_ESTABLISHED:
2261 case TCP_STATE_FIN_WAIT_1:
2269 if (tc->flags & TCP_CONN_FINPNDG)
2273 if (max_deq <= tc->burst_acked)
2276 else if ((tc->flags & TCP_CONN_FINRCVD) && tc->bytes_acked)
2281 else if (tc->snd_una == tc->snd_nxt)
2289 if (tc->flags & TCP_CONN_FINRCVD)
2304 if (tc->burst_acked > 1)
2306 tc->burst_acked - 1);
2307 tc->burst_acked = 0;
2310 case TCP_STATE_FIN_WAIT_2:
2316 tc->burst_acked = 0;
2318 case TCP_STATE_CLOSE_WAIT:
2323 if (!(tc->flags & TCP_CONN_FINPNDG))
2328 if (max_deq > tc->burst_acked)
2337 case TCP_STATE_CLOSING:
2344 if (tc->snd_una != tc->snd_nxt)
2355 case TCP_STATE_LAST_ACK:
2364 if (is_fin && tc->snd_una != tc->snd_nxt)
2382 case TCP_STATE_TIME_WAIT:
2408 case TCP_STATE_ESTABLISHED:
2409 case TCP_STATE_FIN_WAIT_1:
2410 case TCP_STATE_FIN_WAIT_2:
2417 case TCP_STATE_CLOSE_WAIT:
2418 case TCP_STATE_CLOSING:
2419 case TCP_STATE_LAST_ACK:
2420 case TCP_STATE_TIME_WAIT:
2430 TCP_EVT (TCP_EVT_FIN_RCVD, tc);
2434 case TCP_STATE_ESTABLISHED:
2443 case TCP_STATE_SYN_RCVD:
2454 case TCP_STATE_CLOSE_WAIT:
2455 case TCP_STATE_CLOSING:
2456 case TCP_STATE_LAST_ACK:
2459 case TCP_STATE_FIN_WAIT_1:
2462 if (tc->flags & TCP_CONN_FINPNDG)
2467 tc->flags |= TCP_CONN_FINRCVD;
2480 case TCP_STATE_FIN_WAIT_2:
2490 case TCP_STATE_TIME_WAIT:
2498 error = TCP_ERROR_FIN_RCVD;
2514 return frame->n_vectors;
2534 .name =
"tcp4-rcv-process",
2536 .vector_size =
sizeof (
u32),
2542 #define _(s,n) [TCP_RCV_PROCESS_NEXT_##s] = n,
2553 .name =
"tcp6-rcv-process",
2555 .vector_size =
sizeof (
u32),
2561 #define _(s,n) [TCP_RCV_PROCESS_NEXT_##s] = n,
2571 u32 *to_next,
u32 n_bufs)
2578 for (
i = 0;
i < n_bufs;
i++)
2581 if (!(
b->
flags & VLIB_BUFFER_IS_TRACED))
2625 if (tc->state != TCP_STATE_TIME_WAIT)
2627 error = TCP_ERROR_CREATE_EXISTS;
2636 error = TCP_ERROR_NO_LISTENER;
2646 error = TCP_ERROR_CREATE_EXISTS;
2663 error = TCP_ERROR_OPTIONS;
2670 child->state = TCP_STATE_SYN_RCVD;
2671 child->c_fib_index = lc->c_fib_index;
2672 child->cc_algo = lc->cc_algo;
2681 TCP_EVT (TCP_EVT_SYN_RCVD, child, 1);
2684 lc->c_thread_index, 0 ))
2687 error = TCP_ERROR_CREATE_SESSION_FAIL;
2700 n_syns += (
error == TCP_ERROR_NONE);
2706 return frame->n_vectors;
2724 .name =
"tcp4-listen",
2726 .vector_size =
sizeof (
u32),
2732 #define _(s,n) [TCP_LISTEN_NEXT_##s] = n,
2743 .name =
"tcp6-listen",
2745 .vector_size =
sizeof (
u32),
2751 #define _(s,n) [TCP_LISTEN_NEXT_##s] = n,
2759 typedef enum _tcp_input_next
2771 #define foreach_tcp4_input_next \
2772 _ (DROP, "ip4-drop") \
2773 _ (LISTEN, "tcp4-listen") \
2774 _ (RCV_PROCESS, "tcp4-rcv-process") \
2775 _ (SYN_SENT, "tcp4-syn-sent") \
2776 _ (ESTABLISHED, "tcp4-established") \
2777 _ (RESET, "tcp4-reset") \
2778 _ (PUNT, "ip4-punt")
2780 #define foreach_tcp6_input_next \
2781 _ (DROP, "ip6-drop") \
2782 _ (LISTEN, "tcp6-listen") \
2783 _ (RCV_PROCESS, "tcp6-rcv-process") \
2784 _ (SYN_SENT, "tcp6-syn-sent") \
2785 _ (ESTABLISHED, "tcp6-established") \
2786 _ (RESET, "tcp6-reset") \
2787 _ (PUNT, "ip6-punt")
2789 #define filter_flags (TCP_FLAG_SYN|TCP_FLAG_ACK|TCP_FLAG_RST|TCP_FLAG_FIN)
2800 for (
i = 0;
i < n_bufs;
i++)
2802 if (bs[
i]->
flags & VLIB_BUFFER_IS_TRACED)
2816 if (*
error == TCP_ERROR_FILTERED || *
error == TCP_ERROR_WRONG_THREAD)
2820 else if ((is_ip4 && tm->punt_unknown4) || (!is_ip4 && tm->punt_unknown6))
2823 *
error = TCP_ERROR_PUNT;
2828 *
error = TCP_ERROR_NO_LISTENER;
2843 *
next = tm->dispatch_table[tc->state][
flags].next;
2844 error = tm->dispatch_table[tc->state][
flags].error;
2854 if (
error == TCP_ERROR_DISPATCH)
2855 clib_warning (
"tcp conn %u disp error state %U flags %U",
2881 u32 error0 = TCP_ERROR_NO_LISTENER, error1 = TCP_ERROR_NO_LISTENER;
2904 vnet_buffer (
b[0])->tcp.connection_index = tc0->c_c_index;
2905 vnet_buffer (
b[1])->tcp.connection_index = tc1->c_c_index;
2915 vnet_buffer (
b[0])->tcp.connection_index = tc0->c_c_index;
2927 vnet_buffer (
b[1])->tcp.connection_index = tc1->c_c_index;
2944 u32 error0 = TCP_ERROR_NO_LISTENER;
2958 vnet_buffer (
b[0])->tcp.connection_index = tc0->c_c_index;
2976 return frame->n_vectors;
2998 .name =
"tcp4-input-nolookup",
3000 .vector_size =
sizeof (
u32),
3006 #define _(s,n) [TCP_INPUT_NEXT_##s] = n,
3018 .name =
"tcp6-input-nolookup",
3020 .vector_size =
sizeof (
u32),
3026 #define _(s,n) [TCP_INPUT_NEXT_##s] = n,
3052 .name =
"tcp4-input",
3054 .vector_size =
sizeof (
u32),
3060 #define _(s,n) [TCP_INPUT_NEXT_##s] = n,
3072 .name =
"tcp6-input",
3074 .vector_size =
sizeof (
u32),
3080 #define _(s,n) [TCP_INPUT_NEXT_##s] = n,
3089 #ifndef CLIB_MARCH_VARIANT
3101 for (j = 0; j <
ARRAY_LEN (tm->dispatch_table[
i]); j++)
3104 tm->dispatch_table[
i][j].error = TCP_ERROR_DISPATCH;
3107 #define _(t,f,n,e) \
3109 tm->dispatch_table[TCP_STATE_##t][f].next = (n); \
3110 tm->dispatch_table[TCP_STATE_##t][f].error = (e); \
3119 TCP_ERROR_ACK_INVALID);
3121 TCP_ERROR_SEGMENT_INVALID);
3123 TCP_ERROR_SEGMENT_INVALID);
3125 TCP_ERROR_INVALID_CONNECTION);
3128 TCP_ERROR_SEGMENT_INVALID);
3130 TCP_ERROR_SEGMENT_INVALID);
3132 TCP_ERROR_SEGMENT_INVALID);
3134 TCP_ERROR_SEGMENT_INVALID);
3136 TCP_ERROR_SEGMENT_INVALID);
3138 TCP_ERROR_SEGMENT_INVALID);
3320 TCP_ERROR_CONNECTION_CLOSED);
3324 TCP_ERROR_CONNECTION_CLOSED);
u32 next_buffer
Next buffer for this linked-list of buffers.
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.
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
static u32 vlib_num_workers()
void tcp_rcv_sacks(tcp_connection_t *tc, u32 ack)
u16 lb_n_buckets
number of buckets in the load-balance.
void tcp_connection_cleanup(tcp_connection_t *tc)
Cleans up connection state.
#define seq_geq(_s1, _s2)
#define tcp_fastrecovery_off(tc)
void tcp_reschedule(tcp_connection_t *tc)
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
static tcp_connection_t * tcp_half_open_connection_get(u32 conn_index)
#define tcp_opts_tstamp(_to)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
vnet_hw_interface_capabilities_t caps
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.
format_function_t format_tcp_state
void session_transport_closing_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
tcp_connection_t * tcp_connection_alloc(u8 thread_index)
void tcp_send_synack(tcp_connection_t *tc)
int ip6_address_compare(ip6_address_t *a1, ip6_address_t *a2)
struct _tcp_header tcp_header_t
void tcp_send_ack(tcp_connection_t *tc)
vlib_get_buffers(vm, from, b, n_left_from)
u32 dpo_get_urpf(const dpo_id_t *dpo)
Get a uRPF interface for the DPO.
vlib_main_t vlib_node_runtime_t * node
struct _tcp_connection tcp_connection_t
static tcp_connection_t * tcp_listener_get(u32 tli)
#define TCP_DBG(_fmt, _args...)
void tcp_bt_sample_delivery_rate(tcp_connection_t *tc, tcp_rate_sample_t *rs)
Generate a delivery rate sample from recently acked bytes.
tcp_bts_flags_t flags
Rate sample flags from bt sample.
static tcp_main_t * vnet_get_tcp_main()
static tcp_worker_ctx_t * tcp_get_worker(u32 thread_index)
#define TCP_DUPACK_THRESHOLD
static heap_elt_t * first(heap_header_t *h)
#define vlib_call_init_function(vm, x)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static void tcp_timer_update(tcp_timer_wheel_t *tw, tcp_connection_t *tc, u8 timer_id, u32 interval)
static u32 tcp_time_tstamp(u32 thread_index)
Time used to generate timestamps, not the timestamp.
void session_transport_closed_notify(transport_connection_t *tc)
Notification from transport that it is closed.
static void tcp_cc_congestion(tcp_connection_t *tc)
void tcp_init_snd_vars(tcp_connection_t *tc)
Initialize connection send variables.
static u8 tcp_is_lost_fin(tcp_connection_t *tc)
vlib_main_t vlib_node_runtime_t vlib_frame_t * from_frame
vlib_buffer_enqueue_to_next(vm, node, from,(u16 *) nexts, frame->n_vectors)
#define TCP_PAWS_IDLE
24 days
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)
#define tcp_disconnect_pending_off(tc)
struct _tcp_main tcp_main_t
static tcp_connection_t * tcp_input_lookup_buffer(vlib_buffer_t *b, u8 thread_index, u32 *error, u8 is_ip4, u8 is_nolookup)
#define tcp_fastrecovery_on(tc)
static void tcp_cong_recovery_off(tcp_connection_t *tc)
static void tcp_update_rto(tcp_connection_t *tc)
#define CLIB_PREFETCH(addr, size, type)
int session_stream_accept(transport_connection_t *tc, u32 listener_index, u32 thread_index, u8 notify)
Accept a stream session.
vlib_error_t * errors
Vector of errors for this node.
#define timestamp_leq(_t1, _t2)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static void tcp_retransmit_timer_reset(tcp_timer_wheel_t *tw, tcp_connection_t *tc)
#define seq_leq(_s1, _s2)
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
void scoreboard_clear(sack_scoreboard_t *sb)
void tcp_program_cleanup(tcp_worker_ctx_t *wrk, tcp_connection_t *tc)
#define VLIB_NODE_FN(node)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
int session_enqueue_stream_connection(transport_connection_t *tc, vlib_buffer_t *b, u32 offset, u8 queue_event, u8 is_in_order)
#define tcp_opts_wscale(_to)
#define tcp_validate_txf_size(_tc, _a)
#define tcp_in_recovery(tc)
vnet_main_t * vnet_get_main(void)
#define VLIB_NODE_FLAG_TRACE
tcp_connection_t tcp_connection
static u8 tcp_timer_is_active(tcp_connection_t *tc, tcp_timers_e timer)
void tcp_update_sack_list(tcp_connection_t *tc, u32 start, u32 end)
Build SACK list as per RFC2018.
struct clib_bihash_value offset
template key/value backing page structure
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO
static void tcp_cc_recovered(tcp_connection_t *tc)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
format_function_t format_tcp_connection_id
f64 end
end of the time range
transport_connection_t * session_lookup_half_open_connection(u64 handle, u8 proto, u8 is_ip4)
#define tcp_fastrecovery_first_on(tc)
format_function_t format_tcp_flags
static ooo_segment_t * svm_fifo_newest_ooo_segment(svm_fifo_t *f)
void transport_fifos_init_ooo(transport_connection_t *tc)
static u32 ooo_segment_offset_prod(svm_fifo_t *f, ooo_segment_t *s)
#define tcp_disconnect_pending_on(tc)
static u32 transport_max_tx_dequeue(transport_connection_t *tc)
static void tcp_connection_set_state(tcp_connection_t *tc, tcp_state_t state)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static void tcp_cc_rcv_ack(tcp_connection_t *tc, tcp_rate_sample_t *rs)
void tcp_connection_timers_reset(tcp_connection_t *tc)
Stop all connection timers.
static const dpo_id_t * load_balance_get_bucket_i(const load_balance_t *lb, u32 bucket)
vl_api_mac_address_t dst_addr
sll srl srl sll sra u16x4 i
static void tcp_retransmit_timer_update(tcp_timer_wheel_t *tw, tcp_connection_t *tc)
static void tcp_timer_set(tcp_timer_wheel_t *tw, tcp_connection_t *tc, u8 timer_id, u32 interval)
int session_main_flush_enqueue_events(u8 transport_proto, u32 thread_index)
Flushes queue of sessions that are to be notified of new data enqueued events.
void tcp_program_ack(tcp_connection_t *tc)
#define tcp_opts_sack_permitted(_to)
void tcp_program_dupack(tcp_connection_t *tc)
#define TCP_EVT(_evt, _args...)
#define CLIB_CACHE_LINE_BYTES
static u32 tcp_tstamp(tcp_connection_t *tc)
Generate timestamp for tcp connection.
struct _vlib_node_registration vlib_node_registration_t
static session_t * session_get(u32 si, u32 thread_index)
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
static u32 ip6_fib_table_fwding_lookup(u32 fib_index, const ip6_address_t *dst)
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.
int ip4_address_compare(ip4_address_t *a1, ip4_address_t *a2)
void tcp_program_retransmit(tcp_connection_t *tc)
static f64 tcp_time_now_us(u32 thread_index)
static u32 ooo_segment_length(svm_fifo_t *f, ooo_segment_t *s)
static clib_error_t * tcp_init(vlib_main_t *vm)
void tcp_send_reset(tcp_connection_t *tc)
Build and set reset packet for connection.
static tcp_header_t * tcp_buffer_hdr(vlib_buffer_t *b)
template key/value backing page structure
struct _sack_scoreboard_hole sack_scoreboard_hole_t
@ TRANSPORT_CONNECTION_F_NO_LOOKUP
Don't register connection in lookup.
u32 session_tx_fifo_dequeue_drop(transport_connection_t *tc, u32 max_bytes)
description fragment has unexpected format
void tcp_connection_tx_pacer_reset(tcp_connection_t *tc, u32 window, u32 start_bucket)
static void tcp_cc_undo_recovery(tcp_connection_t *tc)
static u32 transport_tx_fifo_size(transport_connection_t *tc)
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_INIT_FUNCTION(x)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
void scoreboard_init_rxt(sack_scoreboard_t *sb, u32 snd_una)
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.
#define tcp_in_cong_recovery(tc)
#define tcp_recovery_off(tc)
static load_balance_t * load_balance_get(index_t lbi)
f64 rtt_time
RTT for sample.
u64 session_lookup_half_open_handle(transport_connection_t *tc)
static void tcp_cc_rcv_cong_ack(tcp_connection_t *tc, tcp_cc_ack_t ack_type, tcp_rate_sample_t *rs)
static void tcp_update_time_now(tcp_worker_ctx_t *wrk)
void tcp_connection_free(tcp_connection_t *tc)
tcp_connection_t * tcp_connection_alloc_w_base(u8 thread_index, tcp_connection_t *base)
static tcp_connection_t * tcp_get_connection_from_transport(transport_connection_t *tconn)
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static vlib_main_t * vlib_get_main(void)
void tcp_connection_tx_pacer_update(tcp_connection_t *tc)
#define THZ
TCP tick frequency.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static sack_scoreboard_hole_t * scoreboard_first_hole(sack_scoreboard_t *sb)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
session_t * session_lookup_listener4(u32 fib_index, ip4_address_t *lcl, u16 lcl_port, u8 proto, u8 use_wildcard)
#define clib_warning(format, args...)
#define tcp_fastrecovery_first_off(tc)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
u16 nexts[VLIB_FRAME_SIZE]
static index_t ip4_fib_forwarding_lookup(u32 fib_index, const ip4_address_t *addr)
void tcp_connection_init_vars(tcp_connection_t *tc)
Initialize tcp connection variables.
static transport_connection_t * transport_get_listener(transport_proto_t tp, u32 conn_index)
static void tcp_persist_timer_set(tcp_timer_wheel_t *tw, tcp_connection_t *tc)
#define TCP_TICK
TCP tick period (s)
#define tcp_disconnect_pending(tc)
session_t * session_lookup_listener6(u32 fib_index, ip6_address_t *lcl, u16 lcl_port, u8 proto, u8 use_wildcard)
void session_transport_reset_notify(transport_connection_t *tc)
Notify application that connection has been reset.
#define timestamp_lt(_t1, _t2)
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
#define TCP_TIMER_HANDLE_INVALID
static int tcp_options_parse(tcp_header_t *th, tcp_options_t *to, u8 is_syn)
Parse TCP header options.
u8 tcp_scoreboard_is_sane_post_recovery(tcp_connection_t *tc)
Test that scoreboard is sane after recovery.
void tcp_connection_del(tcp_connection_t *tc)
Connection removal.
u32 connection_index
Index of the transport connection associated to the session.
void tcp_send_fin(tcp_connection_t *tc)
Send FIN.
static void tcp_persist_timer_reset(tcp_timer_wheel_t *tw, tcp_connection_t *tc)
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,...
int session_stream_accept_notify(transport_connection_t *tc)
int session_stream_connect_notify(transport_connection_t *tc, session_error_t err)
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)
u8 ip_is_zero(ip46_address_t *ip46_address, u8 is_ip4)
int tcp_half_open_connection_cleanup(tcp_connection_t *tc)
Try to cleanup half-open connection.
vl_api_wireguard_peer_flags_t flags
static void svm_fifo_newest_ooo_segment_reset(svm_fifo_t *f)