if (PREDICT_FALSE (tcp_segment_check_paws (tc0)))
{
*error0 = TCP_ERROR_PAWS;
- TCP_EVT_DBG (TCP_EVT_PAWS_FAIL, tc0, vnet_buffer (b0)->tcp.seq_number,
- vnet_buffer (b0)->tcp.seq_end);
+ TCP_EVT (TCP_EVT_PAWS_FAIL, tc0, vnet_buffer (b0)->tcp.seq_number,
+ vnet_buffer (b0)->tcp.seq_end);
/* If it just so happens that a segment updates tsval_recent for a
* segment over 24 days old, invalidate tsval_recent. */
else if (!tcp_rst (th0))
{
tcp_program_ack (tc0);
- TCP_EVT_DBG (TCP_EVT_DUPACK_SENT, tc0, vnet_buffer (b0)->tcp);
+ TCP_EVT (TCP_EVT_DUPACK_SENT, tc0, vnet_buffer (b0)->tcp);
goto error;
}
}
if (tc0->state == TCP_STATE_SYN_RCVD)
{
tcp_send_synack (tc0);
- TCP_EVT_DBG (TCP_EVT_SYN_RCVD, tc0, 0);
+ TCP_EVT (TCP_EVT_SYN_RCVD, tc0, 0);
*error0 = TCP_ERROR_SYNS_RCVD;
}
else
{
tcp_program_ack (tc0);
- TCP_EVT_DBG (TCP_EVT_SYNACK_RCVD, tc0);
+ TCP_EVT (TCP_EVT_SYNACK_RCVD, tc0);
*error0 = TCP_ERROR_SYN_ACKS_RCVD;
}
goto error;
*error0 = TCP_ERROR_RCV_WND;
+ /* If we advertised a zero rcv_wnd and the segment is in the past or the
+ * next one that we expect, it is probably a window probe */
+ if ((tc0->flags & TCP_CONN_ZERO_RWND_SENT)
+ && seq_lt (vnet_buffer (b0)->tcp.seq_end,
+ tc0->rcv_las + tc0->rcv_opts.mss))
+ *error0 = TCP_ERROR_ZERO_RWND;
+
+ tc0->errors.below_data_wnd += seq_lt (vnet_buffer (b0)->tcp.seq_end,
+ tc0->rcv_las);
+
/* If not RST, send dup ack */
if (!tcp_rst (th0))
{
tcp_program_dupack (tc0);
- TCP_EVT_DBG (TCP_EVT_DUPACK_SENT, tc0, vnet_buffer (b0)->tcp);
+ TCP_EVT (TCP_EVT_DUPACK_SENT, tc0, vnet_buffer (b0)->tcp);
}
goto error;
|| sb->holes[sb->head].start == ack + sb->snd_una_adv);
ASSERT (sb->last_lost_bytes <= sb->lost_bytes);
- TCP_EVT_DBG (TCP_EVT_CC_SCOREBOARD, tc);
+ TCP_EVT (TCP_EVT_CC_SCOREBOARD, tc);
}
#endif /* CLIB_MARCH_VARIANT */
tc->snd_wnd = snd_wnd;
tc->snd_wl1 = seq;
tc->snd_wl2 = ack;
- TCP_EVT_DBG (TCP_EVT_SND_WND, tc);
+ TCP_EVT (TCP_EVT_SND_WND, tc);
if (PREDICT_FALSE (tc->snd_wnd < tc->snd_mss))
{
tc->prev_ssthresh = tc->ssthresh;
tc->prev_cwnd = tc->cwnd;
tc->cc_algo->congestion (tc);
- TCP_EVT_DBG (TCP_EVT_CC_EVT, tc, 4);
+ tc->fr_occurences += 1;
+ TCP_EVT (TCP_EVT_CC_EVT, tc, 4);
}
#endif /* CLIB_MARCH_VARIANT */
tc->snd_rxt_ts = 0;
tc->rtt_ts = 0;
tcp_recovery_off (tc);
- TCP_EVT_DBG (TCP_EVT_CC_EVT, tc, 3);
+ TCP_EVT (TCP_EVT_CC_EVT, tc, 3);
}
#ifndef CLIB_MARCH_VARIANT
tcp_fastrecovery_first_off (tc);
tc->flags &= ~TCP_CONN_FRXT_PENDING;
- TCP_EVT_DBG (TCP_EVT_CC_EVT, tc, 3);
+ TCP_EVT (TCP_EVT_CC_EVT, tc, 3);
}
#endif /* CLIB_MARCH_VARIANT */
}
tcp_cc_undo_recovery (tc);
ASSERT (tc->rto_boff == 0);
- TCP_EVT_DBG (TCP_EVT_CC_EVT, tc, 5);
+ TCP_EVT (TCP_EVT_CC_EVT, tc, 5);
}
static inline u8
*/
else if (is_dack && !tcp_in_recovery (tc))
{
- TCP_EVT_DBG (TCP_EVT_DUPACK_RCVD, tc, 1);
+ TCP_EVT (TCP_EVT_DUPACK_RCVD, tc, 1);
ASSERT (tc->snd_una != tc->snd_nxt || tc->sack_sb.last_sacked_bytes);
tc->rcv_dupacks++;
}
tcp_cc_init_congestion (tc);
- tcp_cc_rcv_cong_ack (tc, TCP_CC_DUPACK, rs);
if (tcp_opts_sack_permitted (&tc->rcv_opts))
- {
- tc->cwnd = tc->ssthresh;
- scoreboard_init_high_rxt (&tc->sack_sb, tc->snd_una);
- }
- else
- {
- /* Post retransmit update cwnd to ssthresh and account for the
- * three segments that have left the network and should've been
- * buffered at the receiver XXX */
- tc->cwnd = tc->ssthresh + 3 * tc->snd_mss;
- }
+ scoreboard_init_high_rxt (&tc->sack_sb, tc->snd_una);
/* Constrain rate until we get a partial ack */
pacer_wnd = clib_max (0.1 * tc->cwnd, 2 * tc->snd_mss);
return;
partial_ack:
- TCP_EVT_DBG (TCP_EVT_CC_PACK, tc);
+ TCP_EVT (TCP_EVT_CC_PACK, tc);
/*
* Legitimate ACK. 1) See if we can exit recovery
tcp_rate_sample_t rs = { 0 };
u8 is_dack;
- TCP_EVT_DBG (TCP_EVT_CC_STAT, tc);
+ TCP_EVT (TCP_EVT_CC_STAT, tc);
/* If the ACK acks something not yet sent (SEG.ACK > SND.NXT) */
if (PREDICT_FALSE (seq_gt (vnet_buffer (b)->tcp.ack_number, tc->snd_nxt)))
goto process_ack;
}
+ tc->errors.above_ack_wnd += 1;
*error = TCP_ERROR_ACK_FUTURE;
- TCP_EVT_DBG (TCP_EVT_ACK_RCV_ERR, tc, 0,
- vnet_buffer (b)->tcp.ack_number);
+ TCP_EVT (TCP_EVT_ACK_RCV_ERR, tc, 0, vnet_buffer (b)->tcp.ack_number);
return -1;
}
/* If old ACK, probably it's an old dupack */
if (PREDICT_FALSE (seq_lt (vnet_buffer (b)->tcp.ack_number, tc->snd_una)))
{
+ tc->errors.below_ack_wnd += 1;
*error = TCP_ERROR_ACK_OLD;
- TCP_EVT_DBG (TCP_EVT_ACK_RCV_ERR, tc, 1,
- vnet_buffer (b)->tcp.ack_number);
+ TCP_EVT (TCP_EVT_ACK_RCV_ERR, tc, 1, vnet_buffer (b)->tcp.ack_number);
if (tcp_in_fastrecovery (tc) && tc->rcv_dupacks == TCP_DUPACK_THRESHOLD)
tcp_cc_handle_event (tc, 0, 1);
/* Don't drop yet */
/*
* Looks okay, process feedback
*/
+
if (tcp_opts_sack_permitted (&tc->rcv_opts))
tcp_rcv_sacks (tc, vnet_buffer (b)->tcp.ack_number);
if (tc->flags & TCP_CONN_RATE_SAMPLE)
tcp_bt_sample_delivery_rate (tc, &rs);
- TCP_EVT_DBG (TCP_EVT_ACK_RCVD, tc);
+ TCP_EVT (TCP_EVT_ACK_RCVD, tc);
/*
* Check if we have congestion event
if (tcp_ack_is_cc_event (tc, b, prev_snd_wnd, prev_snd_una, &is_dack))
{
tcp_cc_handle_event (tc, &rs, is_dack);
+ tc->dupacks_in += is_dack;
if (!tcp_in_cong_recovery (tc))
{
*error = TCP_ERROR_ACK_OK;
* in CLOSE-WAIT, set timer (reuse WAITCLOSE). */
tcp_connection_set_state (tc, TCP_STATE_CLOSE_WAIT);
tcp_program_disconnect (wrk, tc);
- tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME);
- TCP_EVT_DBG (TCP_EVT_FIN_RCVD, tc);
+ tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, tcp_cfg.closewait_time);
+ TCP_EVT (TCP_EVT_FIN_RCVD, tc);
*error = TCP_ERROR_FIN_RCVD;
}
ASSERT (data_len);
written = session_enqueue_stream_connection (&tc->connection, b, 0,
1 /* queue event */ , 1);
+ tc->bytes_in += written;
- TCP_EVT_DBG (TCP_EVT_INPUT, tc, 0, data_len, written);
+ TCP_EVT (TCP_EVT_INPUT, tc, 0, data_len, written);
/* Update rcv_nxt */
if (PREDICT_TRUE (written == data_len))
else if (written > data_len)
{
tc->rcv_nxt += written;
- TCP_EVT_DBG (TCP_EVT_CC_INPUT, tc, data_len, written);
+ TCP_EVT (TCP_EVT_CC_INPUT, tc, data_len, written);
}
else if (written > 0)
{
/* Nothing written */
if (rv)
{
- TCP_EVT_DBG (TCP_EVT_INPUT, tc, 1, data_len, 0);
+ TCP_EVT (TCP_EVT_INPUT, tc, 1, data_len, 0);
return TCP_ERROR_FIFO_FULL;
}
- TCP_EVT_DBG (TCP_EVT_INPUT, tc, 1, data_len, data_len);
+ TCP_EVT (TCP_EVT_INPUT, tc, 1, data_len, data_len);
+ tc->bytes_in += data_len;
/* Update SACK list if in use */
if (tcp_opts_sack_permitted (&tc->rcv_opts))
end = start + ooo_segment_length (s0->rx_fifo, newest);
tcp_update_sack_list (tc, start, end);
svm_fifo_newest_ooo_segment_reset (s0->rx_fifo);
- TCP_EVT_DBG (TCP_EVT_CC_SACKS, tc);
+ TCP_EVT (TCP_EVT_CC_SACKS, tc);
}
}
vlib_buffer_advance (b, vnet_buffer (b)->tcp.data_offset);
n_data_bytes = vnet_buffer (b)->tcp.data_len;
ASSERT (n_data_bytes);
+ tc->data_segs_in += 1;
/* Handle out-of-order data */
if (PREDICT_FALSE (vnet_buffer (b)->tcp.seq_number != tc->rcv_nxt))
/* RFC2581: Enqueue and send DUPACK for fast retransmit */
error = tcp_session_enqueue_ooo (tc, b, n_data_bytes);
tcp_program_dupack (tc);
- TCP_EVT_DBG (TCP_EVT_DUPACK_SENT, tc, vnet_buffer (b)->tcp);
+ TCP_EVT (TCP_EVT_DUPACK_SENT, tc, vnet_buffer (b)->tcp);
+ tc->errors.above_data_wnd += seq_gt (vnet_buffer (b)->tcp.seq_end,
+ tc->rcv_las + tc->rcv_wnd);
goto done;
}
if (tcp_can_delack (tc))
{
if (!tcp_timer_is_active (tc, TCP_TIMER_DELACK))
- tcp_timer_set (tc, TCP_TIMER_DELACK, TCP_DELACK_TIME);
+ tcp_timer_set (tc, TCP_TIMER_DELACK, tcp_cfg.delack_time);
goto done;
}
/* 1-4: check SEQ, RST, SYN */
if (PREDICT_FALSE (tcp_segment_validate (wrk, tc0, b0, th0, &error0)))
{
- TCP_EVT_DBG (TCP_EVT_SEG_INVALID, tc0, vnet_buffer (b0)->tcp);
+ TCP_EVT (TCP_EVT_SEG_INVALID, tc0, vnet_buffer (b0)->tcp);
goto done;
}
tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * from_frame, int is_ip4)
{
- tcp_main_t *tm = vnet_get_tcp_main ();
u32 n_left_from, *from, *first_buffer, errors = 0;
u32 my_thread_index = vm->thread_index;
tcp_worker_ctx_t *wrk = tcp_get_worker (my_thread_index);
/* Valid SYN or SYN-ACK. Move connection from half-open pool to
* current thread pool. */
- pool_get (tm->connections[my_thread_index], new_tc0);
- clib_memcpy_fast (new_tc0, tc0, sizeof (*new_tc0));
- new_tc0->c_c_index = new_tc0 - tm->connections[my_thread_index];
- new_tc0->c_thread_index = my_thread_index;
+ new_tc0 = tcp_connection_alloc_w_base (my_thread_index, tc0);
new_tc0->rcv_nxt = vnet_buffer (b0)->tcp.seq_end;
new_tc0->irs = seq0;
- new_tc0->timers[TCP_TIMER_ESTABLISH_AO] = TCP_TIMER_HANDLE_INVALID;
new_tc0->timers[TCP_TIMER_RETRANSMIT_SYN] = TCP_TIMER_HANDLE_INVALID;
new_tc0->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX];
transport_tx_fifo_size (&new_tc0->connection);
/* Update rtt with the syn-ack sample */
tcp_estimate_initial_rtt (new_tc0);
- TCP_EVT_DBG (TCP_EVT_SYNACK_RCVD, new_tc0);
+ TCP_EVT (TCP_EVT_SYNACK_RCVD, new_tc0);
error0 = TCP_ERROR_SYN_ACKS_RCVD;
}
/* SYN: Simultaneous open. Change state to SYN-RCVD and send SYN-ACK */
{
tcp_connection_cleanup (new_tc0);
tcp_send_reset_w_pkt (tc0, b0, my_thread_index, is_ip4);
- TCP_EVT_DBG (TCP_EVT_RST_SENT, tc0);
+ TCP_EVT (TCP_EVT_RST_SENT, tc0);
error0 = TCP_ERROR_CREATE_SESSION_FAIL;
goto drop;
}
/* Switch state to ESTABLISHED */
tc0->state = TCP_STATE_ESTABLISHED;
- TCP_EVT_DBG (TCP_EVT_STATE_CHANGE, tc0);
+ TCP_EVT (TCP_EVT_STATE_CHANGE, tc0);
/* Initialize session variables */
tc0->snd_una = vnet_buffer (b0)->tcp.ack_number;
/* Reset SYN-ACK retransmit and SYN_RCV establish timers */
tcp_retransmit_timer_reset (tc0);
- tcp_timer_reset (tc0, TCP_TIMER_ESTABLISH);
if (session_stream_accept_notify (&tc0->connection))
{
error0 = TCP_ERROR_MSG_QUEUE_FULL;
/* If a fin was received and data was acked extend wait */
else if ((tc0->flags & TCP_CONN_FINRCVD) && tc0->bytes_acked)
tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE,
- TCP_CLOSEWAIT_TIME);
+ tcp_cfg.closewait_time);
}
/* If FIN is ACKed */
else if (tc0->snd_una == tc0->snd_nxt)
if (tc0->flags & TCP_CONN_FINRCVD)
{
tcp_connection_set_state (tc0, TCP_STATE_CLOSED);
- tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME);
+ tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE,
+ tcp_cfg.cleanup_time);
session_transport_closed_notify (&tc0->connection);
goto drop;
}
tcp_connection_set_state (tc0, TCP_STATE_FIN_WAIT_2);
/* Enable waitclose because we're willing to wait for peer's
* FIN but not indefinitely. */
- tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, TCP_2MSL_TIME);
+ tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, tcp_cfg.finwait2_time);
/* Don't try to deq the FIN acked */
if (tc0->burst_acked > 1)
tcp_send_fin (tc0);
tcp_connection_timers_reset (tc0);
tcp_connection_set_state (tc0, TCP_STATE_LAST_ACK);
- tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, TCP_2MSL_TIME);
+ tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, tcp_cfg.lastack_time);
break;
case TCP_STATE_CLOSING:
/* In addition to the processing for the ESTABLISHED state, if
tcp_connection_timers_reset (tc0);
tcp_connection_set_state (tc0, TCP_STATE_TIME_WAIT);
- tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, TCP_TIMEWAIT_TIME);
+ tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, tcp_cfg.timewait_time);
session_transport_closed_notify (&tc0->connection);
goto drop;
* we can't ensure that we have no packets already enqueued
* to output. Rely instead on the waitclose timer */
tcp_connection_timers_reset (tc0);
- tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, TCP_CLEANUP_TIME);
+ tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, tcp_cfg.cleanup_time);
goto drop;
goto drop;
tcp_program_ack (tc0);
- tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_TIMEWAIT_TIME);
+ tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, tcp_cfg.timewait_time);
goto drop;
break;
if (!is_fin0)
goto drop;
- TCP_EVT_DBG (TCP_EVT_FIN_RCVD, tc0);
+ TCP_EVT (TCP_EVT_FIN_RCVD, tc0);
switch (tc0->state)
{
tcp_program_ack (tc0);
tcp_connection_set_state (tc0, TCP_STATE_CLOSE_WAIT);
tcp_program_disconnect (wrk, tc0);
- tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME);
+ tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, tcp_cfg.closewait_time);
break;
case TCP_STATE_SYN_RCVD:
/* Send FIN-ACK, enter LAST-ACK and because the app was not
tc0->rcv_nxt += 1;
tcp_send_fin (tc0);
tcp_connection_set_state (tc0, TCP_STATE_LAST_ACK);
- tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, TCP_2MSL_TIME);
+ tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, tcp_cfg.lastack_time);
break;
case TCP_STATE_CLOSE_WAIT:
case TCP_STATE_CLOSING:
* sending it. Since we already received a fin, do not wait
* for too long. */
tc0->flags |= TCP_CONN_FINRCVD;
- tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_CLOSEWAIT_TIME);
+ tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE,
+ tcp_cfg.closewait_time);
}
else
{
tcp_connection_set_state (tc0, TCP_STATE_CLOSING);
tcp_program_ack (tc0);
/* Wait for ACK for our FIN but not forever */
- tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_2MSL_TIME);
+ tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE,
+ tcp_cfg.closing_time);
}
break;
case TCP_STATE_FIN_WAIT_2:
tc0->rcv_nxt += 1;
tcp_connection_set_state (tc0, TCP_STATE_TIME_WAIT);
tcp_connection_timers_reset (tc0);
- tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, TCP_TIMEWAIT_TIME);
+ tcp_timer_set (tc0, TCP_TIMER_WAITCLOSE, tcp_cfg.timewait_time);
tcp_program_ack (tc0);
session_transport_closed_notify (&tc0->connection);
break;
/* Remain in the TIME-WAIT state. Restart the time-wait
* timeout.
*/
- tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, TCP_TIMEWAIT_TIME);
+ tcp_timer_update (tc0, TCP_TIMER_WAITCLOSE, tcp_cfg.timewait_time);
break;
}
error0 = TCP_ERROR_FIN_RCVD;
child0->c_is_ip4 = is_ip4;
child0->state = TCP_STATE_SYN_RCVD;
child0->c_fib_index = lc0->c_fib_index;
+ child0->cc_algo = lc0->cc_algo;
if (is_ip4)
{
goto drop;
}
- TCP_EVT_DBG (TCP_EVT_SYN_RCVD, child0, 1);
+ TCP_EVT (TCP_EVT_SYN_RCVD, child0, 1);
child0->tx_fifo_size = transport_tx_fifo_size (&child0->connection);
tcp_send_synack (child0);
- tcp_timer_set (child0, TCP_TIMER_ESTABLISH, TCP_SYN_RCVD_TIME);
drop:
flags = tcp->flags & filter_flags;
*next = tm->dispatch_table[tc->state][flags].next;
*error = tm->dispatch_table[tc->state][flags].error;
+ tc->segs_in += 1;
if (PREDICT_FALSE (*error == TCP_ERROR_DISPATCH
|| *next == TCP_INPUT_NEXT_RESET))
TCP_ERROR_NONE);
_(CLOSING, TCP_FLAG_FIN | TCP_FLAG_SYN | TCP_FLAG_ACK,
TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
+ _(CLOSING, TCP_FLAG_FIN | TCP_FLAG_SYN | TCP_FLAG_RST,
+ TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
_(CLOSING, TCP_FLAG_FIN | TCP_FLAG_SYN | TCP_FLAG_RST | TCP_FLAG_ACK,
TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
/* FIN confirming that the peer (app) has closed */