static timer_expiration_handler *timer_expiration_handlers[TCP_N_TIMERS] =
{
tcp_timer_retransmit_handler,
- tcp_timer_delack_handler,
tcp_timer_persist_handler,
tcp_timer_waitclose_handler,
tcp_timer_retransmit_syn_handler,
if (PREDICT_FALSE (!tc))
continue;
+ /* Skip if the timer is not pending. Probably it was reset while
+ * wating for dispatch */
+ if (PREDICT_FALSE (!(tc->pending_timers & (1 << timer_id))))
+ continue;
+
+ tc->pending_timers &= ~(1 << timer_id);
+
/* Skip timer if it was rearmed while pending dispatch */
if (PREDICT_FALSE (tc->timers[timer_id] != TCP_TIMER_HANDLE_INVALID))
continue;
TCP_EVT (TCP_EVT_TIMER_POP, connection_index, timer_id);
tc->timers[timer_id] = TCP_TIMER_HANDLE_INVALID;
+ tc->pending_timers |= (1 << timer_id);
}
clib_fifo_add (wrk->pending_timers, expired_timers, n_expired);
typedef void (timer_expiration_handler) (tcp_connection_t * tc);
-extern timer_expiration_handler tcp_timer_delack_handler;
extern timer_expiration_handler tcp_timer_retransmit_handler;
extern timer_expiration_handler tcp_timer_persist_handler;
extern timer_expiration_handler tcp_timer_retransmit_syn_handler;
return TCP_ERROR_ENQUEUED_OOO;
}
-/**
- * Check if ACK could be delayed. If ack can be delayed, it should return
- * true for a full frame. If we're always acking return 0.
- */
-always_inline int
-tcp_can_delack (tcp_connection_t * tc)
-{
- /* Send ack if ... */
- if (TCP_ALWAYS_ACK
- /* just sent a rcv wnd 0
- || (tc->flags & TCP_CONN_SENT_RCV_WND0) != 0 */
- /* constrained to send ack */
- || (tc->flags & TCP_CONN_SNDACK) != 0
- /* we're almost out of tx wnd */
- || tcp_available_cc_snd_space (tc) < 4 * tc->snd_mss)
- return 0;
-
- return 1;
-}
-
static int
tcp_buffer_discard_bytes (vlib_buffer_t * b, u32 n_bytes_to_drop)
{
/* In order data, enqueue. Fifo figures out by itself if any out-of-order
* segments can be enqueued after fifo tail offset changes. */
error = tcp_session_enqueue_data (tc, b, n_data_bytes);
- if (tcp_can_delack (tc))
- {
- if (!tcp_timer_is_active (tc, TCP_TIMER_DELACK))
- tcp_timer_set (&wrk->timer_wheel, tc, TCP_TIMER_DELACK,
- tcp_cfg.delack_time);
- goto done;
- }
-
tcp_program_ack (tc);
done:
}
}
-/**
- * Delayed ack timer handler
- *
- * Sends delayed ACK when timer expires
- */
-void
-tcp_timer_delack_handler (tcp_connection_t * tc)
-{
- tcp_send_ack (tc);
-}
-
/**
* Send window update ack
*
tcp_timer_reset (tcp_timer_wheel_t * tw, tcp_connection_t * tc, u8 timer_id)
{
ASSERT (tc->c_thread_index == vlib_get_thread_index ());
+ tc->pending_timers &= ~(1 << timer_id);
if (tc->timers[timer_id] == TCP_TIMER_HANDLE_INVALID)
return;
/** TCP timers */
#define foreach_tcp_timer \
_(RETRANSMIT, "RETRANSMIT") \
- _(DELACK, "DELAYED ACK") \
_(PERSIST, "PERSIST") \
_(WAITCLOSE, "WAIT CLOSE") \
_(RETRANSMIT_SYN, "RETRANSMIT SYN") \
u8 cfg_flags; /**< Connection configuration flags */
u16 flags; /**< Connection flags (see tcp_conn_flags_e) */
u32 timers[TCP_N_TIMERS]; /**< Timer handles into timer wheel */
+ u32 pending_timers; /**< Expired timers not yet handled */
u64 segs_in; /** RFC4022/4898 tcpHCInSegs/tcpEStatsPerfSegsIn */
u64 bytes_in; /** RFC4898 tcpEStatsPerfHCDataOctetsIn */