* draft-cheng-iccrg-delivery-rate-estimation-00
*/
+#include <vnet/tcp/tcp_bt.h>
#include <vnet/tcp/tcp.h>
+#include <vnet/tcp/tcp_inlines.h>
static tcp_bt_sample_t *
bt_get_sample (tcp_byte_tracker_t * bt, u32 bts_index)
tail = bt_get_sample (bt, bt->tail);
if (tail && tail->max_seq == tc->snd_nxt
+ && !(tail->flags & TCP_BTS_IS_SACKED)
&& tail->tx_time == tcp_time_now_us (tc->c_thread_index))
{
tail->max_seq += len;
tcp_bt_sample_t *bts, *next, *cur, *prev, *nbts;
u32 bts_index, cur_index, next_index, prev_index, max_seq;
u8 is_end = end == tc->snd_nxt;
+ tcp_bts_flags_t bts_flags;
/* Contiguous blocks retransmitted at the same time */
bts = bt_get_sample (bt, bt->last_ooo);
return;
}
- /* Find original tx sample */
+ /* Find original tx sample and cache flags in case the sample
+ * is freed or the pool moves */
bts = bt_lookup_seq (bt, start);
+ bts_flags = bts->flags;
ASSERT (bts != 0 && seq_geq (start, bts->min_seq));
{
prev_index = bts->prev;
next = bt_fix_overlapped (bt, bts, end, is_end);
+ /* bts might no longer be valid from here */
next_index = bt_sample_index (bt, next);
cur = tcp_bt_alloc_tx_sample (tc, start, end);
cur->flags |= TCP_BTS_IS_RXT;
- if (bts->flags & TCP_BTS_IS_RXT)
+ if (bts_flags & TCP_BTS_IS_RXT)
cur->flags |= TCP_BTS_IS_RXT_LOST;
cur->next = next_index;
cur->prev = prev_index;
/* Have to split or tail overlap */
cur = tcp_bt_alloc_tx_sample (tc, start, end);
cur->flags |= TCP_BTS_IS_RXT;
- if (bts->flags & TCP_BTS_IS_RXT)
+ if (bts_flags & TCP_BTS_IS_RXT)
cur->flags |= TCP_BTS_IS_RXT_LOST;
cur->prev = bts_index;
cur_index = bt_sample_index (bt, cur);
}
if (cur && seq_lt (cur->min_seq, tc->snd_una))
- tcp_bt_sample_to_rate_sample (tc, cur, rs);
+ {
+ bt_update_sample (bt, cur, tc->snd_una);
+ tcp_bt_sample_to_rate_sample (tc, cur, rs);
+ }
}
static void
tc->lost += tc->sack_sb.last_lost_bytes;
delivered = tc->bytes_acked + tc->sack_sb.last_sacked_bytes;
+ /* Do not count bytes that were previously sacked again */
+ delivered -= tc->sack_sb.last_bytes_delivered;
if (!delivered || tc->bt->head == TCP_BTS_INVALID_INDEX)
return;
- /* Do not count bytes that were previously sacked again */
- tc->delivered += delivered - tc->sack_sb.last_bytes_delivered;
+ tc->delivered += delivered;
tc->delivered_time = tcp_time_now_us (tc->c_thread_index);
if (tc->app_limited && tc->delivered > tc->app_limited)
vec_validate (samples, pool_elts (bt->samples) - 1);
vec_reset_length (samples);
- /* *INDENT-OFF* */
- pool_foreach (bts, bt->samples, ({
+ pool_foreach (bts, bt->samples) {
vec_add1 (samples, bts - bt->samples);
- }));
- /* *INDENT-ON* */
+ }
vec_foreach (si, samples)
{