diff options
author | Neal Cardwell <ncardwell@google.com> | 2012-02-12 13:37:09 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-02-29 19:34:16 -0500 |
commit | 382e8f84cb3db5295aa2f142a11e42eac6544ab4 (patch) | |
tree | 8702597132aa738d859af3c9607e023b2c8626a0 /net | |
parent | 39b73fb4fedd23980b720d0272e5e26510cd6940 (diff) |
tcp: allow tcp_sacktag_one() to tag ranges not aligned with skbs
[ Upstream commit cc9a672ee522d4805495b98680f4a3db5d0a0af9 ]
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-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 c68040fe9cd..af41044c605 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -1289,25 +1289,26 @@ static int tcp_match_skb_to_sack(struct sock *sk, struct sk_buff *skb, | |||
1289 | return in_sack; | 1289 | return in_sack; |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | static u8 tcp_sacktag_one(struct sk_buff *skb, struct sock *sk, | 1292 | /* Mark the given newly-SACKed range as such, adjusting counters and hints. */ |
1293 | struct tcp_sacktag_state *state, | 1293 | static u8 tcp_sacktag_one(struct sock *sk, |
1294 | struct tcp_sacktag_state *state, u8 sacked, | ||
1295 | u32 start_seq, u32 end_seq, | ||
1294 | int dup_sack, int pcount) | 1296 | int dup_sack, int pcount) |
1295 | { | 1297 | { |
1296 | struct tcp_sock *tp = tcp_sk(sk); | 1298 | struct tcp_sock *tp = tcp_sk(sk); |
1297 | u8 sacked = TCP_SKB_CB(skb)->sacked; | ||
1298 | int fack_count = state->fack_count; | 1299 | int fack_count = state->fack_count; |
1299 | 1300 | ||
1300 | /* Account D-SACK for retransmitted packet. */ | 1301 | /* Account D-SACK for retransmitted packet. */ |
1301 | if (dup_sack && (sacked & TCPCB_RETRANS)) { | 1302 | if (dup_sack && (sacked & TCPCB_RETRANS)) { |
1302 | if (tp->undo_marker && tp->undo_retrans && | 1303 | if (tp->undo_marker && tp->undo_retrans && |
1303 | after(TCP_SKB_CB(skb)->end_seq, tp->undo_marker)) | 1304 | after(end_seq, tp->undo_marker)) |
1304 | tp->undo_retrans--; | 1305 | tp->undo_retrans--; |
1305 | if (sacked & TCPCB_SACKED_ACKED) | 1306 | if (sacked & TCPCB_SACKED_ACKED) |
1306 | state->reord = min(fack_count, state->reord); | 1307 | state->reord = min(fack_count, state->reord); |
1307 | } | 1308 | } |
1308 | 1309 | ||
1309 | /* Nothing to do; acked frame is about to be dropped (was ACKed). */ | 1310 | /* Nothing to do; acked frame is about to be dropped (was ACKed). */ |
1310 | if (!after(TCP_SKB_CB(skb)->end_seq, tp->snd_una)) | 1311 | if (!after(end_seq, tp->snd_una)) |
1311 | return sacked; | 1312 | return sacked; |
1312 | 1313 | ||
1313 | if (!(sacked & TCPCB_SACKED_ACKED)) { | 1314 | if (!(sacked & TCPCB_SACKED_ACKED)) { |
@@ -1326,13 +1327,13 @@ static u8 tcp_sacktag_one(struct sk_buff *skb, struct sock *sk, | |||
1326 | /* New sack for not retransmitted frame, | 1327 | /* New sack for not retransmitted frame, |
1327 | * which was in hole. It is reordering. | 1328 | * which was in hole. It is reordering. |
1328 | */ | 1329 | */ |
1329 | if (before(TCP_SKB_CB(skb)->seq, | 1330 | if (before(start_seq, |
1330 | tcp_highest_sack_seq(tp))) | 1331 | tcp_highest_sack_seq(tp))) |
1331 | state->reord = min(fack_count, | 1332 | state->reord = min(fack_count, |
1332 | state->reord); | 1333 | state->reord); |
1333 | 1334 | ||
1334 | /* SACK enhanced F-RTO (RFC4138; Appendix B) */ | 1335 | /* SACK enhanced F-RTO (RFC4138; Appendix B) */ |
1335 | if (!after(TCP_SKB_CB(skb)->end_seq, tp->frto_highmark)) | 1336 | if (!after(end_seq, tp->frto_highmark)) |
1336 | state->flag |= FLAG_ONLY_ORIG_SACKED; | 1337 | state->flag |= FLAG_ONLY_ORIG_SACKED; |
1337 | } | 1338 | } |
1338 | 1339 | ||
@@ -1350,8 +1351,7 @@ static u8 tcp_sacktag_one(struct sk_buff *skb, struct sock *sk, | |||
1350 | 1351 | ||
1351 | /* Lost marker hint past SACKed? Tweak RFC3517 cnt */ | 1352 | /* Lost marker hint past SACKed? Tweak RFC3517 cnt */ |
1352 | if (!tcp_is_fack(tp) && (tp->lost_skb_hint != NULL) && | 1353 | if (!tcp_is_fack(tp) && (tp->lost_skb_hint != NULL) && |
1353 | before(TCP_SKB_CB(skb)->seq, | 1354 | before(start_seq, TCP_SKB_CB(tp->lost_skb_hint)->seq)) |
1354 | TCP_SKB_CB(tp->lost_skb_hint)->seq)) | ||
1355 | tp->lost_cnt_hint += pcount; | 1355 | tp->lost_cnt_hint += pcount; |
1356 | 1356 | ||
1357 | if (fack_count > tp->fackets_out) | 1357 | if (fack_count > tp->fackets_out) |
@@ -1407,7 +1407,11 @@ static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb, | |||
1407 | } | 1407 | } |
1408 | 1408 | ||
1409 | /* We discard results */ | 1409 | /* We discard results */ |
1410 | tcp_sacktag_one(skb, sk, state, dup_sack, pcount); | 1410 | tcp_sacktag_one(sk, state, |
1411 | TCP_SKB_CB(skb)->sacked, | ||
1412 | TCP_SKB_CB(skb)->seq, | ||
1413 | TCP_SKB_CB(skb)->end_seq, | ||
1414 | dup_sack, pcount); | ||
1411 | 1415 | ||
1412 | /* Difference in this won't matter, both ACKed by the same cumul. ACK */ | 1416 | /* Difference in this won't matter, both ACKed by the same cumul. ACK */ |
1413 | TCP_SKB_CB(prev)->sacked |= (TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS); | 1417 | TCP_SKB_CB(prev)->sacked |= (TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS); |
@@ -1646,10 +1650,14 @@ static struct sk_buff *tcp_sacktag_walk(struct sk_buff *skb, struct sock *sk, | |||
1646 | break; | 1650 | break; |
1647 | 1651 | ||
1648 | if (in_sack) { | 1652 | if (in_sack) { |
1649 | TCP_SKB_CB(skb)->sacked = tcp_sacktag_one(skb, sk, | 1653 | TCP_SKB_CB(skb)->sacked = |
1650 | state, | 1654 | tcp_sacktag_one(sk, |
1651 | dup_sack, | 1655 | state, |
1652 | tcp_skb_pcount(skb)); | 1656 | TCP_SKB_CB(skb)->sacked, |
1657 | TCP_SKB_CB(skb)->seq, | ||
1658 | TCP_SKB_CB(skb)->end_seq, | ||
1659 | dup_sack, | ||
1660 | tcp_skb_pcount(skb)); | ||
1653 | 1661 | ||
1654 | if (!before(TCP_SKB_CB(skb)->seq, | 1662 | if (!before(TCP_SKB_CB(skb)->seq, |
1655 | tcp_highest_sack_seq(tp))) | 1663 | tcp_highest_sack_seq(tp))) |