Skip to content

Commit cc9a672

Browse files
nealcardwelldavem330
authored andcommitted
tcp: allow tcp_sacktag_one() to tag ranges not aligned with skbs
This commit allows callers of tcp_sacktag_one() to pass in sequence ranges that do not align with skb boundaries, as tcp_shifted_skb() needs to do in an upcoming fix in this patch series. In fact, now tcp_sacktag_one() does not need to depend on an input skb at all, which makes its semantics and dependencies more clear. Signed-off-by: Neal Cardwell <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8df54d6 commit cc9a672

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

net/ipv4/tcp_input.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,25 +1307,26 @@ static int tcp_match_skb_to_sack(struct sock *sk, struct sk_buff *skb,
13071307
return in_sack;
13081308
}
13091309

1310-
static u8 tcp_sacktag_one(const struct sk_buff *skb, struct sock *sk,
1311-
struct tcp_sacktag_state *state,
1310+
/* Mark the given newly-SACKed range as such, adjusting counters and hints. */
1311+
static u8 tcp_sacktag_one(struct sock *sk,
1312+
struct tcp_sacktag_state *state, u8 sacked,
1313+
u32 start_seq, u32 end_seq,
13121314
int dup_sack, int pcount)
13131315
{
13141316
struct tcp_sock *tp = tcp_sk(sk);
1315-
u8 sacked = TCP_SKB_CB(skb)->sacked;
13161317
int fack_count = state->fack_count;
13171318

13181319
/* Account D-SACK for retransmitted packet. */
13191320
if (dup_sack && (sacked & TCPCB_RETRANS)) {
13201321
if (tp->undo_marker && tp->undo_retrans &&
1321-
after(TCP_SKB_CB(skb)->end_seq, tp->undo_marker))
1322+
after(end_seq, tp->undo_marker))
13221323
tp->undo_retrans--;
13231324
if (sacked & TCPCB_SACKED_ACKED)
13241325
state->reord = min(fack_count, state->reord);
13251326
}
13261327

13271328
/* Nothing to do; acked frame is about to be dropped (was ACKed). */
1328-
if (!after(TCP_SKB_CB(skb)->end_seq, tp->snd_una))
1329+
if (!after(end_seq, tp->snd_una))
13291330
return sacked;
13301331

13311332
if (!(sacked & TCPCB_SACKED_ACKED)) {
@@ -1344,13 +1345,13 @@ static u8 tcp_sacktag_one(const struct sk_buff *skb, struct sock *sk,
13441345
/* New sack for not retransmitted frame,
13451346
* which was in hole. It is reordering.
13461347
*/
1347-
if (before(TCP_SKB_CB(skb)->seq,
1348+
if (before(start_seq,
13481349
tcp_highest_sack_seq(tp)))
13491350
state->reord = min(fack_count,
13501351
state->reord);
13511352

13521353
/* SACK enhanced F-RTO (RFC4138; Appendix B) */
1353-
if (!after(TCP_SKB_CB(skb)->end_seq, tp->frto_highmark))
1354+
if (!after(end_seq, tp->frto_highmark))
13541355
state->flag |= FLAG_ONLY_ORIG_SACKED;
13551356
}
13561357

@@ -1368,8 +1369,7 @@ static u8 tcp_sacktag_one(const struct sk_buff *skb, struct sock *sk,
13681369

13691370
/* Lost marker hint past SACKed? Tweak RFC3517 cnt */
13701371
if (!tcp_is_fack(tp) && (tp->lost_skb_hint != NULL) &&
1371-
before(TCP_SKB_CB(skb)->seq,
1372-
TCP_SKB_CB(tp->lost_skb_hint)->seq))
1372+
before(start_seq, TCP_SKB_CB(tp->lost_skb_hint)->seq))
13731373
tp->lost_cnt_hint += pcount;
13741374

13751375
if (fack_count > tp->fackets_out)
@@ -1425,7 +1425,11 @@ static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb,
14251425
}
14261426

14271427
/* We discard results */
1428-
tcp_sacktag_one(skb, sk, state, dup_sack, pcount);
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);
14291433

14301434
/* Difference in this won't matter, both ACKed by the same cumul. ACK */
14311435
TCP_SKB_CB(prev)->sacked |= (TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS);
@@ -1664,10 +1668,14 @@ static struct sk_buff *tcp_sacktag_walk(struct sk_buff *skb, struct sock *sk,
16641668
break;
16651669

16661670
if (in_sack) {
1667-
TCP_SKB_CB(skb)->sacked = tcp_sacktag_one(skb, sk,
1668-
state,
1669-
dup_sack,
1670-
tcp_skb_pcount(skb));
1671+
TCP_SKB_CB(skb)->sacked =
1672+
tcp_sacktag_one(sk,
1673+
state,
1674+
TCP_SKB_CB(skb)->sacked,
1675+
TCP_SKB_CB(skb)->seq,
1676+
TCP_SKB_CB(skb)->end_seq,
1677+
dup_sack,
1678+
tcp_skb_pcount(skb));
16711679

16721680
if (!before(TCP_SKB_CB(skb)->seq,
16731681
tcp_highest_sack_seq(tp)))

0 commit comments

Comments
 (0)