| From 04049aae9fb74215bc39b17a347fee5fb6ae75bc Mon Sep 17 00:00:00 2001 |
| From: Cambda Zhu <cambda@linux.alibaba.com> |
| Date: Fri, 27 Dec 2019 16:52:37 +0800 |
| Subject: [PATCH] tcp: Fix highest_sack and highest_sack_seq |
| |
| commit 853697504de043ff0bfd815bd3a64de1dce73dc7 upstream. |
| |
| >From commit 50895b9de1d3 ("tcp: highest_sack fix"), the logic about |
| setting tp->highest_sack to the head of the send queue was removed. |
| Of course the logic is error prone, but it is logical. Before we |
| remove the pointer to the highest sack skb and use the seq instead, |
| we need to set tp->highest_sack to NULL when there is no skb after |
| the last sack, and then replace NULL with the real skb when new skb |
| inserted into the rtx queue, because the NULL means the highest sack |
| seq is tp->snd_nxt. If tp->highest_sack is NULL and new data sent, |
| the next ACK with sack option will increase tp->reordering unexpectedly. |
| |
| This patch sets tp->highest_sack to the tail of the rtx queue if |
| it's NULL and new data is sent. The patch keeps the rule that the |
| highest_sack can only be maintained by sack processing, except for |
| this only case. |
| |
| Fixes: 50895b9de1d3 ("tcp: highest_sack fix") |
| Signed-off-by: Cambda Zhu <cambda@linux.alibaba.com> |
| Signed-off-by: Eric Dumazet <edumazet@google.com> |
| Signed-off-by: David S. Miller <davem@davemloft.net> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c |
| index 74aa691fd0ae..3443c1f9f5e2 100644 |
| --- a/net/ipv4/tcp_output.c |
| +++ b/net/ipv4/tcp_output.c |
| @@ -72,6 +72,9 @@ static void tcp_event_new_data_sent(struct sock *sk, struct sk_buff *skb) |
| __skb_unlink(skb, &sk->sk_write_queue); |
| tcp_rbtree_insert(&sk->tcp_rtx_queue, skb); |
| |
| + if (tp->highest_sack == NULL) |
| + tp->highest_sack = skb; |
| + |
| tp->packets_out += tcp_skb_pcount(skb); |
| if (!prior_packets || icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) |
| tcp_rearm_rto(sk); |
| -- |
| 2.7.4 |
| |