data = (const u8 *) (th + 1);
/* Zero out all flags but those set in SYN */
- to->flags &= (TCP_OPTS_FLAG_SACK_PERMITTED | TCP_OPTS_FLAG_WSCALE);
+ to->flags &= (TCP_OPTS_FLAG_SACK_PERMITTED | TCP_OPTS_FLAG_WSCALE
+ | TCP_OPTS_FLAG_SACK);
for (; opts_len > 0; opts_len -= opt_len, data += opt_len)
{
/* Poison the entry */
if (CLIB_DEBUG > 0)
- memset (hole, 0xfe, sizeof (*hole));
+ clib_memset (hole, 0xfe, sizeof (*hole));
pool_put (sb->holes, hole);
}
u32 hole_index;
pool_get (sb->holes, hole);
- memset (hole, 0, sizeof (*hole));
+ clib_memset (hole, 0, sizeof (*hole));
hole->start = start;
hole->end = end;
static void
scoreboard_update_bytes (tcp_connection_t * tc, sack_scoreboard_t * sb)
{
- sack_scoreboard_hole_t *hole, *prev;
+ sack_scoreboard_hole_t *left, *right;
u32 bytes = 0, blks = 0;
sb->lost_bytes = 0;
sb->sacked_bytes = 0;
- hole = scoreboard_last_hole (sb);
- if (!hole)
+ left = scoreboard_last_hole (sb);
+ if (!left)
return;
- if (seq_gt (sb->high_sacked, hole->end))
+ if (seq_gt (sb->high_sacked, left->end))
{
- bytes = sb->high_sacked - hole->end;
+ bytes = sb->high_sacked - left->end;
blks = 1;
}
- while ((prev = scoreboard_prev_hole (sb, hole))
- && (bytes < (TCP_DUPACK_THRESHOLD - 1) * tc->snd_mss
- && blks < TCP_DUPACK_THRESHOLD))
+ while ((right = left)
+ && bytes < (TCP_DUPACK_THRESHOLD - 1) * tc->snd_mss
+ && blks < TCP_DUPACK_THRESHOLD
+ /* left not updated if above conditions fail */
+ && (left = scoreboard_prev_hole (sb, right)))
{
- bytes += hole->start - prev->end;
+ bytes += right->start - left->end;
blks++;
- hole = prev;
}
- while (hole)
+ /* left is first lost */
+ if (left)
{
- sb->lost_bytes += scoreboard_hole_bytes (hole);
- hole->is_lost = 1;
- prev = hole;
- hole = scoreboard_prev_hole (sb, hole);
- if (hole)
- bytes += prev->start - hole->end;
+ do
+ {
+ sb->lost_bytes += scoreboard_hole_bytes (right);
+ left->is_lost = 1;
+ left = scoreboard_prev_hole (sb, right);
+ if (left)
+ bytes += right->start - left->end;
+ }
+ while ((right = left));
}
+
sb->sacked_bytes = bytes;
}
{
sack_scoreboard_hole_t *hole;
hole = scoreboard_first_hole (&tc->sack_sb);
- return (!hole || seq_geq (hole->start, tc->snd_una));
+ return (!hole || (seq_geq (hole->start, tc->snd_una)
+ && seq_lt (hole->end, tc->snd_una_max)));
}
void
}
}
+ if (pool_elts (sb->holes) == 1)
+ {
+ hole = scoreboard_first_hole (sb);
+ if (hole->start == ack + sb->snd_una_adv
+ && hole->end == tc->snd_una_max)
+ scoreboard_remove_hole (sb, hole);
+ }
+
scoreboard_update_bytes (tc, sb);
sb->last_sacked_bytes = sb->sacked_bytes
- (old_sacked_bytes - sb->last_bytes_delivered);
if (!tcp_in_cong_recovery (tc))
return 0;
*error = TCP_ERROR_ACK_DUP;
- return vnet_buffer (b)->tcp.data_len ? 0 : -1;
+ if (vnet_buffer (b)->tcp.data_len || tcp_is_fin (th))
+ return 0;
+ return -1;
}
/*
tc0->state = TCP_STATE_CLOSED;
TCP_EVT_DBG (TCP_EVT_STATE_CHANGE, tc0);
- /* Delete the connection/session since the pipes should be
- * clear by now */
- tcp_connection_del (tc0);
+
+ /* Don't free the connection from the data path since
+ * 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_update (tc0, TCP_TIMER_WAITCLOSE, 1);
goto drop;
_(LAST_ACK, TCP_FLAG_FIN | TCP_FLAG_ACK, TCP_INPUT_NEXT_RCV_PROCESS,
TCP_ERROR_NONE);
_(LAST_ACK, TCP_FLAG_RST, TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
+ _(LAST_ACK, TCP_FLAG_SYN, TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
_(TIME_WAIT, TCP_FLAG_FIN, TCP_INPUT_NEXT_RCV_PROCESS, TCP_ERROR_NONE);
_(TIME_WAIT, TCP_FLAG_FIN | TCP_FLAG_ACK, TCP_INPUT_NEXT_RCV_PROCESS,
TCP_ERROR_NONE);