23 #define tcp_error(n,s) s, 29 #define foreach_tcp_state_next \ 30 _ (DROP, "error-drop") \ 31 _ (TCP4_OUTPUT, "tcp4-output") \ 32 _ (TCP6_OUTPUT, "tcp6-output") 34 typedef enum _tcp_established_next
36 #define _(s,n) TCP_ESTABLISHED_NEXT_##s, 42 typedef enum _tcp_rcv_process_next
44 #define _(s,n) TCP_RCV_PROCESS_NEXT_##s, 50 typedef enum _tcp_syn_sent_next
52 #define _(s,n) TCP_SYN_SENT_NEXT_##s, 58 typedef enum _tcp_listen_next
60 #define _(s,n) TCP_LISTEN_NEXT_##s, 67 typedef enum _tcp_state_next
69 #define _(s,n) TCP_NEXT_##s, 75 #define tcp_next_output(is_ip4) (is_ip4 ? TCP_NEXT_TCP4_OUTPUT \ 76 : TCP_NEXT_TCP6_OUTPUT) 111 return (
seq_geq (end_seq, tc->rcv_las)
112 &&
seq_leq (seq, tc->rcv_nxt + tc->rcv_wnd));
126 u8 opt_len, opts_len, kind;
131 data = (
const u8 *) (th + 1);
134 to->
flags &= (TCP_OPTS_FLAG_SACK_PERMITTED | TCP_OPTS_FLAG_WSCALE);
136 for (; opts_len > 0; opts_len -= opt_len, data += opt_len)
156 if (opt_len < 2 || opt_len > opts_len)
166 to->
flags |= TCP_OPTS_FLAG_MSS;
167 to->
mss = clib_net_to_host_u16 (*(
u16 *) (data + 2));
173 to->
flags |= TCP_OPTS_FLAG_WSCALE;
186 to->
flags |= TCP_OPTS_FLAG_TSTAMP;
187 to->
tsval = clib_net_to_host_u32 (*(
u32 *) (data + 2));
188 to->
tsecr = clib_net_to_host_u32 (*(
u32 *) (data + 6));
193 to->
flags |= TCP_OPTS_FLAG_SACK_PERMITTED;
197 if ((to->
flags & TCP_OPTS_FLAG_SACK_PERMITTED) == 0 ||
tcp_syn (th))
204 to->
flags |= TCP_OPTS_FLAG_SACK;
209 b.start = clib_net_to_host_u32 (*(
u32 *) (data + 2 + 4 * j));
210 b.end = clib_net_to_host_u32 (*(
u32 *) (data + 6 + 4 * j));
254 tc->tsval_recent = tc->rcv_opts.tsval;
299 tc0->tsval_recent = 0;
300 clib_warning (
"paws failed - really old segment. REALLY?");
321 if (tc0->rcv_wnd == 0
322 && tc0->rcv_nxt ==
vnet_buffer (b0)->tcp.seq_number)
385 err = mrtt - tc->srtt;
392 tc->srtt =
clib_max ((
int) tc->srtt + (err >> 3), 1);
393 diff = (
clib_abs (err) - (int) tc->rttvar) >> 2;
394 tc->rttvar =
clib_max ((
int) tc->rttvar + diff, 1);
400 tc->rttvar = mrtt >> 1;
430 if (tc->rtt_ts &&
seq_geq (ack, tc->rtt_seq) && !rtx_acked)
469 tc->bytes_acked + tc->sack_sb.snd_una_adv);
488 return ((
vnet_buffer (b)->tcp.ack_number == prev_snd_una)
489 &&
seq_gt (tc->snd_una_max, tc->snd_una)
491 && (prev_snd_wnd == tc->snd_wnd));
499 u32 prev_snd_wnd,
u32 prev_snd_una,
u8 * is_dack)
503 *is_dack = tc->sack_sb.last_sacked_bytes
517 next->prev = hole->prev;
521 sb->tail = hole->prev;
527 prev->next = hole->next;
531 sb->head = hole->next;
548 memset (hole, 0,
sizeof (*hole));
552 hole_index = hole - sb->holes;
557 hole->prev = prev_index;
558 hole->next = prev->next;
561 next->prev = hole_index;
563 sb->tail = hole_index;
565 prev->next = hole_index;
569 sb->head = hole_index;
581 u32 bytes = 0, blks = 0;
584 sb->sacked_bytes = 0;
589 if (
seq_gt (sb->high_sacked, hole->end))
591 bytes = sb->high_sacked - hole->end;
599 bytes += hole->start - prev->end;
611 bytes += prev->start - hole->end;
613 sb->sacked_bytes = bytes;
625 u8 * can_rescue,
u8 * snd_limited)
630 while (hole &&
seq_leq (hole->end, sb->high_rxt) && hole->is_lost)
641 if (hole->is_lost &&
seq_lt (hole->start, sb->high_sacked))
648 if (!have_sent_1_smss)
654 else if (
seq_lt (hole->start, sb->high_sacked))
670 if (hole &&
seq_lt (sb->high_rxt, hole->start))
671 sb->high_rxt = hole->start;
681 sb->high_rxt = hole->start;
682 sb->cur_rxt_hole = sb->head;
691 u32 blk_index = 0, old_sacked_bytes, hole_index;
694 sb->last_sacked_bytes = 0;
696 old_sacked_bytes = sb->sacked_bytes;
697 sb->last_bytes_delivered = 0;
704 blk = tc->rcv_opts.sacks;
705 while (blk <
vec_end (tc->rcv_opts.sacks))
707 if (
seq_lt (blk->start, blk->end)
708 &&
seq_gt (blk->start, tc->snd_una)
709 &&
seq_gt (blk->start, ack) &&
seq_leq (blk->end, tc->snd_nxt))
714 vec_del1 (tc->rcv_opts.sacks, blk - tc->rcv_opts.sacks);
718 if (
seq_gt (ack, tc->snd_una))
720 tmp.start = tc->snd_una;
725 if (
vec_len (tc->rcv_opts.sacks) == 0)
729 for (i = 0; i <
vec_len (tc->rcv_opts.sacks); i++)
730 for (j = i + 1; j <
vec_len (tc->rcv_opts.sacks); j++)
731 if (
seq_lt (tc->rcv_opts.sacks[j].start, tc->rcv_opts.sacks[i].start))
733 tmp = tc->rcv_opts.sacks[
i];
734 tc->rcv_opts.sacks[
i] = tc->rcv_opts.sacks[j];
735 tc->rcv_opts.sacks[j] = tmp;
742 tc->snd_una, tc->snd_una_max);
744 tmp = tc->rcv_opts.sacks[
vec_len (tc->rcv_opts.sacks) - 1];
745 sb->high_sacked = tmp.end;
751 tmp = tc->rcv_opts.sacks[
vec_len (tc->rcv_opts.sacks) - 1];
753 if (
seq_gt (tc->snd_una_max, sb->high_sacked)
754 &&
seq_gt (tc->snd_una_max, last_hole->end))
755 last_hole->end = tc->snd_una_max;
758 if (
seq_gt (tmp.end, sb->high_sacked))
759 sb->high_sacked = tmp.end;
764 while (hole && blk_index < vec_len (tc->rcv_opts.sacks))
766 blk = &tc->rcv_opts.sacks[blk_index];
768 if (
seq_leq (blk->start, hole->start))
771 if (
seq_geq (blk->end, hole->end))
780 if (
seq_lt (ack, next_hole->start))
781 sb->snd_una_adv = next_hole->start - ack;
782 sb->last_bytes_delivered +=
783 next_hole->start - hole->end;
787 sb->snd_una_adv = sb->high_sacked - ack;
788 sb->last_bytes_delivered += sb->high_sacked - hole->end;
798 if (
seq_gt (blk->end, hole->start))
800 hole->start = blk->end;
808 if (
seq_lt (blk->end, hole->end))
815 hole->end = blk->start;
818 else if (
seq_lt (blk->start, hole->end))
820 hole->end = blk->start;
828 sb->last_sacked_bytes = sb->sacked_bytes
829 - (old_sacked_bytes - sb->last_bytes_delivered);
830 ASSERT (sb->sacked_bytes == 0
831 || sb->sacked_bytes < tc->snd_una_max -
seq_max (tc->snd_una, ack));
832 ASSERT (sb->last_sacked_bytes + sb->lost_bytes <= tc->snd_una_max
847 if (
seq_lt (tc->snd_wl1, seq)
848 || (tc->snd_wl1 == seq &&
seq_leq (tc->snd_wl2, ack)))
850 tc->snd_wnd = snd_wnd;
855 if (tc->snd_wnd < tc->snd_mss)
878 tc->snd_congestion = tc->snd_una_max;
879 tc->cc_algo->congestion (tc);
896 tc->cc_algo->recovered (tc);
897 tc->snd_rxt_bytes = 0;
906 tc->cwnd = tc->prev_cwnd;
907 tc->ssthresh = tc->prev_ssthresh;
908 tc->snd_nxt = tc->snd_una_max;
912 ASSERT (tc->rto_boff == 0);
919 return (tc->snd_rxt_ts
939 ASSERT (tc->rto_boff == 0);
952 tc->cc_algo->rcv_ack (tc);
953 tc->tsecr_last_ack = tc->rcv_opts.tsecr;
963 (
seq_leq (tc->snd_congestion, tc->snd_una - tc->bytes_acked)
964 &&
seq_gt (tc->snd_congestion, tc->snd_una)))
965 tc->snd_congestion = tc->snd_una - 1;
995 ASSERT (tc->snd_una != tc->snd_una_max
996 || tc->sack_sb.last_sacked_bytes);
1011 tc->rcv_dupacks = 0;
1012 goto partial_ack_test;
1022 if ((
seq_gt (tc->snd_una, tc->snd_congestion)
1023 || !(tc->cwnd > tc->snd_mss
1024 && tc->bytes_acked <= 4 * tc->snd_mss))
1025 || tc->rcv_opts.tsecr != tc->tsecr_last_ack)
1027 tc->rcv_dupacks = 0;
1040 tc->cwnd = tc->ssthresh + tc->rcv_dupacks * tc->snd_mss;
1056 else if (!tc->bytes_acked
1068 if (!tc->bytes_acked)
1078 if (
seq_geq (tc->snd_una, tc->snd_congestion))
1083 tc->tsecr_last_ack = tc->rcv_opts.tsecr;
1087 tc->snd_nxt = tc->snd_una_max;
1090 tc->cc_algo->rcv_ack (tc);
1091 tc->tsecr_last_ack = tc->rcv_opts.tsecr;
1102 tc->rcv_dupacks = 0;
1111 ASSERT (tc->bytes_acked + tc->sack_sb.snd_una_adv
1112 >= tc->sack_sb.last_bytes_delivered);
1113 rxt_delivered = tc->bytes_acked + tc->sack_sb.snd_una_adv
1114 - tc->sack_sb.last_bytes_delivered;
1115 if (rxt_delivered &&
seq_gt (tc->sack_sb.high_rxt, tc->snd_una))
1119 ASSERT (tc->snd_rxt_bytes >= rxt_delivered);
1120 tc->snd_rxt_bytes -= rxt_delivered;
1126 tc->snd_rxt_bytes = 0;
1141 tc->cc_algo->init (tc);
1151 u32 prev_snd_wnd, prev_snd_una;
1166 *error = TCP_ERROR_ACK_INVALID;
1176 *error = TCP_ERROR_ACK_FUTURE;
1182 *error = TCP_ERROR_ACK_OLD;
1203 prev_snd_wnd = tc->snd_wnd;
1204 prev_snd_una = tc->snd_una;
1207 clib_net_to_host_u16 (th->window) << tc->snd_wscale);
1208 tc->bytes_acked =
vnet_buffer (b)->tcp.ack_number - tc->snd_una;
1209 tc->snd_una =
vnet_buffer (b)->tcp.ack_number + tc->sack_sb.snd_una_adv;
1212 if (tc->bytes_acked)
1222 *error = TCP_ERROR_ACK_DUP;
1254 if (
seq_lt (tc->rcv_nxt, start))
1257 block->start = start;
1262 for (i = 0; i <
vec_len (tc->snd_sacks); i++)
1265 if (
seq_leq (tc->snd_sacks[i].start, tc->rcv_nxt))
1269 if (block && (
seq_geq (tc->snd_sacks[i].end, new_list[0].start)
1270 &&
seq_leq (tc->snd_sacks[i].start, new_list[0].end)))
1272 if (
seq_lt (tc->snd_sacks[i].start, new_list[0].start))
1273 new_list[0].start = tc->snd_sacks[i].start;
1274 if (
seq_lt (new_list[0].end, tc->snd_sacks[i].end))
1275 new_list[0].end = tc->snd_sacks[i].end;
1282 vec_add1 (new_list, tc->snd_sacks[i]);
1294 tc->snd_sacks = new_list;
1308 return TCP_ERROR_PURE_ACK;
1314 TCP_EVT_DBG (TCP_EVT_INPUT, tc, 0, data_len, written);
1322 else if (written > data_len)
1324 tc->rcv_nxt =
vnet_buffer (b)->tcp.seq_end + written - data_len;
1327 tc->flags |= TCP_CONN_SNDACK;
1329 else if (written > 0)
1332 tc->rcv_nxt += written;
1336 tc->flags |= TCP_CONN_SNDACK;
1338 return TCP_ERROR_PARTIALLY_ENQUEUED;
1342 tc->flags |= TCP_CONN_SNDACK;
1343 return TCP_ERROR_FIFO_FULL;
1353 return TCP_ERROR_ENQUEUED;
1369 return TCP_ERROR_PURE_ACK;
1375 tc->rcv_nxt, 0 , 0);
1381 return TCP_ERROR_FIFO_FULL;
1384 TCP_EVT_DBG (TCP_EVT_INPUT, tc, 1, data_len, data_len);
1407 return TCP_ERROR_ENQUEUED;
1420 || (tc->flags & TCP_CONN_SENT_RCV_WND0) != 0
1422 || (tc->flags & TCP_CONN_SNDACK) != 0
1432 u16 n_data_bytes,
u32 * next0)
1434 u32 error = 0, n_bytes_to_drop;
1443 error = TCP_ERROR_SEGMENT_OLD;
1444 *next0 = TCP_NEXT_DROP;
1451 n_bytes_to_drop = tc->rcv_nxt -
vnet_buffer (b)->tcp.seq_number;
1452 n_data_bytes -= n_bytes_to_drop;
1485 if (n_data_bytes == 0)
1487 *next0 = TCP_NEXT_DROP;
1520 s =
format (s,
"%U\n%U%U",
1535 s =
format (s,
"%d -> %d (%U)",
1536 clib_net_to_host_u16 (t->
tcp_header.src_port),
1574 u32 n_left_from, next_index, *from, *to_next;
1584 while (n_left_from > 0)
1589 while (n_left_from > 0 && n_left_to_next > 0)
1595 u32 next0 = TCP_ESTABLISHED_NEXT_DROP, error0 = TCP_ERROR_ENQUEUED;
1602 n_left_to_next -= 1;
1610 error0 = TCP_ERROR_INVALID_CONNECTION;
1626 error0 = TCP_ERROR_SEGMENT_INVALID;
1656 tc0->state = TCP_STATE_CLOSE_WAIT;
1672 n_left_to_next, bi0, next0);
1701 .name =
"tcp4-established",
1703 .vector_size =
sizeof (
u32),
1709 #define _(s,n) [TCP_ESTABLISHED_NEXT_##s] = n, 1723 .name =
"tcp6-established",
1725 .vector_size =
sizeof (
u32),
1731 #define _(s,n) [TCP_ESTABLISHED_NEXT_##s] = n, 1750 u32 n_left_from, next_index, *from, *to_next;
1752 u8 sst = is_ip4 ? SESSION_TYPE_IP4_TCP : SESSION_TYPE_IP6_TCP;
1759 while (n_left_from > 0)
1765 while (n_left_from > 0 && n_left_to_next > 0)
1767 u32 bi0, ack0, seq0;
1773 u32 next0 = TCP_SYN_SENT_NEXT_DROP, error0 = TCP_ERROR_ENQUEUED;
1780 n_left_to_next -= 1;
1785 tcp.connection_index);
1813 if (ack0 <= tc0->iss || ack0 > tc0->snd_nxt)
1822 if (tc0->snd_una > ack0)
1861 pool_get (tm->connections[my_thread_index], new_tc0);
1864 new_tc0->c_thread_index = my_thread_index;
1865 new_tc0->c_c_index = new_tc0 - tm->connections[my_thread_index];
1868 pool_put (tm->half_open_connections, tc0);
1871 new_tc0->irs = seq0;
1879 new_tc0->tsval_recent = new_tc0->rcv_opts.tsval;
1884 new_tc0->snd_wscale = new_tc0->rcv_opts.wscale;
1886 new_tc0->snd_wnd = clib_net_to_host_u16 (tcp0->window)
1887 << new_tc0->snd_wscale;
1888 new_tc0->snd_wl1 = seq0;
1889 new_tc0->snd_wl2 = ack0;
1899 new_tc0->snd_una = ack0;
1900 new_tc0->state = TCP_STATE_ESTABLISHED;
1903 new_tc0->rcv_las = new_tc0->rcv_nxt;
1919 new_tc0->flags |= TCP_CONN_SNDACK;
1924 new_tc0->state = TCP_STATE_SYN_RCVD;
1928 (&new_tc0->connection, sst, 0))
1951 if (error0 == TCP_ERROR_PURE_ACK)
1952 error0 = TCP_ERROR_SYN_ACKS_RCVD;
1972 n_left_to_next, bi0, next0);
1983 TCP_ERROR_EVENT_FIFO_FULL, errors);
1986 TCP_ERROR_EVENT_FIFO_FULL, errors);
2010 .name =
"tcp4-syn-sent",
2012 .vector_size =
sizeof (
u32),
2018 #define _(s,n) [TCP_SYN_SENT_NEXT_##s] = n, 2032 .name =
"tcp6-syn-sent",
2034 .vector_size =
sizeof (
u32),
2040 #define _(s,n) [TCP_SYN_SENT_NEXT_##s] = n, 2058 u32 n_left_from, next_index, *from, *to_next;
2066 while (n_left_from > 0)
2072 while (n_left_from > 0 && n_left_to_next > 0)
2078 u32 next0 = TCP_RCV_PROCESS_NEXT_DROP, error0 = TCP_ERROR_ENQUEUED;
2085 n_left_to_next -= 1;
2092 error0 = TCP_ERROR_INVALID_CONNECTION;
2108 case TCP_STATE_CLOSED:
2121 error0 = TCP_ERROR_SEGMENT_INVALID;
2128 case TCP_STATE_SYN_RCVD:
2142 tc0->bytes_acked = 1;
2146 tc0->state = TCP_STATE_ESTABLISHED;
2150 tc0->snd_wnd = clib_net_to_host_u16 (tcp0->window)
2151 << tc0->rcv_opts.wscale;
2161 case TCP_STATE_ESTABLISHED:
2168 case TCP_STATE_FIN_WAIT_1:
2176 if (tc0->snd_una == tc0->snd_una_max)
2178 tc0->state = TCP_STATE_FIN_WAIT_2;
2183 case TCP_STATE_FIN_WAIT_2:
2191 case TCP_STATE_CLOSE_WAIT:
2196 case TCP_STATE_CLOSING:
2204 tc0->state = TCP_STATE_TIME_WAIT;
2208 case TCP_STATE_LAST_ACK:
2224 tc0->state = TCP_STATE_CLOSED;
2238 case TCP_STATE_TIME_WAIT:
2262 case TCP_STATE_ESTABLISHED:
2263 case TCP_STATE_FIN_WAIT_1:
2264 case TCP_STATE_FIN_WAIT_2:
2270 case TCP_STATE_CLOSE_WAIT:
2271 case TCP_STATE_CLOSING:
2272 case TCP_STATE_LAST_ACK:
2273 case TCP_STATE_TIME_WAIT:
2285 case TCP_STATE_ESTABLISHED:
2286 case TCP_STATE_SYN_RCVD:
2292 tc0->state = TCP_STATE_CLOSE_WAIT;
2294 case TCP_STATE_CLOSE_WAIT:
2295 case TCP_STATE_CLOSING:
2296 case TCP_STATE_LAST_ACK:
2299 case TCP_STATE_FIN_WAIT_1:
2300 tc0->state = TCP_STATE_TIME_WAIT;
2304 case TCP_STATE_FIN_WAIT_2:
2306 tc0->state = TCP_STATE_TIME_WAIT;
2312 case TCP_STATE_TIME_WAIT:
2332 n_left_to_next, bi0, next0);
2343 TCP_ERROR_EVENT_FIFO_FULL, errors);
2346 TCP_ERROR_EVENT_FIFO_FULL, errors);
2370 .name =
"tcp4-rcv-process",
2372 .vector_size =
sizeof (
u32),
2378 #define _(s,n) [TCP_RCV_PROCESS_NEXT_##s] = n, 2392 .name =
"tcp6-rcv-process",
2394 .vector_size =
sizeof (
u32),
2400 #define _(s,n) [TCP_RCV_PROCESS_NEXT_##s] = n, 2420 u32 n_left_from, next_index, *from, *to_next;
2423 u8 sst = is_ip4 ? SESSION_TYPE_IP4_TCP : SESSION_TYPE_IP6_TCP;
2430 while (n_left_from > 0)
2436 while (n_left_from > 0 && n_left_to_next > 0)
2446 u32 error0 = TCP_ERROR_SYNS_RCVD, next0 = TCP_LISTEN_NEXT_DROP;
2453 n_left_to_next -= 1;
2485 pool_get (tm->connections[my_thread_index], child0);
2486 memset (child0, 0,
sizeof (*child0));
2488 child0->c_c_index = child0 - tm->connections[my_thread_index];
2489 child0->c_lcl_port = lc0->c_lcl_port;
2490 child0->c_rmt_port = th0->src_port;
2491 child0->c_is_ip4 = is_ip4;
2492 child0->c_thread_index = my_thread_index;
2493 child0->state = TCP_STATE_SYN_RCVD;
2511 error0 = TCP_ERROR_CREATE_SESSION_FAIL;
2521 child0->rcv_nxt =
vnet_buffer (b0)->tcp.seq_number + 1;
2522 child0->rcv_las = child0->rcv_nxt;
2528 child0->tsval_recent = child0->rcv_opts.tsval;
2533 child0->snd_wscale = child0->rcv_opts.wscale;
2535 child0->snd_wnd = clib_net_to_host_u16 (th0->window)
2536 << child0->snd_wscale;
2537 child0->snd_wl1 =
vnet_buffer (b0)->tcp.seq_number;
2538 child0->snd_wl2 =
vnet_buffer (b0)->tcp.ack_number;
2564 n_left_to_next, bi0, next0);
2590 .name =
"tcp4-listen",
2592 .vector_size =
sizeof (
u32),
2598 #define _(s,n) [TCP_LISTEN_NEXT_##s] = n, 2612 .name =
"tcp6-listen",
2614 .vector_size =
sizeof (
u32),
2620 #define _(s,n) [TCP_LISTEN_NEXT_##s] = n, 2633 typedef enum _tcp_input_next
2644 #define foreach_tcp4_input_next \ 2645 _ (DROP, "error-drop") \ 2646 _ (LISTEN, "tcp4-listen") \ 2647 _ (RCV_PROCESS, "tcp4-rcv-process") \ 2648 _ (SYN_SENT, "tcp4-syn-sent") \ 2649 _ (ESTABLISHED, "tcp4-established") \ 2650 _ (RESET, "tcp4-reset") 2652 #define foreach_tcp6_input_next \ 2653 _ (DROP, "error-drop") \ 2654 _ (LISTEN, "tcp6-listen") \ 2655 _ (RCV_PROCESS, "tcp6-rcv-process") \ 2656 _ (SYN_SENT, "tcp6-syn-sent") \ 2657 _ (ESTABLISHED, "tcp6-established") \ 2658 _ (RESET, "tcp6-reset") 2660 #define filter_flags (TCP_FLAG_SYN|TCP_FLAG_ACK|TCP_FLAG_RST|TCP_FLAG_FIN) 2666 u32 n_left_from, next_index, *from, *to_next;
2675 while (n_left_from > 0)
2681 while (n_left_from > 0 && n_left_to_next > 0)
2683 int n_advance_bytes0, n_data_bytes0;
2698 n_left_to_next -= 1;
2711 n_data_bytes0 = clib_net_to_host_u16 (ip40->
length)
2721 SESSION_TYPE_IP4_TCP,
2731 n_advance_bytes0 +=
sizeof (ip60[0]);
2739 SESSION_TYPE_IP6_TCP,
2746 error0 = TCP_ERROR_LENGTH;
2754 vnet_buffer (b0)->tcp.connection_index = tc0->c_c_index;
2756 clib_net_to_host_u32 (tcp0->seq_number);
2758 clib_net_to_host_u32 (tcp0->ack_number);
2762 vnet_buffer (b0)->tcp.data_offset = n_advance_bytes0;
2766 next0 = tm->dispatch_table[tc0->state][flags0].next;
2767 error0 = tm->dispatch_table[tc0->state][flags0].error;
2776 if (error0 == TCP_ERROR_DISPATCH)
2786 error0 = TCP_ERROR_NO_LISTENER;
2799 n_left_to_next, bi0, next0);
2826 .name =
"tcp4-input",
2828 .vector_size =
sizeof (
u32),
2834 #define _(s,n) [TCP_INPUT_NEXT_##s] = n, 2849 .name =
"tcp6-input",
2851 .vector_size =
sizeof (
u32),
2857 #define _(s,n) [TCP_INPUT_NEXT_##s] = n, 2872 for (i = 0; i <
ARRAY_LEN (tm->dispatch_table); i++)
2873 for (j = 0; j <
ARRAY_LEN (tm->dispatch_table[i]); j++)
2876 tm->dispatch_table[
i][j].error = TCP_ERROR_DISPATCH;
2879 #define _(t,f,n,e) \ 2881 tm->dispatch_table[TCP_STATE_##t][f].next = (n); \ 2882 tm->dispatch_table[TCP_STATE_##t][f].error = (e); \ #define tcp_in_cong_recovery(tc)
int session_manager_flush_enqueue_events(u32 thread_index)
Flushes queue of sessions that are to be notified of new data enqueued events.
sll srl srl sll sra u16x4 i
#define tcp_fastrecovery_1_smss_off(tc)
#define tcp_in_recovery(tc)
#define TCP_OPTION_LEN_SACK_PERMITTED
#define seq_leq(_s1, _s2)
void tcp_make_fin(tcp_connection_t *tc, vlib_buffer_t *b)
Convert buffer to FIN-ACK.
void tcp_send_reset(vlib_buffer_t *pkt, u8 is_ip4)
Send reset without reusing existing buffer.
struct _sack_block sack_block_t
int stream_session_accept(transport_connection_t *tc, u32 listener_index, u8 sst, u8 notify)
Accept a stream session.
#define tcp_opts_tstamp(_to)
void tcp_fast_retransmit(tcp_connection_t *tc)
Do fast retransmit.
int stream_session_enqueue_data(transport_connection_t *tc, vlib_buffer_t *b, u32 offset, u8 queue_event, u8 is_in_order)
static int ip4_header_bytes(ip4_header_t *i)
struct _sack_scoreboard sack_scoreboard_t
static tcp_connection_t * tcp_half_open_connection_get(u32 conn_index)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
struct _tcp_main tcp_main_t
void tcp_connection_timers_reset(tcp_connection_t *tc)
Stop all connection timers.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define tcp_recovery_off(tc)
struct _vlib_node_registration vlib_node_registration_t
static sack_scoreboard_hole_t * scoreboard_prev_hole(sack_scoreboard_t *sb, sack_scoreboard_hole_t *hole)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
struct _tcp_connection tcp_connection_t
#define tcp_opts_sack(_to)
void tcp_fast_retransmit_sack(tcp_connection_t *tc)
Do fast retransmit with SACKs.
tcp_connection_t tcp_connection
vlib_error_t * errors
Vector of errors for this node.
format_function_t format_tcp_flags
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
u8 n_sack_blocks
Number of SACKs blocks.
struct _tcp_header tcp_header_t
static u32 tcp_available_snd_space(const tcp_connection_t *tc)
struct _sack_scoreboard_hole sack_scoreboard_hole_t
u8 wscale
Window scale advertised.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
struct _stream_session_t stream_session_t
#define tcp_fastrecovery_on(tc)
static u32 scoreboard_hole_index(sack_scoreboard_t *sb, sack_scoreboard_hole_t *hole)
#define VLIB_INIT_FUNCTION(x)
#define TCP_CLOSEWAIT_TIME
void stream_session_accept_notify(transport_connection_t *tc)
#define TCP_OPTION_LEN_SACK_BLOCK
static tcp_header_t * tcp_buffer_hdr(vlib_buffer_t *b)
enum _tcp_state tcp_state_t
#define TCP_ALWAYS_ACK
On/off delayed acks.
static u32 ooo_segment_length(svm_fifo_t *f, ooo_segment_t *s)
static void * ip4_next_header(ip4_header_t *i)
static u32 tcp_time_now(void)
sack_block_t * sacks
SACK blocks.
#define vec_end(v)
End (last data address) of vector.
static tcp_cc_algorithm_t * tcp_cc_algo_get(tcp_cc_algorithm_type_e type)
static u32 scoreboard_hole_bytes(sack_scoreboard_hole_t *hole)
#define vlib_call_init_function(vm, x)
#define TCP_MAX_SACK_BLOCKS
Max number of SACK blocks stored.
#define tcp_validate_txf_size(_tc, _a)
int stream_session_connect_notify(transport_connection_t *tc, u8 sst, u8 is_fail)
#define TCP_EVT_DBG(_evt, _args...)
transport_connection_t * stream_session_lookup_transport4(ip4_address_t *lcl, ip4_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 my_thread_index)
#define timestamp_lt(_t1, _t2)
static void tcp_timer_set(tcp_connection_t *tc, u8 timer_id, u32 interval)
#define TCP_OPTION_LEN_WINDOW_SCALE
u32 stream_session_dequeue_drop(transport_connection_t *tc, u32 max_bytes)
#define TCP_INVALID_SACK_HOLE_INDEX
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define tcp_in_fastrecovery(tc)
void tcp_retransmit_first_unacked(tcp_connection_t *tc)
Retransmit first unacked segment.
static sack_scoreboard_hole_t * scoreboard_next_hole(sack_scoreboard_t *sb, sack_scoreboard_hole_t *hole)
static u32 ooo_segment_offset(svm_fifo_t *f, ooo_segment_t *s)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define pool_put(P, E)
Free an object E in pool P.
void tcp_fast_retransmit_no_sack(tcp_connection_t *tc)
Fast retransmit without SACK info.
#define vec_del1(v, i)
Delete the element at index I.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
static sack_scoreboard_hole_t * scoreboard_last_hole(sack_scoreboard_t *sb)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
#define TCP_OPTION_LEN_TIMESTAMP
static ooo_segment_t * svm_fifo_newest_ooo_segment(svm_fifo_t *f)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define TCP_MAX_WND_SCALE
static void tcp_timer_reset(tcp_connection_t *tc, u8 timer_id)
static sack_scoreboard_hole_t * scoreboard_first_hole(sack_scoreboard_t *sb)
#define vec_free(V)
Free vector's memory (no header).
#define TCP_DUPACK_THRESHOLD
format_function_t format_tcp_state
#define clib_warning(format, args...)
#define VLIB_BUFFER_IS_TRACED
void stream_session_init_fifos_pointers(transport_connection_t *tc, u32 rx_pointer, u32 tx_pointer)
Init fifo tail and head pointers.
#define clib_memcpy(a, b, c)
void tcp_make_synack(tcp_connection_t *ts, vlib_buffer_t *b)
Convert buffer to SYN-ACK.
u16 mss
Option flags, see above.
static void * ip6_next_header(ip6_header_t *i)
void tcp_make_ack(tcp_connection_t *ts, vlib_buffer_t *b)
Convert buffer to ACK.
void stream_session_disconnect_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
static void tcp_timer_update(tcp_connection_t *tc, u8 timer_id, u32 interval)
#define TCP_PAWS_IDLE
24 days
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define seq_geq(_s1, _s2)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define tcp_opts_wscale(_to)
static sack_scoreboard_hole_t * scoreboard_get_hole(sack_scoreboard_t *sb, u32 index)
void tcp_connection_reset(tcp_connection_t *tc)
Notify session that connection has been reset.
u32 tsval
Timestamp value.
u32 tsecr
Echoed/reflected time stamp.
void tcp_send_fin(tcp_connection_t *tc)
Send FIN.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void tcp_retransmit_timer_update(tcp_connection_t *tc)
#define seq_max(_s1, _s2)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
void tcp_connection_init_vars(tcp_connection_t *tc)
Initialize tcp connection variables.
#define TCP_OPTION_LEN_MSS
clib_error_t * tcp_init(vlib_main_t *vm)
u8 * format_tcp_connection(u8 *s, va_list *args)
static tcp_connection_t * tcp_connection_get(u32 conn_index, u32 thread_index)
#define VLIB_REGISTER_NODE(x,...)
static int tcp_header_bytes(tcp_header_t *t)
void tcp_connection_cleanup(tcp_connection_t *tc)
Cleans up connection state.
#define tcp_opts_sack_permitted(_to)
transport_connection_t * stream_session_lookup_transport6(ip6_address_t *lcl, ip6_address_t *rmt, u16 lcl_port, u16 rmt_port, u8 proto, u32 my_thread_index)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static void tcp_persist_timer_set(tcp_connection_t *tc)
static tcp_main_t * vnet_get_tcp_main()
#define tcp_fastrecovery_off(tc)
static void tcp_retransmit_timer_reset(tcp_connection_t *tc)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u8 tcp_timer_is_active(tcp_connection_t *tc, tcp_timers_e timer)
static tcp_connection_t * tcp_listener_get(u32 tli)
static stream_session_t * stream_session_get(u32 si, u32 thread_index)
static void tcp_persist_timer_reset(tcp_connection_t *tc)