Skip to content

Commit 082d4fa

Browse files
yousukseungdavem330
authored andcommitted
tcp: update delivered_ce with delivered
Currently tp->delivered is updated in various places in tcp_ack() but tp->delivered_ce is updated once at the end. As a result two counts in OPT_STATS of SCM_TSTAMP_ACK timestamps generated in tcp_ack() may not be in sync. This patch updates both counts at the same in tcp_ack(). Signed-off-by: Yousuk Seung <ysseung@google.com> Signed-off-by: Yuchung Cheng <ycheng@google.com> Acked-by: Eric Dumazet <edumazet@google.com> Acked-by: Neal Cardwell <ncardwell@google.com> Acked-by: Soheil Hassas Yeganeh <soheil@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f00394c commit 082d4fa

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

net/ipv4/tcp_input.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,15 @@ void tcp_skb_mark_lost_uncond_verify(struct tcp_sock *tp, struct sk_buff *skb)
962962
}
963963
}
964964

965+
/* Updates the delivered and delivered_ce counts */
966+
static void tcp_count_delivered(struct tcp_sock *tp, u32 delivered,
967+
bool ece_ack)
968+
{
969+
tp->delivered += delivered;
970+
if (ece_ack)
971+
tp->delivered_ce += delivered;
972+
}
973+
965974
/* This procedure tags the retransmission queue when SACKs arrive.
966975
*
967976
* We have three tag bits: SACKED(S), RETRANS(R) and LOST(L).
@@ -1259,7 +1268,7 @@ static u8 tcp_sacktag_one(struct sock *sk,
12591268
sacked |= TCPCB_SACKED_ACKED;
12601269
state->flag |= FLAG_DATA_SACKED;
12611270
tp->sacked_out += pcount;
1262-
tp->delivered += pcount; /* Out-of-order packets delivered */
1271+
/* Out-of-order packets delivered */
12631272
state->sack_delivered += pcount;
12641273

12651274
/* Lost marker hint past SACKed? Tweak RFC3517 cnt */
@@ -1686,7 +1695,7 @@ tcp_sacktag_write_queue(struct sock *sk, const struct sk_buff *ack_skb,
16861695
num_sacks, prior_snd_una);
16871696
if (found_dup_sack) {
16881697
state->flag |= FLAG_DSACKING_ACK;
1689-
tp->delivered++; /* A spurious retransmission is delivered */
1698+
/* A spurious retransmission is delivered */
16901699
state->sack_delivered++;
16911700
}
16921701

@@ -1907,7 +1916,7 @@ static void tcp_add_reno_sack(struct sock *sk, int num_dupack, bool ece_ack)
19071916
tcp_check_reno_reordering(sk, 0);
19081917
delivered = tp->sacked_out - prior_sacked;
19091918
if (delivered > 0)
1910-
tp->delivered += delivered;
1919+
tcp_count_delivered(tp, delivered, ece_ack);
19111920
tcp_verify_left_out(tp);
19121921
}
19131922
}
@@ -1920,7 +1929,8 @@ static void tcp_remove_reno_sacks(struct sock *sk, int acked, bool ece_ack)
19201929

19211930
if (acked > 0) {
19221931
/* One ACK acked hole. The rest eat duplicate ACKs. */
1923-
tp->delivered += max_t(int, acked - tp->sacked_out, 1);
1932+
tcp_count_delivered(tp, max_t(int, acked - tp->sacked_out, 1),
1933+
ece_ack);
19241934
if (acked - 1 >= tp->sacked_out)
19251935
tp->sacked_out = 0;
19261936
else
@@ -3116,7 +3126,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, u32 prior_fack,
31163126
if (sacked & TCPCB_SACKED_ACKED) {
31173127
tp->sacked_out -= acked_pcount;
31183128
} else if (tcp_is_sack(tp)) {
3119-
tp->delivered += acked_pcount;
3129+
tcp_count_delivered(tp, acked_pcount, ece_ack);
31203130
if (!tcp_skb_spurious_retrans(tp, skb))
31213131
tcp_rack_advance(tp, sacked, scb->end_seq,
31223132
tcp_skb_timestamp_us(skb));
@@ -3562,10 +3572,9 @@ static u32 tcp_newly_delivered(struct sock *sk, u32 prior_delivered, int flag)
35623572

35633573
delivered = tp->delivered - prior_delivered;
35643574
NET_ADD_STATS(net, LINUX_MIB_TCPDELIVERED, delivered);
3565-
if (flag & FLAG_ECE) {
3566-
tp->delivered_ce += delivered;
3575+
if (flag & FLAG_ECE)
35673576
NET_ADD_STATS(net, LINUX_MIB_TCPDELIVEREDCE, delivered);
3568-
}
3577+
35693578
return delivered;
35703579
}
35713580

@@ -3665,6 +3674,10 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
36653674
ack_ev_flags |= CA_ACK_ECE;
36663675
}
36673676

3677+
if (sack_state.sack_delivered)
3678+
tcp_count_delivered(tp, sack_state.sack_delivered,
3679+
flag & FLAG_ECE);
3680+
36683681
if (flag & FLAG_WIN_UPDATE)
36693682
ack_ev_flags |= CA_ACK_WIN_UPDATE;
36703683

0 commit comments

Comments
 (0)