diff options
author | Neal Cardwell <ncardwell@google.com> | 2012-02-12 13:37:09 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-02-13 01:00:21 -0500 |
commit | cc9a672ee522d4805495b98680f4a3db5d0a0af9 (patch) | |
tree | 391c58df73783b8b662f638e14e1f48aa83578e4 /net/ipv4 | |
parent | 8df54d622a120058ee8bec38743c9b8f091c8e58 (diff) |
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 <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/tcp_input.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 976034f82320..4e8a81fda65c 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -1307,25 +1307,26 @@ static int tcp_match_skb_to_sack(struct sock *sk, struct sk_buff *skb, | |||
1307 | return in_sack; | 1307 | return in_sack; |
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | static u8 tcp_sacktag_one(const struct sk_buff *skb, struct sock *sk, | 1310 | /* Mark the given newly-SACKed range as such, adjusting counters and hints. */ |
1311 | struct tcp_sacktag_state *state, | 1311 | static u8 tcp_sacktag_one(struct sock *sk, |
1312 | struct tcp_sacktag_state *state, u8 sacked, | ||
1313 | u32 start_seq, u32 end_seq, | ||
1312 | int dup_sack, int pcount) | 1314 | int dup_sack, int pcount) |
1313 | { | 1315 | { |
1314 | struct tcp_sock *tp = tcp_sk(sk); | 1316 | struct tcp_sock *tp = tcp_sk(sk); |
1315 | u8 sacked = TCP_SKB_CB(skb)->sacked; | ||
1316 | int fack_count = state->fack_count; | 1317 | int fack_count = state->fack_count; |
1317 | 1318 | ||
1318 | /* Account D-SACK for retransmitted packet. */ | 1319 | /* Account D-SACK for retransmitted packet. */ |
1319 | if (dup_sack && (sacked & TCPCB_RETRANS)) { | 1320 | if (dup_sack && (sacked & TCPCB_RETRANS)) { |
1320 | if (tp->undo_marker && tp->undo_retrans && | 1321 | 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)) |
1322 | tp->undo_retrans--; | 1323 | tp->undo_retrans--; |
1323 | if (sacked & TCPCB_SACKED_ACKED) | 1324 | if (sacked & TCPCB_SACKED_ACKED) |
1324 | state->reord = min(fack_count, state->reord); | 1325 | state->reord = min(fack_count, state->reord); |
1325 | } | 1326 | } |
1326 | 1327 | ||
1327 | /* Nothing to do; acked frame is about to be dropped (was ACKed). */ | 1328 | /* 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)) |
1329 | return sacked; | 1330 | return sacked; |
1330 | 1331 | ||
1331 | if (!(sacked & TCPCB_SACKED_ACKED)) { | 1332 | if (!(sacked & TCPCB_SACKED_ACKED)) { |
@@ -1344,13 +1345,13 @@ static u8 tcp_sacktag_one(const struct sk_buff *skb, struct sock *sk, | |||
1344 | /* New sack for not retransmitted frame, | 1345 | /* New sack for not retransmitted frame, |
1345 | * which was in hole. It is reordering. | 1346 | * which was in hole. It is reordering. |
1346 | */ | 1347 | */ |
1347 | if (before(TCP_SKB_CB(skb)->seq, | 1348 | if (before(start_seq, |
1348 | tcp_highest_sack_seq(tp))) | 1349 | tcp_highest_sack_seq(tp))) |
1349 | state->reord = min(fack_count, | 1350 | state->reord = min(fack_count, |
1350 | state->reord); | 1351 | state->reord); |
1351 | 1352 | ||
1352 | /* SACK enhanced F-RTO (RFC4138; Appendix B) */ | 1353 | /* 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)) |
1354 | state->flag |= FLAG_ONLY_ORIG_SACKED; | 1355 | state->flag |= FLAG_ONLY_ORIG_SACKED; |
1355 | } | 1356 | } |
1356 | 1357 | ||
@@ -1368,8 +1369,7 @@ static u8 tcp_sacktag_one(const struct sk_buff *skb, struct sock *sk, | |||
1368 | 1369 | ||
1369 | /* Lost marker hint past SACKed? Tweak RFC3517 cnt */ | 1370 | /* Lost marker hint past SACKed? Tweak RFC3517 cnt */ |
1370 | if (!tcp_is_fack(tp) && (tp->lost_skb_hint != NULL) && | 1371 | if (!tcp_is_fack(tp) && (tp->lost_skb_hint != NULL) && |
1371 | before(TCP_SKB_CB(skb)->seq, | 1372 | before(start_seq, TCP_SKB_CB(tp->lost_skb_hint)->seq)) |
1372 | TCP_SKB_CB(tp->lost_skb_hint)->seq)) | ||
1373 | tp->lost_cnt_hint += pcount; | 1373 | tp->lost_cnt_hint += pcount; |
1374 | 1374 | ||
1375 | if (fack_count > tp->fackets_out) | 1375 | if (fack_count > tp->fackets_out) |
@@ -1425,7 +1425,11 @@ static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb, | |||
1425 | } | 1425 | } |
1426 | 1426 | ||
1427 | /* We discard results */ | 1427 | /* 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); | ||
1429 | 1433 | ||
1430 | /* Difference in this won't matter, both ACKed by the same cumul. ACK */ | 1434 | /* Difference in this won't matter, both ACKed by the same cumul. ACK */ |
1431 | TCP_SKB_CB(prev)->sacked |= (TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS); | 1435 | 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, | |||
1664 | break; | 1668 | break; |
1665 | 1669 | ||
1666 | if (in_sack) { | 1670 | if (in_sack) { |
1667 | TCP_SKB_CB(skb)->sacked = tcp_sacktag_one(skb, sk, | 1671 | TCP_SKB_CB(skb)->sacked = |
1668 | state, | 1672 | tcp_sacktag_one(sk, |
1669 | dup_sack, | 1673 | state, |
1670 | tcp_skb_pcount(skb)); | 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)); | ||
1671 | 1679 | ||
1672 | if (!before(TCP_SKB_CB(skb)->seq, | 1680 | if (!before(TCP_SKB_CB(skb)->seq, |
1673 | tcp_highest_sack_seq(tp))) | 1681 | tcp_highest_sack_seq(tp))) |