sack_scoreboard_t *sb = &tc->sack_sb;
sack_block_t *blk, tmp;
sack_scoreboard_hole_t *hole, *next_hole, *last_hole, *new_hole;
- u32 blk_index = 0, old_sacked_bytes, hole_index;
+ u32 blk_index = 0, old_sacked_bytes, delivered_bytes, hole_index;
int i, j;
sb->last_sacked_bytes = 0;
sb->snd_una_adv = 0;
old_sacked_bytes = sb->sacked_bytes;
+ delivered_bytes = 0;
if (!tcp_opts_sack (&tc->opt) && sb->head == TCP_INVALID_SACK_HOLE_INDEX)
return;
last_hole = scoreboard_insert_hole (sb, TCP_INVALID_SACK_HOLE_INDEX,
tc->snd_una, tc->snd_una_max);
sb->tail = scoreboard_hole_index (sb, last_hole);
+ tmp = tc->opt.sacks[vec_len (tc->opt.sacks) - 1];
+ sb->max_byte_sacked = tmp.end;
}
else
{
{
/* Bytes lost because snd_wnd left edge advances */
if (next_hole && seq_leq (next_hole->start, ack))
- sb->sacked_bytes -= next_hole->start - hole->end;
+ delivered_bytes += next_hole->start - hole->end;
else
- sb->sacked_bytes -= ack - hole->end;
+ delivered_bytes += ack - hole->end;
}
else
{
sb->sacked_bytes += scoreboard_hole_bytes (hole);
}
- /* snd_una needs to be advanced */
- if (seq_geq (ack, hole->end))
- {
- if (next_hole && seq_lt (ack, next_hole->start))
- sb->snd_una_adv = next_hole->start - ack;
- else
- sb->snd_una_adv = sb->max_byte_sacked - ack;
-
- /* all these can be delivered */
- sb->sacked_bytes -= sb->snd_una_adv;
- }
-
/* About to remove last hole */
if (hole == last_hole)
{
sb->tail = hole->prev;
last_hole = scoreboard_last_hole (sb);
- /* keep track of max byte sacked in case the last hole
+ /* keep track of max byte sacked for when the last hole
* is acked */
if (seq_gt (hole->end, sb->max_byte_sacked))
sb->max_byte_sacked = hole->end;
}
+
+ /* snd_una needs to be advanced */
+ if (blk->end == ack && seq_geq (ack, hole->end))
+ {
+ if (next_hole && seq_lt (ack, next_hole->start))
+ {
+ sb->snd_una_adv = next_hole->start - ack;
+
+ /* all these can be delivered */
+ delivered_bytes += sb->snd_una_adv;
+ }
+ else if (!next_hole)
+ {
+ sb->snd_una_adv = sb->max_byte_sacked - ack;
+ delivered_bytes += sb->snd_una_adv;
+ }
+ }
+
scoreboard_remove_hole (sb, hole);
hole = next_hole;
}
}
}
- sb->last_sacked_bytes = sb->sacked_bytes + sb->snd_una_adv
- - old_sacked_bytes;
+ sb->last_sacked_bytes = sb->sacked_bytes - old_sacked_bytes;
+ sb->sacked_bytes -= delivered_bytes;
}
/** Update snd_wnd
TCP_EVT_DBG (TCP_EVT_SND_WND, tc);
/* Set probe timer if we just got 0 wnd */
- if (tc->snd_wnd < tc->snd_mss
- && !tcp_timer_is_active (tc, TCP_TIMER_PERSIST))
- tcp_persist_timer_set (tc);
+ if (tc->snd_wnd < tc->snd_mss)
+ {
+ if (!tcp_timer_is_active (tc, TCP_TIMER_PERSIST))
+ tcp_persist_timer_set (tc);
+ }
else
tcp_persist_timer_reset (tc);
}
tcp_cc_rcv_ack (tcp_connection_t * tc, vlib_buffer_t * b)
{
u8 partial_ack;
+ u32 bytes_advanced;
if (tcp_in_fastrecovery (tc))
{
tc->rcv_dupacks = 0;
if (tcp_in_recovery (tc))
{
- tc->rtx_bytes -= clib_min (tc->bytes_acked, tc->rtx_bytes);
+ bytes_advanced = tc->bytes_acked + tc->sack_sb.snd_una_adv;
+ tc->rtx_bytes -= clib_min (bytes_advanced, tc->rtx_bytes);
tc->rto = clib_min (tc->srtt + (tc->rttvar << 2), TCP_RTO_MAX);
if (seq_geq (tc->snd_una, tc->snd_congestion))
- tcp_recovery_off (tc);
+ {
+ tc->rtx_bytes = 0;
+ tcp_recovery_off (tc);
+ }
}
}
}
s = format (s, "%U\n%U%U",
format_tcp_header, &t->tcp_header, 128,
format_white_space, indent,
- format_tcp_connection_verbose, &t->tcp_connection);
+ format_tcp_connection, &t->tcp_connection, 1);
return s;
}
s = format (s, "%d -> %d (%U)",
clib_net_to_host_u16 (t->tcp_header.src_port),
clib_net_to_host_u16 (t->tcp_header.dst_port), format_tcp_state,
- &t->tcp_connection.state);
+ t->tcp_connection.state);
return s;
}
child0->c_rmt_port = th0->src_port;
child0->c_is_ip4 = is_ip4;
child0->c_thread_index = my_thread_index;
+ child0->state = TCP_STATE_SYN_RCVD;
if (is_ip4)
{
child0->irs = vnet_buffer (b0)->tcp.seq_number;
child0->rcv_nxt = vnet_buffer (b0)->tcp.seq_number + 1;
child0->rcv_las = child0->rcv_nxt;
- child0->state = TCP_STATE_SYN_RCVD;
/* RFC1323: TSval timestamps sent on {SYN} and {SYN,ACK}
* segments are used to initialize PAWS. */
if (error0 == TCP_ERROR_DISPATCH)
clib_warning ("disp error state %U flags %U",
- format_tcp_state, &state0, format_tcp_flags,
+ format_tcp_state, state0, format_tcp_flags,
(int) flags0);
}
}