diff options
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r-- | net/ipv4/tcp_input.c | 210 |
1 files changed, 102 insertions, 108 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index a6961d75c7ea..c96a6bb25430 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -64,6 +64,7 @@ | |||
64 | #include <linux/mm.h> | 64 | #include <linux/mm.h> |
65 | #include <linux/module.h> | 65 | #include <linux/module.h> |
66 | #include <linux/sysctl.h> | 66 | #include <linux/sysctl.h> |
67 | #include <linux/kernel.h> | ||
67 | #include <net/dst.h> | 68 | #include <net/dst.h> |
68 | #include <net/tcp.h> | 69 | #include <net/tcp.h> |
69 | #include <net/inet_common.h> | 70 | #include <net/inet_common.h> |
@@ -927,6 +928,8 @@ static void tcp_init_metrics(struct sock *sk) | |||
927 | tcp_set_rto(sk); | 928 | tcp_set_rto(sk); |
928 | if (inet_csk(sk)->icsk_rto < TCP_TIMEOUT_INIT && !tp->rx_opt.saw_tstamp) | 929 | if (inet_csk(sk)->icsk_rto < TCP_TIMEOUT_INIT && !tp->rx_opt.saw_tstamp) |
929 | goto reset; | 930 | goto reset; |
931 | |||
932 | cwnd: | ||
930 | tp->snd_cwnd = tcp_init_cwnd(tp, dst); | 933 | tp->snd_cwnd = tcp_init_cwnd(tp, dst); |
931 | tp->snd_cwnd_stamp = tcp_time_stamp; | 934 | tp->snd_cwnd_stamp = tcp_time_stamp; |
932 | return; | 935 | return; |
@@ -941,6 +944,7 @@ reset: | |||
941 | tp->mdev = tp->mdev_max = tp->rttvar = TCP_TIMEOUT_INIT; | 944 | tp->mdev = tp->mdev_max = tp->rttvar = TCP_TIMEOUT_INIT; |
942 | inet_csk(sk)->icsk_rto = TCP_TIMEOUT_INIT; | 945 | inet_csk(sk)->icsk_rto = TCP_TIMEOUT_INIT; |
943 | } | 946 | } |
947 | goto cwnd; | ||
944 | } | 948 | } |
945 | 949 | ||
946 | static void tcp_update_reordering(struct sock *sk, const int metric, | 950 | static void tcp_update_reordering(struct sock *sk, const int metric, |
@@ -1178,10 +1182,18 @@ static void tcp_mark_lost_retrans(struct sock *sk) | |||
1178 | if (!(TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS)) | 1182 | if (!(TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS)) |
1179 | continue; | 1183 | continue; |
1180 | 1184 | ||
1181 | if (after(received_upto, ack_seq) && | 1185 | /* TODO: We would like to get rid of tcp_is_fack(tp) only |
1182 | (tcp_is_fack(tp) || | 1186 | * constraint here (see above) but figuring out that at |
1183 | !before(received_upto, | 1187 | * least tp->reordering SACK blocks reside between ack_seq |
1184 | ack_seq + tp->reordering * tp->mss_cache))) { | 1188 | * and received_upto is not easy task to do cheaply with |
1189 | * the available datastructures. | ||
1190 | * | ||
1191 | * Whether FACK should check here for tp->reordering segs | ||
1192 | * in-between one could argue for either way (it would be | ||
1193 | * rather simple to implement as we could count fack_count | ||
1194 | * during the walk and do tp->fackets_out - fack_count). | ||
1195 | */ | ||
1196 | if (after(received_upto, ack_seq)) { | ||
1185 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; | 1197 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; |
1186 | tp->retrans_out -= tcp_skb_pcount(skb); | 1198 | tp->retrans_out -= tcp_skb_pcount(skb); |
1187 | 1199 | ||
@@ -1374,7 +1386,8 @@ static u8 tcp_sacktag_one(struct sk_buff *skb, struct sock *sk, | |||
1374 | 1386 | ||
1375 | static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb, | 1387 | static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb, |
1376 | struct tcp_sacktag_state *state, | 1388 | struct tcp_sacktag_state *state, |
1377 | unsigned int pcount, int shifted, int mss) | 1389 | unsigned int pcount, int shifted, int mss, |
1390 | int dup_sack) | ||
1378 | { | 1391 | { |
1379 | struct tcp_sock *tp = tcp_sk(sk); | 1392 | struct tcp_sock *tp = tcp_sk(sk); |
1380 | struct sk_buff *prev = tcp_write_queue_prev(sk, skb); | 1393 | struct sk_buff *prev = tcp_write_queue_prev(sk, skb); |
@@ -1410,7 +1423,7 @@ static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb, | |||
1410 | } | 1423 | } |
1411 | 1424 | ||
1412 | /* We discard results */ | 1425 | /* We discard results */ |
1413 | tcp_sacktag_one(skb, sk, state, 0, pcount); | 1426 | tcp_sacktag_one(skb, sk, state, dup_sack, pcount); |
1414 | 1427 | ||
1415 | /* Difference in this won't matter, both ACKed by the same cumul. ACK */ | 1428 | /* Difference in this won't matter, both ACKed by the same cumul. ACK */ |
1416 | TCP_SKB_CB(prev)->sacked |= (TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS); | 1429 | TCP_SKB_CB(prev)->sacked |= (TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS); |
@@ -1561,7 +1574,7 @@ static struct sk_buff *tcp_shift_skb_data(struct sock *sk, struct sk_buff *skb, | |||
1561 | 1574 | ||
1562 | if (!skb_shift(prev, skb, len)) | 1575 | if (!skb_shift(prev, skb, len)) |
1563 | goto fallback; | 1576 | goto fallback; |
1564 | if (!tcp_shifted_skb(sk, skb, state, pcount, len, mss)) | 1577 | if (!tcp_shifted_skb(sk, skb, state, pcount, len, mss, dup_sack)) |
1565 | goto out; | 1578 | goto out; |
1566 | 1579 | ||
1567 | /* Hole filled allows collapsing with the next as well, this is very | 1580 | /* Hole filled allows collapsing with the next as well, this is very |
@@ -1580,7 +1593,7 @@ static struct sk_buff *tcp_shift_skb_data(struct sock *sk, struct sk_buff *skb, | |||
1580 | len = skb->len; | 1593 | len = skb->len; |
1581 | if (skb_shift(prev, skb, len)) { | 1594 | if (skb_shift(prev, skb, len)) { |
1582 | pcount += tcp_skb_pcount(skb); | 1595 | pcount += tcp_skb_pcount(skb); |
1583 | tcp_shifted_skb(sk, skb, state, tcp_skb_pcount(skb), len, mss); | 1596 | tcp_shifted_skb(sk, skb, state, tcp_skb_pcount(skb), len, mss, 0); |
1584 | } | 1597 | } |
1585 | 1598 | ||
1586 | out: | 1599 | out: |
@@ -1793,11 +1806,7 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, | |||
1793 | for (i = used_sacks - 1; i > 0; i--) { | 1806 | for (i = used_sacks - 1; i > 0; i--) { |
1794 | for (j = 0; j < i; j++) { | 1807 | for (j = 0; j < i; j++) { |
1795 | if (after(sp[j].start_seq, sp[j + 1].start_seq)) { | 1808 | if (after(sp[j].start_seq, sp[j + 1].start_seq)) { |
1796 | struct tcp_sack_block tmp; | 1809 | swap(sp[j], sp[j + 1]); |
1797 | |||
1798 | tmp = sp[j]; | ||
1799 | sp[j] = sp[j + 1]; | ||
1800 | sp[j + 1] = tmp; | ||
1801 | 1810 | ||
1802 | /* Track where the first SACK block goes to */ | 1811 | /* Track where the first SACK block goes to */ |
1803 | if (j == first_sack_index) | 1812 | if (j == first_sack_index) |
@@ -2452,6 +2461,44 @@ static int tcp_time_to_recover(struct sock *sk) | |||
2452 | return 0; | 2461 | return 0; |
2453 | } | 2462 | } |
2454 | 2463 | ||
2464 | /* New heuristics: it is possible only after we switched to restart timer | ||
2465 | * each time when something is ACKed. Hence, we can detect timed out packets | ||
2466 | * during fast retransmit without falling to slow start. | ||
2467 | * | ||
2468 | * Usefulness of this as is very questionable, since we should know which of | ||
2469 | * the segments is the next to timeout which is relatively expensive to find | ||
2470 | * in general case unless we add some data structure just for that. The | ||
2471 | * current approach certainly won't find the right one too often and when it | ||
2472 | * finally does find _something_ it usually marks large part of the window | ||
2473 | * right away (because a retransmission with a larger timestamp blocks the | ||
2474 | * loop from advancing). -ij | ||
2475 | */ | ||
2476 | static void tcp_timeout_skbs(struct sock *sk) | ||
2477 | { | ||
2478 | struct tcp_sock *tp = tcp_sk(sk); | ||
2479 | struct sk_buff *skb; | ||
2480 | |||
2481 | if (!tcp_is_fack(tp) || !tcp_head_timedout(sk)) | ||
2482 | return; | ||
2483 | |||
2484 | skb = tp->scoreboard_skb_hint; | ||
2485 | if (tp->scoreboard_skb_hint == NULL) | ||
2486 | skb = tcp_write_queue_head(sk); | ||
2487 | |||
2488 | tcp_for_write_queue_from(skb, sk) { | ||
2489 | if (skb == tcp_send_head(sk)) | ||
2490 | break; | ||
2491 | if (!tcp_skb_timedout(sk, skb)) | ||
2492 | break; | ||
2493 | |||
2494 | tcp_skb_mark_lost(tp, skb); | ||
2495 | } | ||
2496 | |||
2497 | tp->scoreboard_skb_hint = skb; | ||
2498 | |||
2499 | tcp_verify_left_out(tp); | ||
2500 | } | ||
2501 | |||
2455 | /* Mark head of queue up as lost. With RFC3517 SACK, the packets is | 2502 | /* Mark head of queue up as lost. With RFC3517 SACK, the packets is |
2456 | * is against sacked "cnt", otherwise it's against facked "cnt" | 2503 | * is against sacked "cnt", otherwise it's against facked "cnt" |
2457 | */ | 2504 | */ |
@@ -2524,30 +2571,7 @@ static void tcp_update_scoreboard(struct sock *sk, int fast_rexmit) | |||
2524 | tcp_mark_head_lost(sk, sacked_upto); | 2571 | tcp_mark_head_lost(sk, sacked_upto); |
2525 | } | 2572 | } |
2526 | 2573 | ||
2527 | /* New heuristics: it is possible only after we switched | 2574 | tcp_timeout_skbs(sk); |
2528 | * to restart timer each time when something is ACKed. | ||
2529 | * Hence, we can detect timed out packets during fast | ||
2530 | * retransmit without falling to slow start. | ||
2531 | */ | ||
2532 | if (tcp_is_fack(tp) && tcp_head_timedout(sk)) { | ||
2533 | struct sk_buff *skb; | ||
2534 | |||
2535 | skb = tp->scoreboard_skb_hint ? tp->scoreboard_skb_hint | ||
2536 | : tcp_write_queue_head(sk); | ||
2537 | |||
2538 | tcp_for_write_queue_from(skb, sk) { | ||
2539 | if (skb == tcp_send_head(sk)) | ||
2540 | break; | ||
2541 | if (!tcp_skb_timedout(sk, skb)) | ||
2542 | break; | ||
2543 | |||
2544 | tcp_skb_mark_lost(tp, skb); | ||
2545 | } | ||
2546 | |||
2547 | tp->scoreboard_skb_hint = skb; | ||
2548 | |||
2549 | tcp_verify_left_out(tp); | ||
2550 | } | ||
2551 | } | 2575 | } |
2552 | 2576 | ||
2553 | /* CWND moderation, preventing bursts due to too big ACKs | 2577 | /* CWND moderation, preventing bursts due to too big ACKs |
@@ -2812,7 +2836,7 @@ static void tcp_mtup_probe_failed(struct sock *sk) | |||
2812 | icsk->icsk_mtup.probe_size = 0; | 2836 | icsk->icsk_mtup.probe_size = 0; |
2813 | } | 2837 | } |
2814 | 2838 | ||
2815 | static void tcp_mtup_probe_success(struct sock *sk, struct sk_buff *skb) | 2839 | static void tcp_mtup_probe_success(struct sock *sk) |
2816 | { | 2840 | { |
2817 | struct tcp_sock *tp = tcp_sk(sk); | 2841 | struct tcp_sock *tp = tcp_sk(sk); |
2818 | struct inet_connection_sock *icsk = inet_csk(sk); | 2842 | struct inet_connection_sock *icsk = inet_csk(sk); |
@@ -2840,7 +2864,7 @@ void tcp_simple_retransmit(struct sock *sk) | |||
2840 | const struct inet_connection_sock *icsk = inet_csk(sk); | 2864 | const struct inet_connection_sock *icsk = inet_csk(sk); |
2841 | struct tcp_sock *tp = tcp_sk(sk); | 2865 | struct tcp_sock *tp = tcp_sk(sk); |
2842 | struct sk_buff *skb; | 2866 | struct sk_buff *skb; |
2843 | unsigned int mss = tcp_current_mss(sk, 0); | 2867 | unsigned int mss = tcp_current_mss(sk); |
2844 | u32 prior_lost = tp->lost_out; | 2868 | u32 prior_lost = tp->lost_out; |
2845 | 2869 | ||
2846 | tcp_for_write_queue(skb, sk) { | 2870 | tcp_for_write_queue(skb, sk) { |
@@ -3177,7 +3201,6 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, | |||
3177 | 3201 | ||
3178 | while ((skb = tcp_write_queue_head(sk)) && skb != tcp_send_head(sk)) { | 3202 | while ((skb = tcp_write_queue_head(sk)) && skb != tcp_send_head(sk)) { |
3179 | struct tcp_skb_cb *scb = TCP_SKB_CB(skb); | 3203 | struct tcp_skb_cb *scb = TCP_SKB_CB(skb); |
3180 | u32 end_seq; | ||
3181 | u32 acked_pcount; | 3204 | u32 acked_pcount; |
3182 | u8 sacked = scb->sacked; | 3205 | u8 sacked = scb->sacked; |
3183 | 3206 | ||
@@ -3192,16 +3215,8 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, | |||
3192 | break; | 3215 | break; |
3193 | 3216 | ||
3194 | fully_acked = 0; | 3217 | fully_acked = 0; |
3195 | end_seq = tp->snd_una; | ||
3196 | } else { | 3218 | } else { |
3197 | acked_pcount = tcp_skb_pcount(skb); | 3219 | acked_pcount = tcp_skb_pcount(skb); |
3198 | end_seq = scb->end_seq; | ||
3199 | } | ||
3200 | |||
3201 | /* MTU probing checks */ | ||
3202 | if (fully_acked && icsk->icsk_mtup.probe_size && | ||
3203 | !after(tp->mtu_probe.probe_seq_end, scb->end_seq)) { | ||
3204 | tcp_mtup_probe_success(sk, skb); | ||
3205 | } | 3220 | } |
3206 | 3221 | ||
3207 | if (sacked & TCPCB_RETRANS) { | 3222 | if (sacked & TCPCB_RETRANS) { |
@@ -3266,24 +3281,26 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, | |||
3266 | const struct tcp_congestion_ops *ca_ops | 3281 | const struct tcp_congestion_ops *ca_ops |
3267 | = inet_csk(sk)->icsk_ca_ops; | 3282 | = inet_csk(sk)->icsk_ca_ops; |
3268 | 3283 | ||
3284 | if (unlikely(icsk->icsk_mtup.probe_size && | ||
3285 | !after(tp->mtu_probe.probe_seq_end, tp->snd_una))) { | ||
3286 | tcp_mtup_probe_success(sk); | ||
3287 | } | ||
3288 | |||
3269 | tcp_ack_update_rtt(sk, flag, seq_rtt); | 3289 | tcp_ack_update_rtt(sk, flag, seq_rtt); |
3270 | tcp_rearm_rto(sk); | 3290 | tcp_rearm_rto(sk); |
3271 | 3291 | ||
3272 | if (tcp_is_reno(tp)) { | 3292 | if (tcp_is_reno(tp)) { |
3273 | tcp_remove_reno_sacks(sk, pkts_acked); | 3293 | tcp_remove_reno_sacks(sk, pkts_acked); |
3274 | } else { | 3294 | } else { |
3295 | int delta; | ||
3296 | |||
3275 | /* Non-retransmitted hole got filled? That's reordering */ | 3297 | /* Non-retransmitted hole got filled? That's reordering */ |
3276 | if (reord < prior_fackets) | 3298 | if (reord < prior_fackets) |
3277 | tcp_update_reordering(sk, tp->fackets_out - reord, 0); | 3299 | tcp_update_reordering(sk, tp->fackets_out - reord, 0); |
3278 | 3300 | ||
3279 | /* No need to care for underflows here because | 3301 | delta = tcp_is_fack(tp) ? pkts_acked : |
3280 | * the lost_skb_hint gets NULLed if we're past it | 3302 | prior_sacked - tp->sacked_out; |
3281 | * (or something non-trivial happened) | 3303 | tp->lost_cnt_hint -= min(tp->lost_cnt_hint, delta); |
3282 | */ | ||
3283 | if (tcp_is_fack(tp)) | ||
3284 | tp->lost_cnt_hint -= pkts_acked; | ||
3285 | else | ||
3286 | tp->lost_cnt_hint -= prior_sacked - tp->sacked_out; | ||
3287 | } | 3304 | } |
3288 | 3305 | ||
3289 | tp->fackets_out -= min(pkts_acked, tp->fackets_out); | 3306 | tp->fackets_out -= min(pkts_acked, tp->fackets_out); |
@@ -3395,7 +3412,7 @@ static int tcp_ack_update_window(struct sock *sk, struct sk_buff *skb, u32 ack, | |||
3395 | 3412 | ||
3396 | if (tcp_may_update_window(tp, ack, ack_seq, nwin)) { | 3413 | if (tcp_may_update_window(tp, ack, ack_seq, nwin)) { |
3397 | flag |= FLAG_WIN_UPDATE; | 3414 | flag |= FLAG_WIN_UPDATE; |
3398 | tcp_update_wl(tp, ack, ack_seq); | 3415 | tcp_update_wl(tp, ack_seq); |
3399 | 3416 | ||
3400 | if (tp->snd_wnd != nwin) { | 3417 | if (tp->snd_wnd != nwin) { |
3401 | tp->snd_wnd = nwin; | 3418 | tp->snd_wnd = nwin; |
@@ -3571,15 +3588,18 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
3571 | int prior_packets; | 3588 | int prior_packets; |
3572 | int frto_cwnd = 0; | 3589 | int frto_cwnd = 0; |
3573 | 3590 | ||
3574 | /* If the ack is newer than sent or older than previous acks | 3591 | /* If the ack is older than previous acks |
3575 | * then we can probably ignore it. | 3592 | * then we can probably ignore it. |
3576 | */ | 3593 | */ |
3577 | if (after(ack, tp->snd_nxt)) | ||
3578 | goto uninteresting_ack; | ||
3579 | |||
3580 | if (before(ack, prior_snd_una)) | 3594 | if (before(ack, prior_snd_una)) |
3581 | goto old_ack; | 3595 | goto old_ack; |
3582 | 3596 | ||
3597 | /* If the ack includes data we haven't sent yet, discard | ||
3598 | * this segment (RFC793 Section 3.9). | ||
3599 | */ | ||
3600 | if (after(ack, tp->snd_nxt)) | ||
3601 | goto invalid_ack; | ||
3602 | |||
3583 | if (after(ack, prior_snd_una)) | 3603 | if (after(ack, prior_snd_una)) |
3584 | flag |= FLAG_SND_UNA_ADVANCED; | 3604 | flag |= FLAG_SND_UNA_ADVANCED; |
3585 | 3605 | ||
@@ -3600,7 +3620,7 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
3600 | * No more checks are required. | 3620 | * No more checks are required. |
3601 | * Note, we use the fact that SND.UNA>=SND.WL2. | 3621 | * Note, we use the fact that SND.UNA>=SND.WL2. |
3602 | */ | 3622 | */ |
3603 | tcp_update_wl(tp, ack, ack_seq); | 3623 | tcp_update_wl(tp, ack_seq); |
3604 | tp->snd_una = ack; | 3624 | tp->snd_una = ack; |
3605 | flag |= FLAG_WIN_UPDATE; | 3625 | flag |= FLAG_WIN_UPDATE; |
3606 | 3626 | ||
@@ -3669,6 +3689,10 @@ no_queue: | |||
3669 | tcp_ack_probe(sk); | 3689 | tcp_ack_probe(sk); |
3670 | return 1; | 3690 | return 1; |
3671 | 3691 | ||
3692 | invalid_ack: | ||
3693 | SOCK_DEBUG(sk, "Ack %u after %u:%u\n", ack, tp->snd_una, tp->snd_nxt); | ||
3694 | return -1; | ||
3695 | |||
3672 | old_ack: | 3696 | old_ack: |
3673 | if (TCP_SKB_CB(skb)->sacked) { | 3697 | if (TCP_SKB_CB(skb)->sacked) { |
3674 | tcp_sacktag_write_queue(sk, skb, prior_snd_una); | 3698 | tcp_sacktag_write_queue(sk, skb, prior_snd_una); |
@@ -3676,8 +3700,7 @@ old_ack: | |||
3676 | tcp_try_keep_open(sk); | 3700 | tcp_try_keep_open(sk); |
3677 | } | 3701 | } |
3678 | 3702 | ||
3679 | uninteresting_ack: | 3703 | SOCK_DEBUG(sk, "Ack %u before %u:%u\n", ack, tp->snd_una, tp->snd_nxt); |
3680 | SOCK_DEBUG(sk, "Ack %u out of %u:%u\n", ack, tp->snd_una, tp->snd_nxt); | ||
3681 | return 0; | 3704 | return 0; |
3682 | } | 3705 | } |
3683 | 3706 | ||
@@ -3865,8 +3888,7 @@ static inline void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq) | |||
3865 | * Not only, also it occurs for expired timestamps. | 3888 | * Not only, also it occurs for expired timestamps. |
3866 | */ | 3889 | */ |
3867 | 3890 | ||
3868 | if ((s32)(tp->rx_opt.rcv_tsval - tp->rx_opt.ts_recent) >= 0 || | 3891 | if (tcp_paws_check(&tp->rx_opt, 0)) |
3869 | get_seconds() >= tp->rx_opt.ts_recent_stamp + TCP_PAWS_24DAYS) | ||
3870 | tcp_store_ts_recent(tp); | 3892 | tcp_store_ts_recent(tp); |
3871 | } | 3893 | } |
3872 | } | 3894 | } |
@@ -3918,9 +3940,9 @@ static inline int tcp_paws_discard(const struct sock *sk, | |||
3918 | const struct sk_buff *skb) | 3940 | const struct sk_buff *skb) |
3919 | { | 3941 | { |
3920 | const struct tcp_sock *tp = tcp_sk(sk); | 3942 | const struct tcp_sock *tp = tcp_sk(sk); |
3921 | return ((s32)(tp->rx_opt.ts_recent - tp->rx_opt.rcv_tsval) > TCP_PAWS_WINDOW && | 3943 | |
3922 | get_seconds() < tp->rx_opt.ts_recent_stamp + TCP_PAWS_24DAYS && | 3944 | return !tcp_paws_check(&tp->rx_opt, TCP_PAWS_WINDOW) && |
3923 | !tcp_disordered_ack(sk, skb)); | 3945 | !tcp_disordered_ack(sk, skb); |
3924 | } | 3946 | } |
3925 | 3947 | ||
3926 | /* Check segment sequence number for validity. | 3948 | /* Check segment sequence number for validity. |
@@ -4078,7 +4100,6 @@ static void tcp_dsack_set(struct sock *sk, u32 seq, u32 end_seq) | |||
4078 | tp->rx_opt.dsack = 1; | 4100 | tp->rx_opt.dsack = 1; |
4079 | tp->duplicate_sack[0].start_seq = seq; | 4101 | tp->duplicate_sack[0].start_seq = seq; |
4080 | tp->duplicate_sack[0].end_seq = end_seq; | 4102 | tp->duplicate_sack[0].end_seq = end_seq; |
4081 | tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks + 1; | ||
4082 | } | 4103 | } |
4083 | } | 4104 | } |
4084 | 4105 | ||
@@ -4133,8 +4154,6 @@ static void tcp_sack_maybe_coalesce(struct tcp_sock *tp) | |||
4133 | * Decrease num_sacks. | 4154 | * Decrease num_sacks. |
4134 | */ | 4155 | */ |
4135 | tp->rx_opt.num_sacks--; | 4156 | tp->rx_opt.num_sacks--; |
4136 | tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks + | ||
4137 | tp->rx_opt.dsack; | ||
4138 | for (i = this_sack; i < tp->rx_opt.num_sacks; i++) | 4157 | for (i = this_sack; i < tp->rx_opt.num_sacks; i++) |
4139 | sp[i] = sp[i + 1]; | 4158 | sp[i] = sp[i + 1]; |
4140 | continue; | 4159 | continue; |
@@ -4143,20 +4162,6 @@ static void tcp_sack_maybe_coalesce(struct tcp_sock *tp) | |||
4143 | } | 4162 | } |
4144 | } | 4163 | } |
4145 | 4164 | ||
4146 | static inline void tcp_sack_swap(struct tcp_sack_block *sack1, | ||
4147 | struct tcp_sack_block *sack2) | ||
4148 | { | ||
4149 | __u32 tmp; | ||
4150 | |||
4151 | tmp = sack1->start_seq; | ||
4152 | sack1->start_seq = sack2->start_seq; | ||
4153 | sack2->start_seq = tmp; | ||
4154 | |||
4155 | tmp = sack1->end_seq; | ||
4156 | sack1->end_seq = sack2->end_seq; | ||
4157 | sack2->end_seq = tmp; | ||
4158 | } | ||
4159 | |||
4160 | static void tcp_sack_new_ofo_skb(struct sock *sk, u32 seq, u32 end_seq) | 4165 | static void tcp_sack_new_ofo_skb(struct sock *sk, u32 seq, u32 end_seq) |
4161 | { | 4166 | { |
4162 | struct tcp_sock *tp = tcp_sk(sk); | 4167 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -4171,7 +4176,7 @@ static void tcp_sack_new_ofo_skb(struct sock *sk, u32 seq, u32 end_seq) | |||
4171 | if (tcp_sack_extend(sp, seq, end_seq)) { | 4176 | if (tcp_sack_extend(sp, seq, end_seq)) { |
4172 | /* Rotate this_sack to the first one. */ | 4177 | /* Rotate this_sack to the first one. */ |
4173 | for (; this_sack > 0; this_sack--, sp--) | 4178 | for (; this_sack > 0; this_sack--, sp--) |
4174 | tcp_sack_swap(sp, sp - 1); | 4179 | swap(*sp, *(sp - 1)); |
4175 | if (cur_sacks > 1) | 4180 | if (cur_sacks > 1) |
4176 | tcp_sack_maybe_coalesce(tp); | 4181 | tcp_sack_maybe_coalesce(tp); |
4177 | return; | 4182 | return; |
@@ -4197,7 +4202,6 @@ new_sack: | |||
4197 | sp->start_seq = seq; | 4202 | sp->start_seq = seq; |
4198 | sp->end_seq = end_seq; | 4203 | sp->end_seq = end_seq; |
4199 | tp->rx_opt.num_sacks++; | 4204 | tp->rx_opt.num_sacks++; |
4200 | tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack; | ||
4201 | } | 4205 | } |
4202 | 4206 | ||
4203 | /* RCV.NXT advances, some SACKs should be eaten. */ | 4207 | /* RCV.NXT advances, some SACKs should be eaten. */ |
@@ -4211,7 +4215,6 @@ static void tcp_sack_remove(struct tcp_sock *tp) | |||
4211 | /* Empty ofo queue, hence, all the SACKs are eaten. Clear. */ | 4215 | /* Empty ofo queue, hence, all the SACKs are eaten. Clear. */ |
4212 | if (skb_queue_empty(&tp->out_of_order_queue)) { | 4216 | if (skb_queue_empty(&tp->out_of_order_queue)) { |
4213 | tp->rx_opt.num_sacks = 0; | 4217 | tp->rx_opt.num_sacks = 0; |
4214 | tp->rx_opt.eff_sacks = tp->rx_opt.dsack; | ||
4215 | return; | 4218 | return; |
4216 | } | 4219 | } |
4217 | 4220 | ||
@@ -4232,11 +4235,7 @@ static void tcp_sack_remove(struct tcp_sock *tp) | |||
4232 | this_sack++; | 4235 | this_sack++; |
4233 | sp++; | 4236 | sp++; |
4234 | } | 4237 | } |
4235 | if (num_sacks != tp->rx_opt.num_sacks) { | 4238 | tp->rx_opt.num_sacks = num_sacks; |
4236 | tp->rx_opt.num_sacks = num_sacks; | ||
4237 | tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks + | ||
4238 | tp->rx_opt.dsack; | ||
4239 | } | ||
4240 | } | 4239 | } |
4241 | 4240 | ||
4242 | /* This one checks to see if we can put data from the | 4241 | /* This one checks to see if we can put data from the |
@@ -4312,10 +4311,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) | |||
4312 | 4311 | ||
4313 | TCP_ECN_accept_cwr(tp, skb); | 4312 | TCP_ECN_accept_cwr(tp, skb); |
4314 | 4313 | ||
4315 | if (tp->rx_opt.dsack) { | 4314 | tp->rx_opt.dsack = 0; |
4316 | tp->rx_opt.dsack = 0; | ||
4317 | tp->rx_opt.eff_sacks = tp->rx_opt.num_sacks; | ||
4318 | } | ||
4319 | 4315 | ||
4320 | /* Queue data for delivery to the user. | 4316 | /* Queue data for delivery to the user. |
4321 | * Packets in sequence go to the receive queue. | 4317 | * Packets in sequence go to the receive queue. |
@@ -4434,8 +4430,6 @@ drop: | |||
4434 | /* Initial out of order segment, build 1 SACK. */ | 4430 | /* Initial out of order segment, build 1 SACK. */ |
4435 | if (tcp_is_sack(tp)) { | 4431 | if (tcp_is_sack(tp)) { |
4436 | tp->rx_opt.num_sacks = 1; | 4432 | tp->rx_opt.num_sacks = 1; |
4437 | tp->rx_opt.dsack = 0; | ||
4438 | tp->rx_opt.eff_sacks = 1; | ||
4439 | tp->selective_acks[0].start_seq = TCP_SKB_CB(skb)->seq; | 4433 | tp->selective_acks[0].start_seq = TCP_SKB_CB(skb)->seq; |
4440 | tp->selective_acks[0].end_seq = | 4434 | tp->selective_acks[0].end_seq = |
4441 | TCP_SKB_CB(skb)->end_seq; | 4435 | TCP_SKB_CB(skb)->end_seq; |
@@ -5156,7 +5150,8 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, | |||
5156 | */ | 5150 | */ |
5157 | 5151 | ||
5158 | if ((tcp_flag_word(th) & TCP_HP_BITS) == tp->pred_flags && | 5152 | if ((tcp_flag_word(th) & TCP_HP_BITS) == tp->pred_flags && |
5159 | TCP_SKB_CB(skb)->seq == tp->rcv_nxt) { | 5153 | TCP_SKB_CB(skb)->seq == tp->rcv_nxt && |
5154 | !after(TCP_SKB_CB(skb)->ack_seq, tp->snd_nxt)) { | ||
5160 | int tcp_header_len = tp->tcp_header_len; | 5155 | int tcp_header_len = tp->tcp_header_len; |
5161 | 5156 | ||
5162 | /* Timestamp header prediction: tcp_header_len | 5157 | /* Timestamp header prediction: tcp_header_len |
@@ -5309,8 +5304,8 @@ slow_path: | |||
5309 | return -res; | 5304 | return -res; |
5310 | 5305 | ||
5311 | step5: | 5306 | step5: |
5312 | if (th->ack) | 5307 | if (th->ack && tcp_ack(sk, skb, FLAG_SLOWPATH) < 0) |
5313 | tcp_ack(sk, skb, FLAG_SLOWPATH); | 5308 | goto discard; |
5314 | 5309 | ||
5315 | tcp_rcv_rtt_measure_ts(sk, skb); | 5310 | tcp_rcv_rtt_measure_ts(sk, skb); |
5316 | 5311 | ||
@@ -5408,7 +5403,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, | |||
5408 | * never scaled. | 5403 | * never scaled. |
5409 | */ | 5404 | */ |
5410 | tp->snd_wnd = ntohs(th->window); | 5405 | tp->snd_wnd = ntohs(th->window); |
5411 | tcp_init_wl(tp, TCP_SKB_CB(skb)->ack_seq, TCP_SKB_CB(skb)->seq); | 5406 | tcp_init_wl(tp, TCP_SKB_CB(skb)->seq); |
5412 | 5407 | ||
5413 | if (!tp->rx_opt.wscale_ok) { | 5408 | if (!tp->rx_opt.wscale_ok) { |
5414 | tp->rx_opt.snd_wscale = tp->rx_opt.rcv_wscale = 0; | 5409 | tp->rx_opt.snd_wscale = tp->rx_opt.rcv_wscale = 0; |
@@ -5509,7 +5504,7 @@ discard: | |||
5509 | 5504 | ||
5510 | /* PAWS check. */ | 5505 | /* PAWS check. */ |
5511 | if (tp->rx_opt.ts_recent_stamp && tp->rx_opt.saw_tstamp && | 5506 | if (tp->rx_opt.ts_recent_stamp && tp->rx_opt.saw_tstamp && |
5512 | tcp_paws_check(&tp->rx_opt, 0)) | 5507 | tcp_paws_reject(&tp->rx_opt, 0)) |
5513 | goto discard_and_undo; | 5508 | goto discard_and_undo; |
5514 | 5509 | ||
5515 | if (th->syn) { | 5510 | if (th->syn) { |
@@ -5647,7 +5642,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | |||
5647 | 5642 | ||
5648 | /* step 5: check the ACK field */ | 5643 | /* step 5: check the ACK field */ |
5649 | if (th->ack) { | 5644 | if (th->ack) { |
5650 | int acceptable = tcp_ack(sk, skb, FLAG_SLOWPATH); | 5645 | int acceptable = tcp_ack(sk, skb, FLAG_SLOWPATH) > 0; |
5651 | 5646 | ||
5652 | switch (sk->sk_state) { | 5647 | switch (sk->sk_state) { |
5653 | case TCP_SYN_RECV: | 5648 | case TCP_SYN_RECV: |
@@ -5669,8 +5664,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | |||
5669 | tp->snd_una = TCP_SKB_CB(skb)->ack_seq; | 5664 | tp->snd_una = TCP_SKB_CB(skb)->ack_seq; |
5670 | tp->snd_wnd = ntohs(th->window) << | 5665 | tp->snd_wnd = ntohs(th->window) << |
5671 | tp->rx_opt.snd_wscale; | 5666 | tp->rx_opt.snd_wscale; |
5672 | tcp_init_wl(tp, TCP_SKB_CB(skb)->ack_seq, | 5667 | tcp_init_wl(tp, TCP_SKB_CB(skb)->seq); |
5673 | TCP_SKB_CB(skb)->seq); | ||
5674 | 5668 | ||
5675 | /* tcp_ack considers this ACK as duplicate | 5669 | /* tcp_ack considers this ACK as duplicate |
5676 | * and does not calculate rtt. | 5670 | * and does not calculate rtt. |