Skip to content

Commit f58b22f

Browse files
ij1davem330
authored andcommitted
tcp: make tcp_sacktag_one able to handle partial skb too
This is preparatory work for SACK combiner patch which may have to count TCP state changes for only a part of the skb because it will intentionally avoids splitting skb to SACKed and not sacked parts. Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent adb92db commit f58b22f

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

net/ipv4/tcp_input.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,8 @@ static int tcp_match_skb_to_sack(struct sock *sk, struct sk_buff *skb,
12891289
}
12901290

12911291
static int tcp_sacktag_one(struct sk_buff *skb, struct sock *sk,
1292-
int *reord, int dup_sack, int fack_count)
1292+
int *reord, int dup_sack, int fack_count,
1293+
u8 *sackedto, int pcount)
12931294
{
12941295
struct tcp_sock *tp = tcp_sk(sk);
12951296
u8 sacked = TCP_SKB_CB(skb)->sacked;
@@ -1314,10 +1315,9 @@ static int tcp_sacktag_one(struct sk_buff *skb, struct sock *sk,
13141315
* that retransmission is still in flight.
13151316
*/
13161317
if (sacked & TCPCB_LOST) {
1317-
TCP_SKB_CB(skb)->sacked &=
1318-
~(TCPCB_LOST|TCPCB_SACKED_RETRANS);
1319-
tp->lost_out -= tcp_skb_pcount(skb);
1320-
tp->retrans_out -= tcp_skb_pcount(skb);
1318+
*sackedto &= ~(TCPCB_LOST|TCPCB_SACKED_RETRANS);
1319+
tp->lost_out -= pcount;
1320+
tp->retrans_out -= pcount;
13211321
}
13221322
} else {
13231323
if (!(sacked & TCPCB_RETRANS)) {
@@ -1334,22 +1334,22 @@ static int tcp_sacktag_one(struct sk_buff *skb, struct sock *sk,
13341334
}
13351335

13361336
if (sacked & TCPCB_LOST) {
1337-
TCP_SKB_CB(skb)->sacked &= ~TCPCB_LOST;
1338-
tp->lost_out -= tcp_skb_pcount(skb);
1337+
*sackedto &= ~TCPCB_LOST;
1338+
tp->lost_out -= pcount;
13391339
}
13401340
}
13411341

1342-
TCP_SKB_CB(skb)->sacked |= TCPCB_SACKED_ACKED;
1342+
*sackedto |= TCPCB_SACKED_ACKED;
13431343
flag |= FLAG_DATA_SACKED;
1344-
tp->sacked_out += tcp_skb_pcount(skb);
1344+
tp->sacked_out += pcount;
13451345

1346-
fack_count += tcp_skb_pcount(skb);
1346+
fack_count += pcount;
13471347

13481348
/* Lost marker hint past SACKed? Tweak RFC3517 cnt */
13491349
if (!tcp_is_fack(tp) && (tp->lost_skb_hint != NULL) &&
13501350
before(TCP_SKB_CB(skb)->seq,
13511351
TCP_SKB_CB(tp->lost_skb_hint)->seq))
1352-
tp->lost_cnt_hint += tcp_skb_pcount(skb);
1352+
tp->lost_cnt_hint += pcount;
13531353

13541354
if (fack_count > tp->fackets_out)
13551355
tp->fackets_out = fack_count;
@@ -1362,9 +1362,9 @@ static int tcp_sacktag_one(struct sk_buff *skb, struct sock *sk,
13621362
* frames and clear it. undo_retrans is decreased above, L|R frames
13631363
* are accounted above as well.
13641364
*/
1365-
if (dup_sack && (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS)) {
1366-
TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS;
1367-
tp->retrans_out -= tcp_skb_pcount(skb);
1365+
if (dup_sack && (*sackedto & TCPCB_SACKED_RETRANS)) {
1366+
*sackedto &= ~TCPCB_SACKED_RETRANS;
1367+
tp->retrans_out -= pcount;
13681368
}
13691369

13701370
return flag;
@@ -1404,7 +1404,9 @@ static struct sk_buff *tcp_sacktag_walk(struct sk_buff *skb, struct sock *sk,
14041404

14051405
if (in_sack)
14061406
*flag |= tcp_sacktag_one(skb, sk, reord, dup_sack,
1407-
*fack_count);
1407+
*fack_count,
1408+
&(TCP_SKB_CB(skb)->sacked),
1409+
tcp_skb_pcount(skb));
14081410

14091411
*fack_count += tcp_skb_pcount(skb);
14101412
}

0 commit comments

Comments
 (0)