Skip to content

Commit daef52b

Browse files
nealcardwelldavem330
authored andcommitted
tcp: fix range tcp_shifted_skb() passes to tcp_sacktag_one()
Fix the newly-SACKed range to be the range of newly-shifted bytes. Previously - since 832d11c - tcp_shifted_skb() incorrectly called tcp_sacktag_one() with the start and end sequence numbers of the skb it passes in set to the range just beyond the range that is newly-SACKed. This commit also removes a special-case adjustment to lost_cnt_hint in tcp_shifted_skb() since the pre-existing adjustment of lost_cnt_hint in tcp_sacktag_one() now properly handles this things now that the correct start sequence number is passed in. Signed-off-by: Neal Cardwell <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cc9a672 commit daef52b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

net/ipv4/tcp_input.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,19 +1388,21 @@ static u8 tcp_sacktag_one(struct sock *sk,
13881388
return sacked;
13891389
}
13901390

1391+
/* Shift newly-SACKed bytes from this skb to the immediately previous
1392+
* already-SACKed sk_buff. Mark the newly-SACKed bytes as such.
1393+
*/
13911394
static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb,
13921395
struct tcp_sacktag_state *state,
13931396
unsigned int pcount, int shifted, int mss,
13941397
int dup_sack)
13951398
{
13961399
struct tcp_sock *tp = tcp_sk(sk);
13971400
struct sk_buff *prev = tcp_write_queue_prev(sk, skb);
1401+
u32 start_seq = TCP_SKB_CB(skb)->seq; /* start of newly-SACKed */
1402+
u32 end_seq = start_seq + shifted; /* end of newly-SACKed */
13981403

13991404
BUG_ON(!pcount);
14001405

1401-
if (skb == tp->lost_skb_hint)
1402-
tp->lost_cnt_hint += pcount;
1403-
14041406
TCP_SKB_CB(prev)->end_seq += shifted;
14051407
TCP_SKB_CB(skb)->seq += shifted;
14061408

@@ -1424,12 +1426,11 @@ static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb,
14241426
skb_shinfo(skb)->gso_type = 0;
14251427
}
14261428

1427-
/* We discard results */
1428-
tcp_sacktag_one(sk, state,
1429-
TCP_SKB_CB(skb)->sacked,
1430-
TCP_SKB_CB(skb)->seq,
1431-
TCP_SKB_CB(skb)->end_seq,
1432-
dup_sack, pcount);
1429+
/* Adjust counters and hints for the newly sacked sequence range but
1430+
* discard the return value since prev is already marked.
1431+
*/
1432+
tcp_sacktag_one(sk, state, TCP_SKB_CB(skb)->sacked,
1433+
start_seq, end_seq, dup_sack, pcount);
14331434

14341435
/* Difference in this won't matter, both ACKed by the same cumul. ACK */
14351436
TCP_SKB_CB(prev)->sacked |= (TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS);

0 commit comments

Comments
 (0)