diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-09-08 05:43:49 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-09-08 05:43:49 -0400 |
commit | 1d6ae775d7a948c9575658eb41184fd2e506c0df (patch) | |
tree | 8128a28e89d82f13bb8e3a2160382240c66e2816 /net/ipv4/tcp_input.c | |
parent | 739cdbf1d8f0739b80035b80d69d871e33749b86 (diff) | |
parent | caf39e87cc1182f7dae84eefc43ca14d54c78ef9 (diff) |
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r-- | net/ipv4/tcp_input.c | 549 |
1 files changed, 305 insertions, 244 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 53a8a5399f1e..29222b964951 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -114,20 +114,21 @@ int sysctl_tcp_moderate_rcvbuf = 1; | |||
114 | /* Adapt the MSS value used to make delayed ack decision to the | 114 | /* Adapt the MSS value used to make delayed ack decision to the |
115 | * real world. | 115 | * real world. |
116 | */ | 116 | */ |
117 | static inline void tcp_measure_rcv_mss(struct tcp_sock *tp, | 117 | static inline void tcp_measure_rcv_mss(struct sock *sk, |
118 | struct sk_buff *skb) | 118 | const struct sk_buff *skb) |
119 | { | 119 | { |
120 | unsigned int len, lss; | 120 | struct inet_connection_sock *icsk = inet_csk(sk); |
121 | const unsigned int lss = icsk->icsk_ack.last_seg_size; | ||
122 | unsigned int len; | ||
121 | 123 | ||
122 | lss = tp->ack.last_seg_size; | 124 | icsk->icsk_ack.last_seg_size = 0; |
123 | tp->ack.last_seg_size = 0; | ||
124 | 125 | ||
125 | /* skb->len may jitter because of SACKs, even if peer | 126 | /* skb->len may jitter because of SACKs, even if peer |
126 | * sends good full-sized frames. | 127 | * sends good full-sized frames. |
127 | */ | 128 | */ |
128 | len = skb->len; | 129 | len = skb->len; |
129 | if (len >= tp->ack.rcv_mss) { | 130 | if (len >= icsk->icsk_ack.rcv_mss) { |
130 | tp->ack.rcv_mss = len; | 131 | icsk->icsk_ack.rcv_mss = len; |
131 | } else { | 132 | } else { |
132 | /* Otherwise, we make more careful check taking into account, | 133 | /* Otherwise, we make more careful check taking into account, |
133 | * that SACKs block is variable. | 134 | * that SACKs block is variable. |
@@ -147,41 +148,44 @@ static inline void tcp_measure_rcv_mss(struct tcp_sock *tp, | |||
147 | * tcp header plus fixed timestamp option length. | 148 | * tcp header plus fixed timestamp option length. |
148 | * Resulting "len" is MSS free of SACK jitter. | 149 | * Resulting "len" is MSS free of SACK jitter. |
149 | */ | 150 | */ |
150 | len -= tp->tcp_header_len; | 151 | len -= tcp_sk(sk)->tcp_header_len; |
151 | tp->ack.last_seg_size = len; | 152 | icsk->icsk_ack.last_seg_size = len; |
152 | if (len == lss) { | 153 | if (len == lss) { |
153 | tp->ack.rcv_mss = len; | 154 | icsk->icsk_ack.rcv_mss = len; |
154 | return; | 155 | return; |
155 | } | 156 | } |
156 | } | 157 | } |
157 | tp->ack.pending |= TCP_ACK_PUSHED; | 158 | icsk->icsk_ack.pending |= ICSK_ACK_PUSHED; |
158 | } | 159 | } |
159 | } | 160 | } |
160 | 161 | ||
161 | static void tcp_incr_quickack(struct tcp_sock *tp) | 162 | static void tcp_incr_quickack(struct sock *sk) |
162 | { | 163 | { |
163 | unsigned quickacks = tp->rcv_wnd/(2*tp->ack.rcv_mss); | 164 | struct inet_connection_sock *icsk = inet_csk(sk); |
165 | unsigned quickacks = tcp_sk(sk)->rcv_wnd / (2 * icsk->icsk_ack.rcv_mss); | ||
164 | 166 | ||
165 | if (quickacks==0) | 167 | if (quickacks==0) |
166 | quickacks=2; | 168 | quickacks=2; |
167 | if (quickacks > tp->ack.quick) | 169 | if (quickacks > icsk->icsk_ack.quick) |
168 | tp->ack.quick = min(quickacks, TCP_MAX_QUICKACKS); | 170 | icsk->icsk_ack.quick = min(quickacks, TCP_MAX_QUICKACKS); |
169 | } | 171 | } |
170 | 172 | ||
171 | void tcp_enter_quickack_mode(struct tcp_sock *tp) | 173 | void tcp_enter_quickack_mode(struct sock *sk) |
172 | { | 174 | { |
173 | tcp_incr_quickack(tp); | 175 | struct inet_connection_sock *icsk = inet_csk(sk); |
174 | tp->ack.pingpong = 0; | 176 | tcp_incr_quickack(sk); |
175 | tp->ack.ato = TCP_ATO_MIN; | 177 | icsk->icsk_ack.pingpong = 0; |
178 | icsk->icsk_ack.ato = TCP_ATO_MIN; | ||
176 | } | 179 | } |
177 | 180 | ||
178 | /* Send ACKs quickly, if "quick" count is not exhausted | 181 | /* Send ACKs quickly, if "quick" count is not exhausted |
179 | * and the session is not interactive. | 182 | * and the session is not interactive. |
180 | */ | 183 | */ |
181 | 184 | ||
182 | static __inline__ int tcp_in_quickack_mode(struct tcp_sock *tp) | 185 | static inline int tcp_in_quickack_mode(const struct sock *sk) |
183 | { | 186 | { |
184 | return (tp->ack.quick && !tp->ack.pingpong); | 187 | const struct inet_connection_sock *icsk = inet_csk(sk); |
188 | return icsk->icsk_ack.quick && !icsk->icsk_ack.pingpong; | ||
185 | } | 189 | } |
186 | 190 | ||
187 | /* Buffer size and advertised window tuning. | 191 | /* Buffer size and advertised window tuning. |
@@ -224,8 +228,8 @@ static void tcp_fixup_sndbuf(struct sock *sk) | |||
224 | */ | 228 | */ |
225 | 229 | ||
226 | /* Slow part of check#2. */ | 230 | /* Slow part of check#2. */ |
227 | static int __tcp_grow_window(struct sock *sk, struct tcp_sock *tp, | 231 | static int __tcp_grow_window(const struct sock *sk, struct tcp_sock *tp, |
228 | struct sk_buff *skb) | 232 | const struct sk_buff *skb) |
229 | { | 233 | { |
230 | /* Optimize this! */ | 234 | /* Optimize this! */ |
231 | int truesize = tcp_win_from_space(skb->truesize)/2; | 235 | int truesize = tcp_win_from_space(skb->truesize)/2; |
@@ -233,7 +237,7 @@ static int __tcp_grow_window(struct sock *sk, struct tcp_sock *tp, | |||
233 | 237 | ||
234 | while (tp->rcv_ssthresh <= window) { | 238 | while (tp->rcv_ssthresh <= window) { |
235 | if (truesize <= skb->len) | 239 | if (truesize <= skb->len) |
236 | return 2*tp->ack.rcv_mss; | 240 | return 2 * inet_csk(sk)->icsk_ack.rcv_mss; |
237 | 241 | ||
238 | truesize >>= 1; | 242 | truesize >>= 1; |
239 | window >>= 1; | 243 | window >>= 1; |
@@ -260,7 +264,7 @@ static inline void tcp_grow_window(struct sock *sk, struct tcp_sock *tp, | |||
260 | 264 | ||
261 | if (incr) { | 265 | if (incr) { |
262 | tp->rcv_ssthresh = min(tp->rcv_ssthresh + incr, tp->window_clamp); | 266 | tp->rcv_ssthresh = min(tp->rcv_ssthresh + incr, tp->window_clamp); |
263 | tp->ack.quick |= 1; | 267 | inet_csk(sk)->icsk_ack.quick |= 1; |
264 | } | 268 | } |
265 | } | 269 | } |
266 | } | 270 | } |
@@ -321,11 +325,12 @@ static void tcp_init_buffer_space(struct sock *sk) | |||
321 | /* 5. Recalculate window clamp after socket hit its memory bounds. */ | 325 | /* 5. Recalculate window clamp after socket hit its memory bounds. */ |
322 | static void tcp_clamp_window(struct sock *sk, struct tcp_sock *tp) | 326 | static void tcp_clamp_window(struct sock *sk, struct tcp_sock *tp) |
323 | { | 327 | { |
328 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
324 | struct sk_buff *skb; | 329 | struct sk_buff *skb; |
325 | unsigned int app_win = tp->rcv_nxt - tp->copied_seq; | 330 | unsigned int app_win = tp->rcv_nxt - tp->copied_seq; |
326 | int ofo_win = 0; | 331 | int ofo_win = 0; |
327 | 332 | ||
328 | tp->ack.quick = 0; | 333 | icsk->icsk_ack.quick = 0; |
329 | 334 | ||
330 | skb_queue_walk(&tp->out_of_order_queue, skb) { | 335 | skb_queue_walk(&tp->out_of_order_queue, skb) { |
331 | ofo_win += skb->len; | 336 | ofo_win += skb->len; |
@@ -346,8 +351,8 @@ static void tcp_clamp_window(struct sock *sk, struct tcp_sock *tp) | |||
346 | app_win += ofo_win; | 351 | app_win += ofo_win; |
347 | if (atomic_read(&sk->sk_rmem_alloc) >= 2 * sk->sk_rcvbuf) | 352 | if (atomic_read(&sk->sk_rmem_alloc) >= 2 * sk->sk_rcvbuf) |
348 | app_win >>= 1; | 353 | app_win >>= 1; |
349 | if (app_win > tp->ack.rcv_mss) | 354 | if (app_win > icsk->icsk_ack.rcv_mss) |
350 | app_win -= tp->ack.rcv_mss; | 355 | app_win -= icsk->icsk_ack.rcv_mss; |
351 | app_win = max(app_win, 2U*tp->advmss); | 356 | app_win = max(app_win, 2U*tp->advmss); |
352 | 357 | ||
353 | if (!ofo_win) | 358 | if (!ofo_win) |
@@ -415,11 +420,12 @@ new_measure: | |||
415 | tp->rcv_rtt_est.time = tcp_time_stamp; | 420 | tp->rcv_rtt_est.time = tcp_time_stamp; |
416 | } | 421 | } |
417 | 422 | ||
418 | static inline void tcp_rcv_rtt_measure_ts(struct tcp_sock *tp, struct sk_buff *skb) | 423 | static inline void tcp_rcv_rtt_measure_ts(struct sock *sk, const struct sk_buff *skb) |
419 | { | 424 | { |
425 | struct tcp_sock *tp = tcp_sk(sk); | ||
420 | if (tp->rx_opt.rcv_tsecr && | 426 | if (tp->rx_opt.rcv_tsecr && |
421 | (TCP_SKB_CB(skb)->end_seq - | 427 | (TCP_SKB_CB(skb)->end_seq - |
422 | TCP_SKB_CB(skb)->seq >= tp->ack.rcv_mss)) | 428 | TCP_SKB_CB(skb)->seq >= inet_csk(sk)->icsk_ack.rcv_mss)) |
423 | tcp_rcv_rtt_update(tp, tcp_time_stamp - tp->rx_opt.rcv_tsecr, 0); | 429 | tcp_rcv_rtt_update(tp, tcp_time_stamp - tp->rx_opt.rcv_tsecr, 0); |
424 | } | 430 | } |
425 | 431 | ||
@@ -492,41 +498,42 @@ new_measure: | |||
492 | */ | 498 | */ |
493 | static void tcp_event_data_recv(struct sock *sk, struct tcp_sock *tp, struct sk_buff *skb) | 499 | static void tcp_event_data_recv(struct sock *sk, struct tcp_sock *tp, struct sk_buff *skb) |
494 | { | 500 | { |
501 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
495 | u32 now; | 502 | u32 now; |
496 | 503 | ||
497 | tcp_schedule_ack(tp); | 504 | inet_csk_schedule_ack(sk); |
498 | 505 | ||
499 | tcp_measure_rcv_mss(tp, skb); | 506 | tcp_measure_rcv_mss(sk, skb); |
500 | 507 | ||
501 | tcp_rcv_rtt_measure(tp); | 508 | tcp_rcv_rtt_measure(tp); |
502 | 509 | ||
503 | now = tcp_time_stamp; | 510 | now = tcp_time_stamp; |
504 | 511 | ||
505 | if (!tp->ack.ato) { | 512 | if (!icsk->icsk_ack.ato) { |
506 | /* The _first_ data packet received, initialize | 513 | /* The _first_ data packet received, initialize |
507 | * delayed ACK engine. | 514 | * delayed ACK engine. |
508 | */ | 515 | */ |
509 | tcp_incr_quickack(tp); | 516 | tcp_incr_quickack(sk); |
510 | tp->ack.ato = TCP_ATO_MIN; | 517 | icsk->icsk_ack.ato = TCP_ATO_MIN; |
511 | } else { | 518 | } else { |
512 | int m = now - tp->ack.lrcvtime; | 519 | int m = now - icsk->icsk_ack.lrcvtime; |
513 | 520 | ||
514 | if (m <= TCP_ATO_MIN/2) { | 521 | if (m <= TCP_ATO_MIN/2) { |
515 | /* The fastest case is the first. */ | 522 | /* The fastest case is the first. */ |
516 | tp->ack.ato = (tp->ack.ato>>1) + TCP_ATO_MIN/2; | 523 | icsk->icsk_ack.ato = (icsk->icsk_ack.ato >> 1) + TCP_ATO_MIN / 2; |
517 | } else if (m < tp->ack.ato) { | 524 | } else if (m < icsk->icsk_ack.ato) { |
518 | tp->ack.ato = (tp->ack.ato>>1) + m; | 525 | icsk->icsk_ack.ato = (icsk->icsk_ack.ato >> 1) + m; |
519 | if (tp->ack.ato > tp->rto) | 526 | if (icsk->icsk_ack.ato > icsk->icsk_rto) |
520 | tp->ack.ato = tp->rto; | 527 | icsk->icsk_ack.ato = icsk->icsk_rto; |
521 | } else if (m > tp->rto) { | 528 | } else if (m > icsk->icsk_rto) { |
522 | /* Too long gap. Apparently sender falled to | 529 | /* Too long gap. Apparently sender falled to |
523 | * restart window, so that we send ACKs quickly. | 530 | * restart window, so that we send ACKs quickly. |
524 | */ | 531 | */ |
525 | tcp_incr_quickack(tp); | 532 | tcp_incr_quickack(sk); |
526 | sk_stream_mem_reclaim(sk); | 533 | sk_stream_mem_reclaim(sk); |
527 | } | 534 | } |
528 | } | 535 | } |
529 | tp->ack.lrcvtime = now; | 536 | icsk->icsk_ack.lrcvtime = now; |
530 | 537 | ||
531 | TCP_ECN_check_ce(tp, skb); | 538 | TCP_ECN_check_ce(tp, skb); |
532 | 539 | ||
@@ -543,8 +550,10 @@ static void tcp_event_data_recv(struct sock *sk, struct tcp_sock *tp, struct sk_ | |||
543 | * To save cycles in the RFC 1323 implementation it was better to break | 550 | * To save cycles in the RFC 1323 implementation it was better to break |
544 | * it up into three procedures. -- erics | 551 | * it up into three procedures. -- erics |
545 | */ | 552 | */ |
546 | static void tcp_rtt_estimator(struct tcp_sock *tp, __u32 mrtt, u32 *usrtt) | 553 | static void tcp_rtt_estimator(struct sock *sk, const __u32 mrtt, u32 *usrtt) |
547 | { | 554 | { |
555 | struct tcp_sock *tp = tcp_sk(sk); | ||
556 | const struct inet_connection_sock *icsk = inet_csk(sk); | ||
548 | long m = mrtt; /* RTT */ | 557 | long m = mrtt; /* RTT */ |
549 | 558 | ||
550 | /* The following amusing code comes from Jacobson's | 559 | /* The following amusing code comes from Jacobson's |
@@ -604,15 +613,16 @@ static void tcp_rtt_estimator(struct tcp_sock *tp, __u32 mrtt, u32 *usrtt) | |||
604 | tp->rtt_seq = tp->snd_nxt; | 613 | tp->rtt_seq = tp->snd_nxt; |
605 | } | 614 | } |
606 | 615 | ||
607 | if (tp->ca_ops->rtt_sample) | 616 | if (icsk->icsk_ca_ops->rtt_sample) |
608 | tp->ca_ops->rtt_sample(tp, *usrtt); | 617 | icsk->icsk_ca_ops->rtt_sample(sk, *usrtt); |
609 | } | 618 | } |
610 | 619 | ||
611 | /* Calculate rto without backoff. This is the second half of Van Jacobson's | 620 | /* Calculate rto without backoff. This is the second half of Van Jacobson's |
612 | * routine referred to above. | 621 | * routine referred to above. |
613 | */ | 622 | */ |
614 | static inline void tcp_set_rto(struct tcp_sock *tp) | 623 | static inline void tcp_set_rto(struct sock *sk) |
615 | { | 624 | { |
625 | const struct tcp_sock *tp = tcp_sk(sk); | ||
616 | /* Old crap is replaced with new one. 8) | 626 | /* Old crap is replaced with new one. 8) |
617 | * | 627 | * |
618 | * More seriously: | 628 | * More seriously: |
@@ -623,7 +633,7 @@ static inline void tcp_set_rto(struct tcp_sock *tp) | |||
623 | * is invisible. Actually, Linux-2.4 also generates erratic | 633 | * is invisible. Actually, Linux-2.4 also generates erratic |
624 | * ACKs in some curcumstances. | 634 | * ACKs in some curcumstances. |
625 | */ | 635 | */ |
626 | tp->rto = (tp->srtt >> 3) + tp->rttvar; | 636 | inet_csk(sk)->icsk_rto = (tp->srtt >> 3) + tp->rttvar; |
627 | 637 | ||
628 | /* 2. Fixups made earlier cannot be right. | 638 | /* 2. Fixups made earlier cannot be right. |
629 | * If we do not estimate RTO correctly without them, | 639 | * If we do not estimate RTO correctly without them, |
@@ -635,10 +645,10 @@ static inline void tcp_set_rto(struct tcp_sock *tp) | |||
635 | /* NOTE: clamping at TCP_RTO_MIN is not required, current algo | 645 | /* NOTE: clamping at TCP_RTO_MIN is not required, current algo |
636 | * guarantees that rto is higher. | 646 | * guarantees that rto is higher. |
637 | */ | 647 | */ |
638 | static inline void tcp_bound_rto(struct tcp_sock *tp) | 648 | static inline void tcp_bound_rto(struct sock *sk) |
639 | { | 649 | { |
640 | if (tp->rto > TCP_RTO_MAX) | 650 | if (inet_csk(sk)->icsk_rto > TCP_RTO_MAX) |
641 | tp->rto = TCP_RTO_MAX; | 651 | inet_csk(sk)->icsk_rto = TCP_RTO_MAX; |
642 | } | 652 | } |
643 | 653 | ||
644 | /* Save metrics learned by this TCP session. | 654 | /* Save metrics learned by this TCP session. |
@@ -656,9 +666,10 @@ void tcp_update_metrics(struct sock *sk) | |||
656 | dst_confirm(dst); | 666 | dst_confirm(dst); |
657 | 667 | ||
658 | if (dst && (dst->flags&DST_HOST)) { | 668 | if (dst && (dst->flags&DST_HOST)) { |
669 | const struct inet_connection_sock *icsk = inet_csk(sk); | ||
659 | int m; | 670 | int m; |
660 | 671 | ||
661 | if (tp->backoff || !tp->srtt) { | 672 | if (icsk->icsk_backoff || !tp->srtt) { |
662 | /* This session failed to estimate rtt. Why? | 673 | /* This session failed to estimate rtt. Why? |
663 | * Probably, no packets returned in time. | 674 | * Probably, no packets returned in time. |
664 | * Reset our results. | 675 | * Reset our results. |
@@ -707,7 +718,7 @@ void tcp_update_metrics(struct sock *sk) | |||
707 | tp->snd_cwnd > dst_metric(dst, RTAX_CWND)) | 718 | tp->snd_cwnd > dst_metric(dst, RTAX_CWND)) |
708 | dst->metrics[RTAX_CWND-1] = tp->snd_cwnd; | 719 | dst->metrics[RTAX_CWND-1] = tp->snd_cwnd; |
709 | } else if (tp->snd_cwnd > tp->snd_ssthresh && | 720 | } else if (tp->snd_cwnd > tp->snd_ssthresh && |
710 | tp->ca_state == TCP_CA_Open) { | 721 | icsk->icsk_ca_state == TCP_CA_Open) { |
711 | /* Cong. avoidance phase, cwnd is reliable. */ | 722 | /* Cong. avoidance phase, cwnd is reliable. */ |
712 | if (!dst_metric_locked(dst, RTAX_SSTHRESH)) | 723 | if (!dst_metric_locked(dst, RTAX_SSTHRESH)) |
713 | dst->metrics[RTAX_SSTHRESH-1] = | 724 | dst->metrics[RTAX_SSTHRESH-1] = |
@@ -801,9 +812,9 @@ static void tcp_init_metrics(struct sock *sk) | |||
801 | tp->mdev = dst_metric(dst, RTAX_RTTVAR); | 812 | tp->mdev = dst_metric(dst, RTAX_RTTVAR); |
802 | tp->mdev_max = tp->rttvar = max(tp->mdev, TCP_RTO_MIN); | 813 | tp->mdev_max = tp->rttvar = max(tp->mdev, TCP_RTO_MIN); |
803 | } | 814 | } |
804 | tcp_set_rto(tp); | 815 | tcp_set_rto(sk); |
805 | tcp_bound_rto(tp); | 816 | tcp_bound_rto(sk); |
806 | if (tp->rto < TCP_TIMEOUT_INIT && !tp->rx_opt.saw_tstamp) | 817 | if (inet_csk(sk)->icsk_rto < TCP_TIMEOUT_INIT && !tp->rx_opt.saw_tstamp) |
807 | goto reset; | 818 | goto reset; |
808 | tp->snd_cwnd = tcp_init_cwnd(tp, dst); | 819 | tp->snd_cwnd = tcp_init_cwnd(tp, dst); |
809 | tp->snd_cwnd_stamp = tcp_time_stamp; | 820 | tp->snd_cwnd_stamp = tcp_time_stamp; |
@@ -817,12 +828,14 @@ reset: | |||
817 | if (!tp->rx_opt.saw_tstamp && tp->srtt) { | 828 | if (!tp->rx_opt.saw_tstamp && tp->srtt) { |
818 | tp->srtt = 0; | 829 | tp->srtt = 0; |
819 | tp->mdev = tp->mdev_max = tp->rttvar = TCP_TIMEOUT_INIT; | 830 | tp->mdev = tp->mdev_max = tp->rttvar = TCP_TIMEOUT_INIT; |
820 | tp->rto = TCP_TIMEOUT_INIT; | 831 | inet_csk(sk)->icsk_rto = TCP_TIMEOUT_INIT; |
821 | } | 832 | } |
822 | } | 833 | } |
823 | 834 | ||
824 | static void tcp_update_reordering(struct tcp_sock *tp, int metric, int ts) | 835 | static void tcp_update_reordering(struct sock *sk, const int metric, |
836 | const int ts) | ||
825 | { | 837 | { |
838 | struct tcp_sock *tp = tcp_sk(sk); | ||
826 | if (metric > tp->reordering) { | 839 | if (metric > tp->reordering) { |
827 | tp->reordering = min(TCP_MAX_REORDERING, metric); | 840 | tp->reordering = min(TCP_MAX_REORDERING, metric); |
828 | 841 | ||
@@ -837,7 +850,7 @@ static void tcp_update_reordering(struct tcp_sock *tp, int metric, int ts) | |||
837 | NET_INC_STATS_BH(LINUX_MIB_TCPSACKREORDER); | 850 | NET_INC_STATS_BH(LINUX_MIB_TCPSACKREORDER); |
838 | #if FASTRETRANS_DEBUG > 1 | 851 | #if FASTRETRANS_DEBUG > 1 |
839 | printk(KERN_DEBUG "Disorder%d %d %u f%u s%u rr%d\n", | 852 | printk(KERN_DEBUG "Disorder%d %d %u f%u s%u rr%d\n", |
840 | tp->rx_opt.sack_ok, tp->ca_state, | 853 | tp->rx_opt.sack_ok, inet_csk(sk)->icsk_ca_state, |
841 | tp->reordering, | 854 | tp->reordering, |
842 | tp->fackets_out, | 855 | tp->fackets_out, |
843 | tp->sacked_out, | 856 | tp->sacked_out, |
@@ -899,6 +912,7 @@ static void tcp_update_reordering(struct tcp_sock *tp, int metric, int ts) | |||
899 | static int | 912 | static int |
900 | tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_una) | 913 | tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_una) |
901 | { | 914 | { |
915 | const struct inet_connection_sock *icsk = inet_csk(sk); | ||
902 | struct tcp_sock *tp = tcp_sk(sk); | 916 | struct tcp_sock *tp = tcp_sk(sk); |
903 | unsigned char *ptr = ack_skb->h.raw + TCP_SKB_CB(ack_skb)->sacked; | 917 | unsigned char *ptr = ack_skb->h.raw + TCP_SKB_CB(ack_skb)->sacked; |
904 | struct tcp_sack_block *sp = (struct tcp_sack_block *)(ptr+2); | 918 | struct tcp_sack_block *sp = (struct tcp_sack_block *)(ptr+2); |
@@ -909,14 +923,6 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
909 | int flag = 0; | 923 | int flag = 0; |
910 | int i; | 924 | int i; |
911 | 925 | ||
912 | /* So, SACKs for already sent large segments will be lost. | ||
913 | * Not good, but alternative is to resegment the queue. */ | ||
914 | if (sk->sk_route_caps & NETIF_F_TSO) { | ||
915 | sk->sk_route_caps &= ~NETIF_F_TSO; | ||
916 | sock_set_flag(sk, SOCK_NO_LARGESEND); | ||
917 | tp->mss_cache = tp->mss_cache; | ||
918 | } | ||
919 | |||
920 | if (!tp->sacked_out) | 926 | if (!tp->sacked_out) |
921 | tp->fackets_out = 0; | 927 | tp->fackets_out = 0; |
922 | prior_fackets = tp->fackets_out; | 928 | prior_fackets = tp->fackets_out; |
@@ -964,20 +970,40 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
964 | flag |= FLAG_DATA_LOST; | 970 | flag |= FLAG_DATA_LOST; |
965 | 971 | ||
966 | sk_stream_for_retrans_queue(skb, sk) { | 972 | sk_stream_for_retrans_queue(skb, sk) { |
967 | u8 sacked = TCP_SKB_CB(skb)->sacked; | 973 | int in_sack, pcount; |
968 | int in_sack; | 974 | u8 sacked; |
969 | 975 | ||
970 | /* The retransmission queue is always in order, so | 976 | /* The retransmission queue is always in order, so |
971 | * we can short-circuit the walk early. | 977 | * we can short-circuit the walk early. |
972 | */ | 978 | */ |
973 | if(!before(TCP_SKB_CB(skb)->seq, end_seq)) | 979 | if (!before(TCP_SKB_CB(skb)->seq, end_seq)) |
974 | break; | 980 | break; |
975 | 981 | ||
976 | fack_count += tcp_skb_pcount(skb); | 982 | pcount = tcp_skb_pcount(skb); |
983 | |||
984 | if (pcount > 1 && | ||
985 | (after(start_seq, TCP_SKB_CB(skb)->seq) || | ||
986 | before(end_seq, TCP_SKB_CB(skb)->end_seq))) { | ||
987 | unsigned int pkt_len; | ||
988 | |||
989 | if (after(start_seq, TCP_SKB_CB(skb)->seq)) | ||
990 | pkt_len = (start_seq - | ||
991 | TCP_SKB_CB(skb)->seq); | ||
992 | else | ||
993 | pkt_len = (end_seq - | ||
994 | TCP_SKB_CB(skb)->seq); | ||
995 | if (tcp_fragment(sk, skb, pkt_len, skb_shinfo(skb)->tso_size)) | ||
996 | break; | ||
997 | pcount = tcp_skb_pcount(skb); | ||
998 | } | ||
999 | |||
1000 | fack_count += pcount; | ||
977 | 1001 | ||
978 | in_sack = !after(start_seq, TCP_SKB_CB(skb)->seq) && | 1002 | in_sack = !after(start_seq, TCP_SKB_CB(skb)->seq) && |
979 | !before(end_seq, TCP_SKB_CB(skb)->end_seq); | 1003 | !before(end_seq, TCP_SKB_CB(skb)->end_seq); |
980 | 1004 | ||
1005 | sacked = TCP_SKB_CB(skb)->sacked; | ||
1006 | |||
981 | /* Account D-SACK for retransmitted packet. */ | 1007 | /* Account D-SACK for retransmitted packet. */ |
982 | if ((dup_sack && in_sack) && | 1008 | if ((dup_sack && in_sack) && |
983 | (sacked & TCPCB_RETRANS) && | 1009 | (sacked & TCPCB_RETRANS) && |
@@ -1064,7 +1090,7 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1064 | * we have to account for reordering! Ugly, | 1090 | * we have to account for reordering! Ugly, |
1065 | * but should help. | 1091 | * but should help. |
1066 | */ | 1092 | */ |
1067 | if (lost_retrans && tp->ca_state == TCP_CA_Recovery) { | 1093 | if (lost_retrans && icsk->icsk_ca_state == TCP_CA_Recovery) { |
1068 | struct sk_buff *skb; | 1094 | struct sk_buff *skb; |
1069 | 1095 | ||
1070 | sk_stream_for_retrans_queue(skb, sk) { | 1096 | sk_stream_for_retrans_queue(skb, sk) { |
@@ -1093,8 +1119,8 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1093 | 1119 | ||
1094 | tp->left_out = tp->sacked_out + tp->lost_out; | 1120 | tp->left_out = tp->sacked_out + tp->lost_out; |
1095 | 1121 | ||
1096 | if ((reord < tp->fackets_out) && tp->ca_state != TCP_CA_Loss) | 1122 | if ((reord < tp->fackets_out) && icsk->icsk_ca_state != TCP_CA_Loss) |
1097 | tcp_update_reordering(tp, ((tp->fackets_out + 1) - reord), 0); | 1123 | tcp_update_reordering(sk, ((tp->fackets_out + 1) - reord), 0); |
1098 | 1124 | ||
1099 | #if FASTRETRANS_DEBUG > 0 | 1125 | #if FASTRETRANS_DEBUG > 0 |
1100 | BUG_TRAP((int)tp->sacked_out >= 0); | 1126 | BUG_TRAP((int)tp->sacked_out >= 0); |
@@ -1111,17 +1137,18 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_ | |||
1111 | */ | 1137 | */ |
1112 | void tcp_enter_frto(struct sock *sk) | 1138 | void tcp_enter_frto(struct sock *sk) |
1113 | { | 1139 | { |
1140 | const struct inet_connection_sock *icsk = inet_csk(sk); | ||
1114 | struct tcp_sock *tp = tcp_sk(sk); | 1141 | struct tcp_sock *tp = tcp_sk(sk); |
1115 | struct sk_buff *skb; | 1142 | struct sk_buff *skb; |
1116 | 1143 | ||
1117 | tp->frto_counter = 1; | 1144 | tp->frto_counter = 1; |
1118 | 1145 | ||
1119 | if (tp->ca_state <= TCP_CA_Disorder || | 1146 | if (icsk->icsk_ca_state <= TCP_CA_Disorder || |
1120 | tp->snd_una == tp->high_seq || | 1147 | tp->snd_una == tp->high_seq || |
1121 | (tp->ca_state == TCP_CA_Loss && !tp->retransmits)) { | 1148 | (icsk->icsk_ca_state == TCP_CA_Loss && !icsk->icsk_retransmits)) { |
1122 | tp->prior_ssthresh = tcp_current_ssthresh(tp); | 1149 | tp->prior_ssthresh = tcp_current_ssthresh(sk); |
1123 | tp->snd_ssthresh = tp->ca_ops->ssthresh(tp); | 1150 | tp->snd_ssthresh = icsk->icsk_ca_ops->ssthresh(sk); |
1124 | tcp_ca_event(tp, CA_EVENT_FRTO); | 1151 | tcp_ca_event(sk, CA_EVENT_FRTO); |
1125 | } | 1152 | } |
1126 | 1153 | ||
1127 | /* Have to clear retransmission markers here to keep the bookkeeping | 1154 | /* Have to clear retransmission markers here to keep the bookkeeping |
@@ -1138,7 +1165,7 @@ void tcp_enter_frto(struct sock *sk) | |||
1138 | } | 1165 | } |
1139 | tcp_sync_left_out(tp); | 1166 | tcp_sync_left_out(tp); |
1140 | 1167 | ||
1141 | tcp_set_ca_state(tp, TCP_CA_Open); | 1168 | tcp_set_ca_state(sk, TCP_CA_Open); |
1142 | tp->frto_highmark = tp->snd_nxt; | 1169 | tp->frto_highmark = tp->snd_nxt; |
1143 | } | 1170 | } |
1144 | 1171 | ||
@@ -1184,7 +1211,7 @@ static void tcp_enter_frto_loss(struct sock *sk) | |||
1184 | 1211 | ||
1185 | tp->reordering = min_t(unsigned int, tp->reordering, | 1212 | tp->reordering = min_t(unsigned int, tp->reordering, |
1186 | sysctl_tcp_reordering); | 1213 | sysctl_tcp_reordering); |
1187 | tcp_set_ca_state(tp, TCP_CA_Loss); | 1214 | tcp_set_ca_state(sk, TCP_CA_Loss); |
1188 | tp->high_seq = tp->frto_highmark; | 1215 | tp->high_seq = tp->frto_highmark; |
1189 | TCP_ECN_queue_cwr(tp); | 1216 | TCP_ECN_queue_cwr(tp); |
1190 | } | 1217 | } |
@@ -1208,16 +1235,17 @@ void tcp_clear_retrans(struct tcp_sock *tp) | |||
1208 | */ | 1235 | */ |
1209 | void tcp_enter_loss(struct sock *sk, int how) | 1236 | void tcp_enter_loss(struct sock *sk, int how) |
1210 | { | 1237 | { |
1238 | const struct inet_connection_sock *icsk = inet_csk(sk); | ||
1211 | struct tcp_sock *tp = tcp_sk(sk); | 1239 | struct tcp_sock *tp = tcp_sk(sk); |
1212 | struct sk_buff *skb; | 1240 | struct sk_buff *skb; |
1213 | int cnt = 0; | 1241 | int cnt = 0; |
1214 | 1242 | ||
1215 | /* Reduce ssthresh if it has not yet been made inside this window. */ | 1243 | /* Reduce ssthresh if it has not yet been made inside this window. */ |
1216 | if (tp->ca_state <= TCP_CA_Disorder || tp->snd_una == tp->high_seq || | 1244 | if (icsk->icsk_ca_state <= TCP_CA_Disorder || tp->snd_una == tp->high_seq || |
1217 | (tp->ca_state == TCP_CA_Loss && !tp->retransmits)) { | 1245 | (icsk->icsk_ca_state == TCP_CA_Loss && !icsk->icsk_retransmits)) { |
1218 | tp->prior_ssthresh = tcp_current_ssthresh(tp); | 1246 | tp->prior_ssthresh = tcp_current_ssthresh(sk); |
1219 | tp->snd_ssthresh = tp->ca_ops->ssthresh(tp); | 1247 | tp->snd_ssthresh = icsk->icsk_ca_ops->ssthresh(sk); |
1220 | tcp_ca_event(tp, CA_EVENT_LOSS); | 1248 | tcp_ca_event(sk, CA_EVENT_LOSS); |
1221 | } | 1249 | } |
1222 | tp->snd_cwnd = 1; | 1250 | tp->snd_cwnd = 1; |
1223 | tp->snd_cwnd_cnt = 0; | 1251 | tp->snd_cwnd_cnt = 0; |
@@ -1248,12 +1276,12 @@ void tcp_enter_loss(struct sock *sk, int how) | |||
1248 | 1276 | ||
1249 | tp->reordering = min_t(unsigned int, tp->reordering, | 1277 | tp->reordering = min_t(unsigned int, tp->reordering, |
1250 | sysctl_tcp_reordering); | 1278 | sysctl_tcp_reordering); |
1251 | tcp_set_ca_state(tp, TCP_CA_Loss); | 1279 | tcp_set_ca_state(sk, TCP_CA_Loss); |
1252 | tp->high_seq = tp->snd_nxt; | 1280 | tp->high_seq = tp->snd_nxt; |
1253 | TCP_ECN_queue_cwr(tp); | 1281 | TCP_ECN_queue_cwr(tp); |
1254 | } | 1282 | } |
1255 | 1283 | ||
1256 | static int tcp_check_sack_reneging(struct sock *sk, struct tcp_sock *tp) | 1284 | static int tcp_check_sack_reneging(struct sock *sk) |
1257 | { | 1285 | { |
1258 | struct sk_buff *skb; | 1286 | struct sk_buff *skb; |
1259 | 1287 | ||
@@ -1265,12 +1293,14 @@ static int tcp_check_sack_reneging(struct sock *sk, struct tcp_sock *tp) | |||
1265 | */ | 1293 | */ |
1266 | if ((skb = skb_peek(&sk->sk_write_queue)) != NULL && | 1294 | if ((skb = skb_peek(&sk->sk_write_queue)) != NULL && |
1267 | (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)) { | 1295 | (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)) { |
1296 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
1268 | NET_INC_STATS_BH(LINUX_MIB_TCPSACKRENEGING); | 1297 | NET_INC_STATS_BH(LINUX_MIB_TCPSACKRENEGING); |
1269 | 1298 | ||
1270 | tcp_enter_loss(sk, 1); | 1299 | tcp_enter_loss(sk, 1); |
1271 | tp->retransmits++; | 1300 | icsk->icsk_retransmits++; |
1272 | tcp_retransmit_skb(sk, skb_peek(&sk->sk_write_queue)); | 1301 | tcp_retransmit_skb(sk, skb_peek(&sk->sk_write_queue)); |
1273 | tcp_reset_xmit_timer(sk, TCP_TIME_RETRANS, tp->rto); | 1302 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, |
1303 | icsk->icsk_rto, TCP_RTO_MAX); | ||
1274 | return 1; | 1304 | return 1; |
1275 | } | 1305 | } |
1276 | return 0; | 1306 | return 0; |
@@ -1281,15 +1311,15 @@ static inline int tcp_fackets_out(struct tcp_sock *tp) | |||
1281 | return IsReno(tp) ? tp->sacked_out+1 : tp->fackets_out; | 1311 | return IsReno(tp) ? tp->sacked_out+1 : tp->fackets_out; |
1282 | } | 1312 | } |
1283 | 1313 | ||
1284 | static inline int tcp_skb_timedout(struct tcp_sock *tp, struct sk_buff *skb) | 1314 | static inline int tcp_skb_timedout(struct sock *sk, struct sk_buff *skb) |
1285 | { | 1315 | { |
1286 | return (tcp_time_stamp - TCP_SKB_CB(skb)->when > tp->rto); | 1316 | return (tcp_time_stamp - TCP_SKB_CB(skb)->when > inet_csk(sk)->icsk_rto); |
1287 | } | 1317 | } |
1288 | 1318 | ||
1289 | static inline int tcp_head_timedout(struct sock *sk, struct tcp_sock *tp) | 1319 | static inline int tcp_head_timedout(struct sock *sk, struct tcp_sock *tp) |
1290 | { | 1320 | { |
1291 | return tp->packets_out && | 1321 | return tp->packets_out && |
1292 | tcp_skb_timedout(tp, skb_peek(&sk->sk_write_queue)); | 1322 | tcp_skb_timedout(sk, skb_peek(&sk->sk_write_queue)); |
1293 | } | 1323 | } |
1294 | 1324 | ||
1295 | /* Linux NewReno/SACK/FACK/ECN state machine. | 1325 | /* Linux NewReno/SACK/FACK/ECN state machine. |
@@ -1423,8 +1453,9 @@ static int tcp_time_to_recover(struct sock *sk, struct tcp_sock *tp) | |||
1423 | * in assumption of absent reordering, interpret this as reordering. | 1453 | * in assumption of absent reordering, interpret this as reordering. |
1424 | * The only another reason could be bug in receiver TCP. | 1454 | * The only another reason could be bug in receiver TCP. |
1425 | */ | 1455 | */ |
1426 | static void tcp_check_reno_reordering(struct tcp_sock *tp, int addend) | 1456 | static void tcp_check_reno_reordering(struct sock *sk, const int addend) |
1427 | { | 1457 | { |
1458 | struct tcp_sock *tp = tcp_sk(sk); | ||
1428 | u32 holes; | 1459 | u32 holes; |
1429 | 1460 | ||
1430 | holes = max(tp->lost_out, 1U); | 1461 | holes = max(tp->lost_out, 1U); |
@@ -1432,16 +1463,17 @@ static void tcp_check_reno_reordering(struct tcp_sock *tp, int addend) | |||
1432 | 1463 | ||
1433 | if ((tp->sacked_out + holes) > tp->packets_out) { | 1464 | if ((tp->sacked_out + holes) > tp->packets_out) { |
1434 | tp->sacked_out = tp->packets_out - holes; | 1465 | tp->sacked_out = tp->packets_out - holes; |
1435 | tcp_update_reordering(tp, tp->packets_out+addend, 0); | 1466 | tcp_update_reordering(sk, tp->packets_out + addend, 0); |
1436 | } | 1467 | } |
1437 | } | 1468 | } |
1438 | 1469 | ||
1439 | /* Emulate SACKs for SACKless connection: account for a new dupack. */ | 1470 | /* Emulate SACKs for SACKless connection: account for a new dupack. */ |
1440 | 1471 | ||
1441 | static void tcp_add_reno_sack(struct tcp_sock *tp) | 1472 | static void tcp_add_reno_sack(struct sock *sk) |
1442 | { | 1473 | { |
1474 | struct tcp_sock *tp = tcp_sk(sk); | ||
1443 | tp->sacked_out++; | 1475 | tp->sacked_out++; |
1444 | tcp_check_reno_reordering(tp, 0); | 1476 | tcp_check_reno_reordering(sk, 0); |
1445 | tcp_sync_left_out(tp); | 1477 | tcp_sync_left_out(tp); |
1446 | } | 1478 | } |
1447 | 1479 | ||
@@ -1456,7 +1488,7 @@ static void tcp_remove_reno_sacks(struct sock *sk, struct tcp_sock *tp, int acke | |||
1456 | else | 1488 | else |
1457 | tp->sacked_out -= acked-1; | 1489 | tp->sacked_out -= acked-1; |
1458 | } | 1490 | } |
1459 | tcp_check_reno_reordering(tp, acked); | 1491 | tcp_check_reno_reordering(sk, acked); |
1460 | tcp_sync_left_out(tp); | 1492 | tcp_sync_left_out(tp); |
1461 | } | 1493 | } |
1462 | 1494 | ||
@@ -1509,7 +1541,7 @@ static void tcp_update_scoreboard(struct sock *sk, struct tcp_sock *tp) | |||
1509 | struct sk_buff *skb; | 1541 | struct sk_buff *skb; |
1510 | 1542 | ||
1511 | sk_stream_for_retrans_queue(skb, sk) { | 1543 | sk_stream_for_retrans_queue(skb, sk) { |
1512 | if (tcp_skb_timedout(tp, skb) && | 1544 | if (tcp_skb_timedout(sk, skb) && |
1513 | !(TCP_SKB_CB(skb)->sacked&TCPCB_TAGBITS)) { | 1545 | !(TCP_SKB_CB(skb)->sacked&TCPCB_TAGBITS)) { |
1514 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; | 1546 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; |
1515 | tp->lost_out += tcp_skb_pcount(skb); | 1547 | tp->lost_out += tcp_skb_pcount(skb); |
@@ -1530,14 +1562,16 @@ static inline void tcp_moderate_cwnd(struct tcp_sock *tp) | |||
1530 | } | 1562 | } |
1531 | 1563 | ||
1532 | /* Decrease cwnd each second ack. */ | 1564 | /* Decrease cwnd each second ack. */ |
1533 | static void tcp_cwnd_down(struct tcp_sock *tp) | 1565 | static void tcp_cwnd_down(struct sock *sk) |
1534 | { | 1566 | { |
1567 | const struct inet_connection_sock *icsk = inet_csk(sk); | ||
1568 | struct tcp_sock *tp = tcp_sk(sk); | ||
1535 | int decr = tp->snd_cwnd_cnt + 1; | 1569 | int decr = tp->snd_cwnd_cnt + 1; |
1536 | 1570 | ||
1537 | tp->snd_cwnd_cnt = decr&1; | 1571 | tp->snd_cwnd_cnt = decr&1; |
1538 | decr >>= 1; | 1572 | decr >>= 1; |
1539 | 1573 | ||
1540 | if (decr && tp->snd_cwnd > tp->ca_ops->min_cwnd(tp)) | 1574 | if (decr && tp->snd_cwnd > icsk->icsk_ca_ops->min_cwnd(sk)) |
1541 | tp->snd_cwnd -= decr; | 1575 | tp->snd_cwnd -= decr; |
1542 | 1576 | ||
1543 | tp->snd_cwnd = min(tp->snd_cwnd, tcp_packets_in_flight(tp)+1); | 1577 | tp->snd_cwnd = min(tp->snd_cwnd, tcp_packets_in_flight(tp)+1); |
@@ -1571,11 +1605,15 @@ static void DBGUNDO(struct sock *sk, struct tcp_sock *tp, const char *msg) | |||
1571 | #define DBGUNDO(x...) do { } while (0) | 1605 | #define DBGUNDO(x...) do { } while (0) |
1572 | #endif | 1606 | #endif |
1573 | 1607 | ||
1574 | static void tcp_undo_cwr(struct tcp_sock *tp, int undo) | 1608 | static void tcp_undo_cwr(struct sock *sk, const int undo) |
1575 | { | 1609 | { |
1610 | struct tcp_sock *tp = tcp_sk(sk); | ||
1611 | |||
1576 | if (tp->prior_ssthresh) { | 1612 | if (tp->prior_ssthresh) { |
1577 | if (tp->ca_ops->undo_cwnd) | 1613 | const struct inet_connection_sock *icsk = inet_csk(sk); |
1578 | tp->snd_cwnd = tp->ca_ops->undo_cwnd(tp); | 1614 | |
1615 | if (icsk->icsk_ca_ops->undo_cwnd) | ||
1616 | tp->snd_cwnd = icsk->icsk_ca_ops->undo_cwnd(sk); | ||
1579 | else | 1617 | else |
1580 | tp->snd_cwnd = max(tp->snd_cwnd, tp->snd_ssthresh<<1); | 1618 | tp->snd_cwnd = max(tp->snd_cwnd, tp->snd_ssthresh<<1); |
1581 | 1619 | ||
@@ -1603,9 +1641,9 @@ static int tcp_try_undo_recovery(struct sock *sk, struct tcp_sock *tp) | |||
1603 | /* Happy end! We did not retransmit anything | 1641 | /* Happy end! We did not retransmit anything |
1604 | * or our original transmission succeeded. | 1642 | * or our original transmission succeeded. |
1605 | */ | 1643 | */ |
1606 | DBGUNDO(sk, tp, tp->ca_state == TCP_CA_Loss ? "loss" : "retrans"); | 1644 | DBGUNDO(sk, tp, inet_csk(sk)->icsk_ca_state == TCP_CA_Loss ? "loss" : "retrans"); |
1607 | tcp_undo_cwr(tp, 1); | 1645 | tcp_undo_cwr(sk, 1); |
1608 | if (tp->ca_state == TCP_CA_Loss) | 1646 | if (inet_csk(sk)->icsk_ca_state == TCP_CA_Loss) |
1609 | NET_INC_STATS_BH(LINUX_MIB_TCPLOSSUNDO); | 1647 | NET_INC_STATS_BH(LINUX_MIB_TCPLOSSUNDO); |
1610 | else | 1648 | else |
1611 | NET_INC_STATS_BH(LINUX_MIB_TCPFULLUNDO); | 1649 | NET_INC_STATS_BH(LINUX_MIB_TCPFULLUNDO); |
@@ -1618,7 +1656,7 @@ static int tcp_try_undo_recovery(struct sock *sk, struct tcp_sock *tp) | |||
1618 | tcp_moderate_cwnd(tp); | 1656 | tcp_moderate_cwnd(tp); |
1619 | return 1; | 1657 | return 1; |
1620 | } | 1658 | } |
1621 | tcp_set_ca_state(tp, TCP_CA_Open); | 1659 | tcp_set_ca_state(sk, TCP_CA_Open); |
1622 | return 0; | 1660 | return 0; |
1623 | } | 1661 | } |
1624 | 1662 | ||
@@ -1627,7 +1665,7 @@ static void tcp_try_undo_dsack(struct sock *sk, struct tcp_sock *tp) | |||
1627 | { | 1665 | { |
1628 | if (tp->undo_marker && !tp->undo_retrans) { | 1666 | if (tp->undo_marker && !tp->undo_retrans) { |
1629 | DBGUNDO(sk, tp, "D-SACK"); | 1667 | DBGUNDO(sk, tp, "D-SACK"); |
1630 | tcp_undo_cwr(tp, 1); | 1668 | tcp_undo_cwr(sk, 1); |
1631 | tp->undo_marker = 0; | 1669 | tp->undo_marker = 0; |
1632 | NET_INC_STATS_BH(LINUX_MIB_TCPDSACKUNDO); | 1670 | NET_INC_STATS_BH(LINUX_MIB_TCPDSACKUNDO); |
1633 | } | 1671 | } |
@@ -1648,10 +1686,10 @@ static int tcp_try_undo_partial(struct sock *sk, struct tcp_sock *tp, | |||
1648 | if (tp->retrans_out == 0) | 1686 | if (tp->retrans_out == 0) |
1649 | tp->retrans_stamp = 0; | 1687 | tp->retrans_stamp = 0; |
1650 | 1688 | ||
1651 | tcp_update_reordering(tp, tcp_fackets_out(tp)+acked, 1); | 1689 | tcp_update_reordering(sk, tcp_fackets_out(tp) + acked, 1); |
1652 | 1690 | ||
1653 | DBGUNDO(sk, tp, "Hoe"); | 1691 | DBGUNDO(sk, tp, "Hoe"); |
1654 | tcp_undo_cwr(tp, 0); | 1692 | tcp_undo_cwr(sk, 0); |
1655 | NET_INC_STATS_BH(LINUX_MIB_TCPPARTIALUNDO); | 1693 | NET_INC_STATS_BH(LINUX_MIB_TCPPARTIALUNDO); |
1656 | 1694 | ||
1657 | /* So... Do not make Hoe's retransmit yet. | 1695 | /* So... Do not make Hoe's retransmit yet. |
@@ -1674,22 +1712,23 @@ static int tcp_try_undo_loss(struct sock *sk, struct tcp_sock *tp) | |||
1674 | DBGUNDO(sk, tp, "partial loss"); | 1712 | DBGUNDO(sk, tp, "partial loss"); |
1675 | tp->lost_out = 0; | 1713 | tp->lost_out = 0; |
1676 | tp->left_out = tp->sacked_out; | 1714 | tp->left_out = tp->sacked_out; |
1677 | tcp_undo_cwr(tp, 1); | 1715 | tcp_undo_cwr(sk, 1); |
1678 | NET_INC_STATS_BH(LINUX_MIB_TCPLOSSUNDO); | 1716 | NET_INC_STATS_BH(LINUX_MIB_TCPLOSSUNDO); |
1679 | tp->retransmits = 0; | 1717 | inet_csk(sk)->icsk_retransmits = 0; |
1680 | tp->undo_marker = 0; | 1718 | tp->undo_marker = 0; |
1681 | if (!IsReno(tp)) | 1719 | if (!IsReno(tp)) |
1682 | tcp_set_ca_state(tp, TCP_CA_Open); | 1720 | tcp_set_ca_state(sk, TCP_CA_Open); |
1683 | return 1; | 1721 | return 1; |
1684 | } | 1722 | } |
1685 | return 0; | 1723 | return 0; |
1686 | } | 1724 | } |
1687 | 1725 | ||
1688 | static inline void tcp_complete_cwr(struct tcp_sock *tp) | 1726 | static inline void tcp_complete_cwr(struct sock *sk) |
1689 | { | 1727 | { |
1728 | struct tcp_sock *tp = tcp_sk(sk); | ||
1690 | tp->snd_cwnd = min(tp->snd_cwnd, tp->snd_ssthresh); | 1729 | tp->snd_cwnd = min(tp->snd_cwnd, tp->snd_ssthresh); |
1691 | tp->snd_cwnd_stamp = tcp_time_stamp; | 1730 | tp->snd_cwnd_stamp = tcp_time_stamp; |
1692 | tcp_ca_event(tp, CA_EVENT_COMPLETE_CWR); | 1731 | tcp_ca_event(sk, CA_EVENT_COMPLETE_CWR); |
1693 | } | 1732 | } |
1694 | 1733 | ||
1695 | static void tcp_try_to_open(struct sock *sk, struct tcp_sock *tp, int flag) | 1734 | static void tcp_try_to_open(struct sock *sk, struct tcp_sock *tp, int flag) |
@@ -1700,21 +1739,21 @@ static void tcp_try_to_open(struct sock *sk, struct tcp_sock *tp, int flag) | |||
1700 | tp->retrans_stamp = 0; | 1739 | tp->retrans_stamp = 0; |
1701 | 1740 | ||
1702 | if (flag&FLAG_ECE) | 1741 | if (flag&FLAG_ECE) |
1703 | tcp_enter_cwr(tp); | 1742 | tcp_enter_cwr(sk); |
1704 | 1743 | ||
1705 | if (tp->ca_state != TCP_CA_CWR) { | 1744 | if (inet_csk(sk)->icsk_ca_state != TCP_CA_CWR) { |
1706 | int state = TCP_CA_Open; | 1745 | int state = TCP_CA_Open; |
1707 | 1746 | ||
1708 | if (tp->left_out || tp->retrans_out || tp->undo_marker) | 1747 | if (tp->left_out || tp->retrans_out || tp->undo_marker) |
1709 | state = TCP_CA_Disorder; | 1748 | state = TCP_CA_Disorder; |
1710 | 1749 | ||
1711 | if (tp->ca_state != state) { | 1750 | if (inet_csk(sk)->icsk_ca_state != state) { |
1712 | tcp_set_ca_state(tp, state); | 1751 | tcp_set_ca_state(sk, state); |
1713 | tp->high_seq = tp->snd_nxt; | 1752 | tp->high_seq = tp->snd_nxt; |
1714 | } | 1753 | } |
1715 | tcp_moderate_cwnd(tp); | 1754 | tcp_moderate_cwnd(tp); |
1716 | } else { | 1755 | } else { |
1717 | tcp_cwnd_down(tp); | 1756 | tcp_cwnd_down(sk); |
1718 | } | 1757 | } |
1719 | } | 1758 | } |
1720 | 1759 | ||
@@ -1733,6 +1772,7 @@ static void | |||
1733 | tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una, | 1772 | tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una, |
1734 | int prior_packets, int flag) | 1773 | int prior_packets, int flag) |
1735 | { | 1774 | { |
1775 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
1736 | struct tcp_sock *tp = tcp_sk(sk); | 1776 | struct tcp_sock *tp = tcp_sk(sk); |
1737 | int is_dupack = (tp->snd_una == prior_snd_una && !(flag&FLAG_NOT_DUP)); | 1777 | int is_dupack = (tp->snd_una == prior_snd_una && !(flag&FLAG_NOT_DUP)); |
1738 | 1778 | ||
@@ -1750,13 +1790,13 @@ tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una, | |||
1750 | tp->prior_ssthresh = 0; | 1790 | tp->prior_ssthresh = 0; |
1751 | 1791 | ||
1752 | /* B. In all the states check for reneging SACKs. */ | 1792 | /* B. In all the states check for reneging SACKs. */ |
1753 | if (tp->sacked_out && tcp_check_sack_reneging(sk, tp)) | 1793 | if (tp->sacked_out && tcp_check_sack_reneging(sk)) |
1754 | return; | 1794 | return; |
1755 | 1795 | ||
1756 | /* C. Process data loss notification, provided it is valid. */ | 1796 | /* C. Process data loss notification, provided it is valid. */ |
1757 | if ((flag&FLAG_DATA_LOST) && | 1797 | if ((flag&FLAG_DATA_LOST) && |
1758 | before(tp->snd_una, tp->high_seq) && | 1798 | before(tp->snd_una, tp->high_seq) && |
1759 | tp->ca_state != TCP_CA_Open && | 1799 | icsk->icsk_ca_state != TCP_CA_Open && |
1760 | tp->fackets_out > tp->reordering) { | 1800 | tp->fackets_out > tp->reordering) { |
1761 | tcp_mark_head_lost(sk, tp, tp->fackets_out-tp->reordering, tp->high_seq); | 1801 | tcp_mark_head_lost(sk, tp, tp->fackets_out-tp->reordering, tp->high_seq); |
1762 | NET_INC_STATS_BH(LINUX_MIB_TCPLOSS); | 1802 | NET_INC_STATS_BH(LINUX_MIB_TCPLOSS); |
@@ -1767,14 +1807,14 @@ tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una, | |||
1767 | 1807 | ||
1768 | /* E. Check state exit conditions. State can be terminated | 1808 | /* E. Check state exit conditions. State can be terminated |
1769 | * when high_seq is ACKed. */ | 1809 | * when high_seq is ACKed. */ |
1770 | if (tp->ca_state == TCP_CA_Open) { | 1810 | if (icsk->icsk_ca_state == TCP_CA_Open) { |
1771 | if (!sysctl_tcp_frto) | 1811 | if (!sysctl_tcp_frto) |
1772 | BUG_TRAP(tp->retrans_out == 0); | 1812 | BUG_TRAP(tp->retrans_out == 0); |
1773 | tp->retrans_stamp = 0; | 1813 | tp->retrans_stamp = 0; |
1774 | } else if (!before(tp->snd_una, tp->high_seq)) { | 1814 | } else if (!before(tp->snd_una, tp->high_seq)) { |
1775 | switch (tp->ca_state) { | 1815 | switch (icsk->icsk_ca_state) { |
1776 | case TCP_CA_Loss: | 1816 | case TCP_CA_Loss: |
1777 | tp->retransmits = 0; | 1817 | icsk->icsk_retransmits = 0; |
1778 | if (tcp_try_undo_recovery(sk, tp)) | 1818 | if (tcp_try_undo_recovery(sk, tp)) |
1779 | return; | 1819 | return; |
1780 | break; | 1820 | break; |
@@ -1783,8 +1823,8 @@ tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una, | |||
1783 | /* CWR is to be held something *above* high_seq | 1823 | /* CWR is to be held something *above* high_seq |
1784 | * is ACKed for CWR bit to reach receiver. */ | 1824 | * is ACKed for CWR bit to reach receiver. */ |
1785 | if (tp->snd_una != tp->high_seq) { | 1825 | if (tp->snd_una != tp->high_seq) { |
1786 | tcp_complete_cwr(tp); | 1826 | tcp_complete_cwr(sk); |
1787 | tcp_set_ca_state(tp, TCP_CA_Open); | 1827 | tcp_set_ca_state(sk, TCP_CA_Open); |
1788 | } | 1828 | } |
1789 | break; | 1829 | break; |
1790 | 1830 | ||
@@ -1795,7 +1835,7 @@ tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una, | |||
1795 | * catching for all duplicate ACKs. */ | 1835 | * catching for all duplicate ACKs. */ |
1796 | IsReno(tp) || tp->snd_una != tp->high_seq) { | 1836 | IsReno(tp) || tp->snd_una != tp->high_seq) { |
1797 | tp->undo_marker = 0; | 1837 | tp->undo_marker = 0; |
1798 | tcp_set_ca_state(tp, TCP_CA_Open); | 1838 | tcp_set_ca_state(sk, TCP_CA_Open); |
1799 | } | 1839 | } |
1800 | break; | 1840 | break; |
1801 | 1841 | ||
@@ -1804,17 +1844,17 @@ tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una, | |||
1804 | tcp_reset_reno_sack(tp); | 1844 | tcp_reset_reno_sack(tp); |
1805 | if (tcp_try_undo_recovery(sk, tp)) | 1845 | if (tcp_try_undo_recovery(sk, tp)) |
1806 | return; | 1846 | return; |
1807 | tcp_complete_cwr(tp); | 1847 | tcp_complete_cwr(sk); |
1808 | break; | 1848 | break; |
1809 | } | 1849 | } |
1810 | } | 1850 | } |
1811 | 1851 | ||
1812 | /* F. Process state. */ | 1852 | /* F. Process state. */ |
1813 | switch (tp->ca_state) { | 1853 | switch (icsk->icsk_ca_state) { |
1814 | case TCP_CA_Recovery: | 1854 | case TCP_CA_Recovery: |
1815 | if (prior_snd_una == tp->snd_una) { | 1855 | if (prior_snd_una == tp->snd_una) { |
1816 | if (IsReno(tp) && is_dupack) | 1856 | if (IsReno(tp) && is_dupack) |
1817 | tcp_add_reno_sack(tp); | 1857 | tcp_add_reno_sack(sk); |
1818 | } else { | 1858 | } else { |
1819 | int acked = prior_packets - tp->packets_out; | 1859 | int acked = prior_packets - tp->packets_out; |
1820 | if (IsReno(tp)) | 1860 | if (IsReno(tp)) |
@@ -1824,13 +1864,13 @@ tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una, | |||
1824 | break; | 1864 | break; |
1825 | case TCP_CA_Loss: | 1865 | case TCP_CA_Loss: |
1826 | if (flag&FLAG_DATA_ACKED) | 1866 | if (flag&FLAG_DATA_ACKED) |
1827 | tp->retransmits = 0; | 1867 | icsk->icsk_retransmits = 0; |
1828 | if (!tcp_try_undo_loss(sk, tp)) { | 1868 | if (!tcp_try_undo_loss(sk, tp)) { |
1829 | tcp_moderate_cwnd(tp); | 1869 | tcp_moderate_cwnd(tp); |
1830 | tcp_xmit_retransmit_queue(sk); | 1870 | tcp_xmit_retransmit_queue(sk); |
1831 | return; | 1871 | return; |
1832 | } | 1872 | } |
1833 | if (tp->ca_state != TCP_CA_Open) | 1873 | if (icsk->icsk_ca_state != TCP_CA_Open) |
1834 | return; | 1874 | return; |
1835 | /* Loss is undone; fall through to processing in Open state. */ | 1875 | /* Loss is undone; fall through to processing in Open state. */ |
1836 | default: | 1876 | default: |
@@ -1838,10 +1878,10 @@ tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una, | |||
1838 | if (tp->snd_una != prior_snd_una) | 1878 | if (tp->snd_una != prior_snd_una) |
1839 | tcp_reset_reno_sack(tp); | 1879 | tcp_reset_reno_sack(tp); |
1840 | if (is_dupack) | 1880 | if (is_dupack) |
1841 | tcp_add_reno_sack(tp); | 1881 | tcp_add_reno_sack(sk); |
1842 | } | 1882 | } |
1843 | 1883 | ||
1844 | if (tp->ca_state == TCP_CA_Disorder) | 1884 | if (icsk->icsk_ca_state == TCP_CA_Disorder) |
1845 | tcp_try_undo_dsack(sk, tp); | 1885 | tcp_try_undo_dsack(sk, tp); |
1846 | 1886 | ||
1847 | if (!tcp_time_to_recover(sk, tp)) { | 1887 | if (!tcp_time_to_recover(sk, tp)) { |
@@ -1861,30 +1901,28 @@ tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una, | |||
1861 | tp->undo_marker = tp->snd_una; | 1901 | tp->undo_marker = tp->snd_una; |
1862 | tp->undo_retrans = tp->retrans_out; | 1902 | tp->undo_retrans = tp->retrans_out; |
1863 | 1903 | ||
1864 | if (tp->ca_state < TCP_CA_CWR) { | 1904 | if (icsk->icsk_ca_state < TCP_CA_CWR) { |
1865 | if (!(flag&FLAG_ECE)) | 1905 | if (!(flag&FLAG_ECE)) |
1866 | tp->prior_ssthresh = tcp_current_ssthresh(tp); | 1906 | tp->prior_ssthresh = tcp_current_ssthresh(sk); |
1867 | tp->snd_ssthresh = tp->ca_ops->ssthresh(tp); | 1907 | tp->snd_ssthresh = icsk->icsk_ca_ops->ssthresh(sk); |
1868 | TCP_ECN_queue_cwr(tp); | 1908 | TCP_ECN_queue_cwr(tp); |
1869 | } | 1909 | } |
1870 | 1910 | ||
1871 | tp->snd_cwnd_cnt = 0; | 1911 | tp->snd_cwnd_cnt = 0; |
1872 | tcp_set_ca_state(tp, TCP_CA_Recovery); | 1912 | tcp_set_ca_state(sk, TCP_CA_Recovery); |
1873 | } | 1913 | } |
1874 | 1914 | ||
1875 | if (is_dupack || tcp_head_timedout(sk, tp)) | 1915 | if (is_dupack || tcp_head_timedout(sk, tp)) |
1876 | tcp_update_scoreboard(sk, tp); | 1916 | tcp_update_scoreboard(sk, tp); |
1877 | tcp_cwnd_down(tp); | 1917 | tcp_cwnd_down(sk); |
1878 | tcp_xmit_retransmit_queue(sk); | 1918 | tcp_xmit_retransmit_queue(sk); |
1879 | } | 1919 | } |
1880 | 1920 | ||
1881 | /* Read draft-ietf-tcplw-high-performance before mucking | 1921 | /* Read draft-ietf-tcplw-high-performance before mucking |
1882 | * with this code. (Superceeds RFC1323) | 1922 | * with this code. (Superceeds RFC1323) |
1883 | */ | 1923 | */ |
1884 | static void tcp_ack_saw_tstamp(struct tcp_sock *tp, u32 *usrtt, int flag) | 1924 | static void tcp_ack_saw_tstamp(struct sock *sk, u32 *usrtt, int flag) |
1885 | { | 1925 | { |
1886 | __u32 seq_rtt; | ||
1887 | |||
1888 | /* RTTM Rule: A TSecr value received in a segment is used to | 1926 | /* RTTM Rule: A TSecr value received in a segment is used to |
1889 | * update the averaged RTT measurement only if the segment | 1927 | * update the averaged RTT measurement only if the segment |
1890 | * acknowledges some new data, i.e., only if it advances the | 1928 | * acknowledges some new data, i.e., only if it advances the |
@@ -1900,14 +1938,15 @@ static void tcp_ack_saw_tstamp(struct tcp_sock *tp, u32 *usrtt, int flag) | |||
1900 | * answer arrives rto becomes 120 seconds! If at least one of segments | 1938 | * answer arrives rto becomes 120 seconds! If at least one of segments |
1901 | * in window is lost... Voila. --ANK (010210) | 1939 | * in window is lost... Voila. --ANK (010210) |
1902 | */ | 1940 | */ |
1903 | seq_rtt = tcp_time_stamp - tp->rx_opt.rcv_tsecr; | 1941 | struct tcp_sock *tp = tcp_sk(sk); |
1904 | tcp_rtt_estimator(tp, seq_rtt, usrtt); | 1942 | const __u32 seq_rtt = tcp_time_stamp - tp->rx_opt.rcv_tsecr; |
1905 | tcp_set_rto(tp); | 1943 | tcp_rtt_estimator(sk, seq_rtt, usrtt); |
1906 | tp->backoff = 0; | 1944 | tcp_set_rto(sk); |
1907 | tcp_bound_rto(tp); | 1945 | inet_csk(sk)->icsk_backoff = 0; |
1946 | tcp_bound_rto(sk); | ||
1908 | } | 1947 | } |
1909 | 1948 | ||
1910 | static void tcp_ack_no_tstamp(struct tcp_sock *tp, u32 seq_rtt, u32 *usrtt, int flag) | 1949 | static void tcp_ack_no_tstamp(struct sock *sk, u32 seq_rtt, u32 *usrtt, int flag) |
1911 | { | 1950 | { |
1912 | /* We don't have a timestamp. Can only use | 1951 | /* We don't have a timestamp. Can only use |
1913 | * packets that are not retransmitted to determine | 1952 | * packets that are not retransmitted to determine |
@@ -1921,27 +1960,29 @@ static void tcp_ack_no_tstamp(struct tcp_sock *tp, u32 seq_rtt, u32 *usrtt, int | |||
1921 | if (flag & FLAG_RETRANS_DATA_ACKED) | 1960 | if (flag & FLAG_RETRANS_DATA_ACKED) |
1922 | return; | 1961 | return; |
1923 | 1962 | ||
1924 | tcp_rtt_estimator(tp, seq_rtt, usrtt); | 1963 | tcp_rtt_estimator(sk, seq_rtt, usrtt); |
1925 | tcp_set_rto(tp); | 1964 | tcp_set_rto(sk); |
1926 | tp->backoff = 0; | 1965 | inet_csk(sk)->icsk_backoff = 0; |
1927 | tcp_bound_rto(tp); | 1966 | tcp_bound_rto(sk); |
1928 | } | 1967 | } |
1929 | 1968 | ||
1930 | static inline void tcp_ack_update_rtt(struct tcp_sock *tp, | 1969 | static inline void tcp_ack_update_rtt(struct sock *sk, const int flag, |
1931 | int flag, s32 seq_rtt, u32 *usrtt) | 1970 | const s32 seq_rtt, u32 *usrtt) |
1932 | { | 1971 | { |
1972 | const struct tcp_sock *tp = tcp_sk(sk); | ||
1933 | /* Note that peer MAY send zero echo. In this case it is ignored. (rfc1323) */ | 1973 | /* Note that peer MAY send zero echo. In this case it is ignored. (rfc1323) */ |
1934 | if (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr) | 1974 | if (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr) |
1935 | tcp_ack_saw_tstamp(tp, usrtt, flag); | 1975 | tcp_ack_saw_tstamp(sk, usrtt, flag); |
1936 | else if (seq_rtt >= 0) | 1976 | else if (seq_rtt >= 0) |
1937 | tcp_ack_no_tstamp(tp, seq_rtt, usrtt, flag); | 1977 | tcp_ack_no_tstamp(sk, seq_rtt, usrtt, flag); |
1938 | } | 1978 | } |
1939 | 1979 | ||
1940 | static inline void tcp_cong_avoid(struct tcp_sock *tp, u32 ack, u32 rtt, | 1980 | static inline void tcp_cong_avoid(struct sock *sk, u32 ack, u32 rtt, |
1941 | u32 in_flight, int good) | 1981 | u32 in_flight, int good) |
1942 | { | 1982 | { |
1943 | tp->ca_ops->cong_avoid(tp, ack, rtt, in_flight, good); | 1983 | const struct inet_connection_sock *icsk = inet_csk(sk); |
1944 | tp->snd_cwnd_stamp = tcp_time_stamp; | 1984 | icsk->icsk_ca_ops->cong_avoid(sk, ack, rtt, in_flight, good); |
1985 | tcp_sk(sk)->snd_cwnd_stamp = tcp_time_stamp; | ||
1945 | } | 1986 | } |
1946 | 1987 | ||
1947 | /* Restart timer after forward progress on connection. | 1988 | /* Restart timer after forward progress on connection. |
@@ -1951,9 +1992,9 @@ static inline void tcp_cong_avoid(struct tcp_sock *tp, u32 ack, u32 rtt, | |||
1951 | static inline void tcp_ack_packets_out(struct sock *sk, struct tcp_sock *tp) | 1992 | static inline void tcp_ack_packets_out(struct sock *sk, struct tcp_sock *tp) |
1952 | { | 1993 | { |
1953 | if (!tp->packets_out) { | 1994 | if (!tp->packets_out) { |
1954 | tcp_clear_xmit_timer(sk, TCP_TIME_RETRANS); | 1995 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); |
1955 | } else { | 1996 | } else { |
1956 | tcp_reset_xmit_timer(sk, TCP_TIME_RETRANS, tp->rto); | 1997 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, inet_csk(sk)->icsk_rto, TCP_RTO_MAX); |
1957 | } | 1998 | } |
1958 | } | 1999 | } |
1959 | 2000 | ||
@@ -2068,9 +2109,13 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p, s32 *seq_usrtt | |||
2068 | seq_rtt = -1; | 2109 | seq_rtt = -1; |
2069 | } else if (seq_rtt < 0) | 2110 | } else if (seq_rtt < 0) |
2070 | seq_rtt = now - scb->when; | 2111 | seq_rtt = now - scb->when; |
2071 | if (seq_usrtt) | 2112 | if (seq_usrtt) { |
2072 | *seq_usrtt = (usnow.tv_sec - skb->stamp.tv_sec) * 1000000 | 2113 | struct timeval tv; |
2073 | + (usnow.tv_usec - skb->stamp.tv_usec); | 2114 | |
2115 | skb_get_timestamp(skb, &tv); | ||
2116 | *seq_usrtt = (usnow.tv_sec - tv.tv_sec) * 1000000 | ||
2117 | + (usnow.tv_usec - tv.tv_usec); | ||
2118 | } | ||
2074 | 2119 | ||
2075 | if (sacked & TCPCB_SACKED_ACKED) | 2120 | if (sacked & TCPCB_SACKED_ACKED) |
2076 | tp->sacked_out -= tcp_skb_pcount(skb); | 2121 | tp->sacked_out -= tcp_skb_pcount(skb); |
@@ -2085,16 +2130,17 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p, s32 *seq_usrtt | |||
2085 | seq_rtt = now - scb->when; | 2130 | seq_rtt = now - scb->when; |
2086 | tcp_dec_pcount_approx(&tp->fackets_out, skb); | 2131 | tcp_dec_pcount_approx(&tp->fackets_out, skb); |
2087 | tcp_packets_out_dec(tp, skb); | 2132 | tcp_packets_out_dec(tp, skb); |
2088 | __skb_unlink(skb, skb->list); | 2133 | __skb_unlink(skb, &sk->sk_write_queue); |
2089 | sk_stream_free_skb(sk, skb); | 2134 | sk_stream_free_skb(sk, skb); |
2090 | } | 2135 | } |
2091 | 2136 | ||
2092 | if (acked&FLAG_ACKED) { | 2137 | if (acked&FLAG_ACKED) { |
2093 | tcp_ack_update_rtt(tp, acked, seq_rtt, seq_usrtt); | 2138 | const struct inet_connection_sock *icsk = inet_csk(sk); |
2139 | tcp_ack_update_rtt(sk, acked, seq_rtt, seq_usrtt); | ||
2094 | tcp_ack_packets_out(sk, tp); | 2140 | tcp_ack_packets_out(sk, tp); |
2095 | 2141 | ||
2096 | if (tp->ca_ops->pkts_acked) | 2142 | if (icsk->icsk_ca_ops->pkts_acked) |
2097 | tp->ca_ops->pkts_acked(tp, pkts_acked); | 2143 | icsk->icsk_ca_ops->pkts_acked(sk, pkts_acked); |
2098 | } | 2144 | } |
2099 | 2145 | ||
2100 | #if FASTRETRANS_DEBUG > 0 | 2146 | #if FASTRETRANS_DEBUG > 0 |
@@ -2102,19 +2148,20 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p, s32 *seq_usrtt | |||
2102 | BUG_TRAP((int)tp->lost_out >= 0); | 2148 | BUG_TRAP((int)tp->lost_out >= 0); |
2103 | BUG_TRAP((int)tp->retrans_out >= 0); | 2149 | BUG_TRAP((int)tp->retrans_out >= 0); |
2104 | if (!tp->packets_out && tp->rx_opt.sack_ok) { | 2150 | if (!tp->packets_out && tp->rx_opt.sack_ok) { |
2151 | const struct inet_connection_sock *icsk = inet_csk(sk); | ||
2105 | if (tp->lost_out) { | 2152 | if (tp->lost_out) { |
2106 | printk(KERN_DEBUG "Leak l=%u %d\n", | 2153 | printk(KERN_DEBUG "Leak l=%u %d\n", |
2107 | tp->lost_out, tp->ca_state); | 2154 | tp->lost_out, icsk->icsk_ca_state); |
2108 | tp->lost_out = 0; | 2155 | tp->lost_out = 0; |
2109 | } | 2156 | } |
2110 | if (tp->sacked_out) { | 2157 | if (tp->sacked_out) { |
2111 | printk(KERN_DEBUG "Leak s=%u %d\n", | 2158 | printk(KERN_DEBUG "Leak s=%u %d\n", |
2112 | tp->sacked_out, tp->ca_state); | 2159 | tp->sacked_out, icsk->icsk_ca_state); |
2113 | tp->sacked_out = 0; | 2160 | tp->sacked_out = 0; |
2114 | } | 2161 | } |
2115 | if (tp->retrans_out) { | 2162 | if (tp->retrans_out) { |
2116 | printk(KERN_DEBUG "Leak r=%u %d\n", | 2163 | printk(KERN_DEBUG "Leak r=%u %d\n", |
2117 | tp->retrans_out, tp->ca_state); | 2164 | tp->retrans_out, icsk->icsk_ca_state); |
2118 | tp->retrans_out = 0; | 2165 | tp->retrans_out = 0; |
2119 | } | 2166 | } |
2120 | } | 2167 | } |
@@ -2125,40 +2172,43 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p, s32 *seq_usrtt | |||
2125 | 2172 | ||
2126 | static void tcp_ack_probe(struct sock *sk) | 2173 | static void tcp_ack_probe(struct sock *sk) |
2127 | { | 2174 | { |
2128 | struct tcp_sock *tp = tcp_sk(sk); | 2175 | const struct tcp_sock *tp = tcp_sk(sk); |
2176 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
2129 | 2177 | ||
2130 | /* Was it a usable window open? */ | 2178 | /* Was it a usable window open? */ |
2131 | 2179 | ||
2132 | if (!after(TCP_SKB_CB(sk->sk_send_head)->end_seq, | 2180 | if (!after(TCP_SKB_CB(sk->sk_send_head)->end_seq, |
2133 | tp->snd_una + tp->snd_wnd)) { | 2181 | tp->snd_una + tp->snd_wnd)) { |
2134 | tp->backoff = 0; | 2182 | icsk->icsk_backoff = 0; |
2135 | tcp_clear_xmit_timer(sk, TCP_TIME_PROBE0); | 2183 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_PROBE0); |
2136 | /* Socket must be waked up by subsequent tcp_data_snd_check(). | 2184 | /* Socket must be waked up by subsequent tcp_data_snd_check(). |
2137 | * This function is not for random using! | 2185 | * This function is not for random using! |
2138 | */ | 2186 | */ |
2139 | } else { | 2187 | } else { |
2140 | tcp_reset_xmit_timer(sk, TCP_TIME_PROBE0, | 2188 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0, |
2141 | min(tp->rto << tp->backoff, TCP_RTO_MAX)); | 2189 | min(icsk->icsk_rto << icsk->icsk_backoff, TCP_RTO_MAX), |
2190 | TCP_RTO_MAX); | ||
2142 | } | 2191 | } |
2143 | } | 2192 | } |
2144 | 2193 | ||
2145 | static inline int tcp_ack_is_dubious(struct tcp_sock *tp, int flag) | 2194 | static inline int tcp_ack_is_dubious(const struct sock *sk, const int flag) |
2146 | { | 2195 | { |
2147 | return (!(flag & FLAG_NOT_DUP) || (flag & FLAG_CA_ALERT) || | 2196 | return (!(flag & FLAG_NOT_DUP) || (flag & FLAG_CA_ALERT) || |
2148 | tp->ca_state != TCP_CA_Open); | 2197 | inet_csk(sk)->icsk_ca_state != TCP_CA_Open); |
2149 | } | 2198 | } |
2150 | 2199 | ||
2151 | static inline int tcp_may_raise_cwnd(struct tcp_sock *tp, int flag) | 2200 | static inline int tcp_may_raise_cwnd(const struct sock *sk, const int flag) |
2152 | { | 2201 | { |
2202 | const struct tcp_sock *tp = tcp_sk(sk); | ||
2153 | return (!(flag & FLAG_ECE) || tp->snd_cwnd < tp->snd_ssthresh) && | 2203 | return (!(flag & FLAG_ECE) || tp->snd_cwnd < tp->snd_ssthresh) && |
2154 | !((1<<tp->ca_state)&(TCPF_CA_Recovery|TCPF_CA_CWR)); | 2204 | !((1 << inet_csk(sk)->icsk_ca_state) & (TCPF_CA_Recovery | TCPF_CA_CWR)); |
2155 | } | 2205 | } |
2156 | 2206 | ||
2157 | /* Check that window update is acceptable. | 2207 | /* Check that window update is acceptable. |
2158 | * The function assumes that snd_una<=ack<=snd_next. | 2208 | * The function assumes that snd_una<=ack<=snd_next. |
2159 | */ | 2209 | */ |
2160 | static inline int tcp_may_update_window(struct tcp_sock *tp, u32 ack, | 2210 | static inline int tcp_may_update_window(const struct tcp_sock *tp, const u32 ack, |
2161 | u32 ack_seq, u32 nwin) | 2211 | const u32 ack_seq, const u32 nwin) |
2162 | { | 2212 | { |
2163 | return (after(ack, tp->snd_una) || | 2213 | return (after(ack, tp->snd_una) || |
2164 | after(ack_seq, tp->snd_wl1) || | 2214 | after(ack_seq, tp->snd_wl1) || |
@@ -2241,6 +2291,7 @@ static void tcp_process_frto(struct sock *sk, u32 prior_snd_una) | |||
2241 | /* This routine deals with incoming acks, but not outgoing ones. */ | 2291 | /* This routine deals with incoming acks, but not outgoing ones. */ |
2242 | static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | 2292 | static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) |
2243 | { | 2293 | { |
2294 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
2244 | struct tcp_sock *tp = tcp_sk(sk); | 2295 | struct tcp_sock *tp = tcp_sk(sk); |
2245 | u32 prior_snd_una = tp->snd_una; | 2296 | u32 prior_snd_una = tp->snd_una; |
2246 | u32 ack_seq = TCP_SKB_CB(skb)->seq; | 2297 | u32 ack_seq = TCP_SKB_CB(skb)->seq; |
@@ -2268,7 +2319,7 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
2268 | tp->snd_una = ack; | 2319 | tp->snd_una = ack; |
2269 | flag |= FLAG_WIN_UPDATE; | 2320 | flag |= FLAG_WIN_UPDATE; |
2270 | 2321 | ||
2271 | tcp_ca_event(tp, CA_EVENT_FAST_ACK); | 2322 | tcp_ca_event(sk, CA_EVENT_FAST_ACK); |
2272 | 2323 | ||
2273 | NET_INC_STATS_BH(LINUX_MIB_TCPHPACKS); | 2324 | NET_INC_STATS_BH(LINUX_MIB_TCPHPACKS); |
2274 | } else { | 2325 | } else { |
@@ -2285,7 +2336,7 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
2285 | if (TCP_ECN_rcv_ecn_echo(tp, skb->h.th)) | 2336 | if (TCP_ECN_rcv_ecn_echo(tp, skb->h.th)) |
2286 | flag |= FLAG_ECE; | 2337 | flag |= FLAG_ECE; |
2287 | 2338 | ||
2288 | tcp_ca_event(tp, CA_EVENT_SLOW_ACK); | 2339 | tcp_ca_event(sk, CA_EVENT_SLOW_ACK); |
2289 | } | 2340 | } |
2290 | 2341 | ||
2291 | /* We passed data and got it acked, remove any soft error | 2342 | /* We passed data and got it acked, remove any soft error |
@@ -2301,19 +2352,19 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
2301 | 2352 | ||
2302 | /* See if we can take anything off of the retransmit queue. */ | 2353 | /* See if we can take anything off of the retransmit queue. */ |
2303 | flag |= tcp_clean_rtx_queue(sk, &seq_rtt, | 2354 | flag |= tcp_clean_rtx_queue(sk, &seq_rtt, |
2304 | tp->ca_ops->rtt_sample ? &seq_usrtt : NULL); | 2355 | icsk->icsk_ca_ops->rtt_sample ? &seq_usrtt : NULL); |
2305 | 2356 | ||
2306 | if (tp->frto_counter) | 2357 | if (tp->frto_counter) |
2307 | tcp_process_frto(sk, prior_snd_una); | 2358 | tcp_process_frto(sk, prior_snd_una); |
2308 | 2359 | ||
2309 | if (tcp_ack_is_dubious(tp, flag)) { | 2360 | if (tcp_ack_is_dubious(sk, flag)) { |
2310 | /* Advanve CWND, if state allows this. */ | 2361 | /* Advanve CWND, if state allows this. */ |
2311 | if ((flag & FLAG_DATA_ACKED) && tcp_may_raise_cwnd(tp, flag)) | 2362 | if ((flag & FLAG_DATA_ACKED) && tcp_may_raise_cwnd(sk, flag)) |
2312 | tcp_cong_avoid(tp, ack, seq_rtt, prior_in_flight, 0); | 2363 | tcp_cong_avoid(sk, ack, seq_rtt, prior_in_flight, 0); |
2313 | tcp_fastretrans_alert(sk, prior_snd_una, prior_packets, flag); | 2364 | tcp_fastretrans_alert(sk, prior_snd_una, prior_packets, flag); |
2314 | } else { | 2365 | } else { |
2315 | if ((flag & FLAG_DATA_ACKED)) | 2366 | if ((flag & FLAG_DATA_ACKED)) |
2316 | tcp_cong_avoid(tp, ack, seq_rtt, prior_in_flight, 1); | 2367 | tcp_cong_avoid(sk, ack, seq_rtt, prior_in_flight, 1); |
2317 | } | 2368 | } |
2318 | 2369 | ||
2319 | if ((flag & FLAG_FORWARD_PROGRESS) || !(flag&FLAG_NOT_DUP)) | 2370 | if ((flag & FLAG_FORWARD_PROGRESS) || !(flag&FLAG_NOT_DUP)) |
@@ -2322,7 +2373,7 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
2322 | return 1; | 2373 | return 1; |
2323 | 2374 | ||
2324 | no_queue: | 2375 | no_queue: |
2325 | tp->probes_out = 0; | 2376 | icsk->icsk_probes_out = 0; |
2326 | 2377 | ||
2327 | /* If this ack opens up a zero window, clear backoff. It was | 2378 | /* If this ack opens up a zero window, clear backoff. It was |
2328 | * being used to time the probes, and is probably far higher than | 2379 | * being used to time the probes, and is probably far higher than |
@@ -2500,8 +2551,9 @@ static inline void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq) | |||
2500 | * up to bandwidth of 18Gigabit/sec. 8) ] | 2551 | * up to bandwidth of 18Gigabit/sec. 8) ] |
2501 | */ | 2552 | */ |
2502 | 2553 | ||
2503 | static int tcp_disordered_ack(struct tcp_sock *tp, struct sk_buff *skb) | 2554 | static int tcp_disordered_ack(const struct sock *sk, const struct sk_buff *skb) |
2504 | { | 2555 | { |
2556 | struct tcp_sock *tp = tcp_sk(sk); | ||
2505 | struct tcphdr *th = skb->h.th; | 2557 | struct tcphdr *th = skb->h.th; |
2506 | u32 seq = TCP_SKB_CB(skb)->seq; | 2558 | u32 seq = TCP_SKB_CB(skb)->seq; |
2507 | u32 ack = TCP_SKB_CB(skb)->ack_seq; | 2559 | u32 ack = TCP_SKB_CB(skb)->ack_seq; |
@@ -2516,14 +2568,15 @@ static int tcp_disordered_ack(struct tcp_sock *tp, struct sk_buff *skb) | |||
2516 | !tcp_may_update_window(tp, ack, seq, ntohs(th->window) << tp->rx_opt.snd_wscale) && | 2568 | !tcp_may_update_window(tp, ack, seq, ntohs(th->window) << tp->rx_opt.snd_wscale) && |
2517 | 2569 | ||
2518 | /* 4. ... and sits in replay window. */ | 2570 | /* 4. ... and sits in replay window. */ |
2519 | (s32)(tp->rx_opt.ts_recent - tp->rx_opt.rcv_tsval) <= (tp->rto*1024)/HZ); | 2571 | (s32)(tp->rx_opt.ts_recent - tp->rx_opt.rcv_tsval) <= (inet_csk(sk)->icsk_rto * 1024) / HZ); |
2520 | } | 2572 | } |
2521 | 2573 | ||
2522 | static inline int tcp_paws_discard(struct tcp_sock *tp, struct sk_buff *skb) | 2574 | static inline int tcp_paws_discard(const struct sock *sk, const struct sk_buff *skb) |
2523 | { | 2575 | { |
2576 | const struct tcp_sock *tp = tcp_sk(sk); | ||
2524 | return ((s32)(tp->rx_opt.ts_recent - tp->rx_opt.rcv_tsval) > TCP_PAWS_WINDOW && | 2577 | return ((s32)(tp->rx_opt.ts_recent - tp->rx_opt.rcv_tsval) > TCP_PAWS_WINDOW && |
2525 | xtime.tv_sec < tp->rx_opt.ts_recent_stamp + TCP_PAWS_24DAYS && | 2578 | xtime.tv_sec < tp->rx_opt.ts_recent_stamp + TCP_PAWS_24DAYS && |
2526 | !tcp_disordered_ack(tp, skb)); | 2579 | !tcp_disordered_ack(sk, skb)); |
2527 | } | 2580 | } |
2528 | 2581 | ||
2529 | /* Check segment sequence number for validity. | 2582 | /* Check segment sequence number for validity. |
@@ -2586,7 +2639,7 @@ static void tcp_fin(struct sk_buff *skb, struct sock *sk, struct tcphdr *th) | |||
2586 | { | 2639 | { |
2587 | struct tcp_sock *tp = tcp_sk(sk); | 2640 | struct tcp_sock *tp = tcp_sk(sk); |
2588 | 2641 | ||
2589 | tcp_schedule_ack(tp); | 2642 | inet_csk_schedule_ack(sk); |
2590 | 2643 | ||
2591 | sk->sk_shutdown |= RCV_SHUTDOWN; | 2644 | sk->sk_shutdown |= RCV_SHUTDOWN; |
2592 | sock_set_flag(sk, SOCK_DONE); | 2645 | sock_set_flag(sk, SOCK_DONE); |
@@ -2596,7 +2649,7 @@ static void tcp_fin(struct sk_buff *skb, struct sock *sk, struct tcphdr *th) | |||
2596 | case TCP_ESTABLISHED: | 2649 | case TCP_ESTABLISHED: |
2597 | /* Move to CLOSE_WAIT */ | 2650 | /* Move to CLOSE_WAIT */ |
2598 | tcp_set_state(sk, TCP_CLOSE_WAIT); | 2651 | tcp_set_state(sk, TCP_CLOSE_WAIT); |
2599 | tp->ack.pingpong = 1; | 2652 | inet_csk(sk)->icsk_ack.pingpong = 1; |
2600 | break; | 2653 | break; |
2601 | 2654 | ||
2602 | case TCP_CLOSE_WAIT: | 2655 | case TCP_CLOSE_WAIT: |
@@ -2694,7 +2747,7 @@ static void tcp_send_dupack(struct sock *sk, struct sk_buff *skb) | |||
2694 | if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq && | 2747 | if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq && |
2695 | before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { | 2748 | before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { |
2696 | NET_INC_STATS_BH(LINUX_MIB_DELAYEDACKLOST); | 2749 | NET_INC_STATS_BH(LINUX_MIB_DELAYEDACKLOST); |
2697 | tcp_enter_quickack_mode(tp); | 2750 | tcp_enter_quickack_mode(sk); |
2698 | 2751 | ||
2699 | if (tp->rx_opt.sack_ok && sysctl_tcp_dsack) { | 2752 | if (tp->rx_opt.sack_ok && sysctl_tcp_dsack) { |
2700 | u32 end_seq = TCP_SKB_CB(skb)->end_seq; | 2753 | u32 end_seq = TCP_SKB_CB(skb)->end_seq; |
@@ -2853,7 +2906,7 @@ static void tcp_ofo_queue(struct sock *sk) | |||
2853 | 2906 | ||
2854 | if (!after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt)) { | 2907 | if (!after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt)) { |
2855 | SOCK_DEBUG(sk, "ofo packet was already received \n"); | 2908 | SOCK_DEBUG(sk, "ofo packet was already received \n"); |
2856 | __skb_unlink(skb, skb->list); | 2909 | __skb_unlink(skb, &tp->out_of_order_queue); |
2857 | __kfree_skb(skb); | 2910 | __kfree_skb(skb); |
2858 | continue; | 2911 | continue; |
2859 | } | 2912 | } |
@@ -2861,7 +2914,7 @@ static void tcp_ofo_queue(struct sock *sk) | |||
2861 | tp->rcv_nxt, TCP_SKB_CB(skb)->seq, | 2914 | tp->rcv_nxt, TCP_SKB_CB(skb)->seq, |
2862 | TCP_SKB_CB(skb)->end_seq); | 2915 | TCP_SKB_CB(skb)->end_seq); |
2863 | 2916 | ||
2864 | __skb_unlink(skb, skb->list); | 2917 | __skb_unlink(skb, &tp->out_of_order_queue); |
2865 | __skb_queue_tail(&sk->sk_receive_queue, skb); | 2918 | __skb_queue_tail(&sk->sk_receive_queue, skb); |
2866 | tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; | 2919 | tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; |
2867 | if(skb->h.th->fin) | 2920 | if(skb->h.th->fin) |
@@ -2942,7 +2995,7 @@ queue_and_out: | |||
2942 | * gap in queue is filled. | 2995 | * gap in queue is filled. |
2943 | */ | 2996 | */ |
2944 | if (skb_queue_empty(&tp->out_of_order_queue)) | 2997 | if (skb_queue_empty(&tp->out_of_order_queue)) |
2945 | tp->ack.pingpong = 0; | 2998 | inet_csk(sk)->icsk_ack.pingpong = 0; |
2946 | } | 2999 | } |
2947 | 3000 | ||
2948 | if (tp->rx_opt.num_sacks) | 3001 | if (tp->rx_opt.num_sacks) |
@@ -2963,8 +3016,8 @@ queue_and_out: | |||
2963 | tcp_dsack_set(tp, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq); | 3016 | tcp_dsack_set(tp, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq); |
2964 | 3017 | ||
2965 | out_of_window: | 3018 | out_of_window: |
2966 | tcp_enter_quickack_mode(tp); | 3019 | tcp_enter_quickack_mode(sk); |
2967 | tcp_schedule_ack(tp); | 3020 | inet_csk_schedule_ack(sk); |
2968 | drop: | 3021 | drop: |
2969 | __kfree_skb(skb); | 3022 | __kfree_skb(skb); |
2970 | return; | 3023 | return; |
@@ -2974,7 +3027,7 @@ drop: | |||
2974 | if (!before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt + tcp_receive_window(tp))) | 3027 | if (!before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt + tcp_receive_window(tp))) |
2975 | goto out_of_window; | 3028 | goto out_of_window; |
2976 | 3029 | ||
2977 | tcp_enter_quickack_mode(tp); | 3030 | tcp_enter_quickack_mode(sk); |
2978 | 3031 | ||
2979 | if (before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { | 3032 | if (before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { |
2980 | /* Partial packet, seq < rcv_next < end_seq */ | 3033 | /* Partial packet, seq < rcv_next < end_seq */ |
@@ -3003,7 +3056,7 @@ drop: | |||
3003 | 3056 | ||
3004 | /* Disable header prediction. */ | 3057 | /* Disable header prediction. */ |
3005 | tp->pred_flags = 0; | 3058 | tp->pred_flags = 0; |
3006 | tcp_schedule_ack(tp); | 3059 | inet_csk_schedule_ack(sk); |
3007 | 3060 | ||
3008 | SOCK_DEBUG(sk, "out of order segment: rcv_next %X seq %X - %X\n", | 3061 | SOCK_DEBUG(sk, "out of order segment: rcv_next %X seq %X - %X\n", |
3009 | tp->rcv_nxt, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq); | 3062 | tp->rcv_nxt, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq); |
@@ -3027,7 +3080,7 @@ drop: | |||
3027 | u32 end_seq = TCP_SKB_CB(skb)->end_seq; | 3080 | u32 end_seq = TCP_SKB_CB(skb)->end_seq; |
3028 | 3081 | ||
3029 | if (seq == TCP_SKB_CB(skb1)->end_seq) { | 3082 | if (seq == TCP_SKB_CB(skb1)->end_seq) { |
3030 | __skb_append(skb1, skb); | 3083 | __skb_append(skb1, skb, &tp->out_of_order_queue); |
3031 | 3084 | ||
3032 | if (!tp->rx_opt.num_sacks || | 3085 | if (!tp->rx_opt.num_sacks || |
3033 | tp->selective_acks[0].end_seq != seq) | 3086 | tp->selective_acks[0].end_seq != seq) |
@@ -3071,7 +3124,7 @@ drop: | |||
3071 | tcp_dsack_extend(tp, TCP_SKB_CB(skb1)->seq, end_seq); | 3124 | tcp_dsack_extend(tp, TCP_SKB_CB(skb1)->seq, end_seq); |
3072 | break; | 3125 | break; |
3073 | } | 3126 | } |
3074 | __skb_unlink(skb1, skb1->list); | 3127 | __skb_unlink(skb1, &tp->out_of_order_queue); |
3075 | tcp_dsack_extend(tp, TCP_SKB_CB(skb1)->seq, TCP_SKB_CB(skb1)->end_seq); | 3128 | tcp_dsack_extend(tp, TCP_SKB_CB(skb1)->seq, TCP_SKB_CB(skb1)->end_seq); |
3076 | __kfree_skb(skb1); | 3129 | __kfree_skb(skb1); |
3077 | } | 3130 | } |
@@ -3088,8 +3141,9 @@ add_sack: | |||
3088 | * simplifies code) | 3141 | * simplifies code) |
3089 | */ | 3142 | */ |
3090 | static void | 3143 | static void |
3091 | tcp_collapse(struct sock *sk, struct sk_buff *head, | 3144 | tcp_collapse(struct sock *sk, struct sk_buff_head *list, |
3092 | struct sk_buff *tail, u32 start, u32 end) | 3145 | struct sk_buff *head, struct sk_buff *tail, |
3146 | u32 start, u32 end) | ||
3093 | { | 3147 | { |
3094 | struct sk_buff *skb; | 3148 | struct sk_buff *skb; |
3095 | 3149 | ||
@@ -3099,7 +3153,7 @@ tcp_collapse(struct sock *sk, struct sk_buff *head, | |||
3099 | /* No new bits? It is possible on ofo queue. */ | 3153 | /* No new bits? It is possible on ofo queue. */ |
3100 | if (!before(start, TCP_SKB_CB(skb)->end_seq)) { | 3154 | if (!before(start, TCP_SKB_CB(skb)->end_seq)) { |
3101 | struct sk_buff *next = skb->next; | 3155 | struct sk_buff *next = skb->next; |
3102 | __skb_unlink(skb, skb->list); | 3156 | __skb_unlink(skb, list); |
3103 | __kfree_skb(skb); | 3157 | __kfree_skb(skb); |
3104 | NET_INC_STATS_BH(LINUX_MIB_TCPRCVCOLLAPSED); | 3158 | NET_INC_STATS_BH(LINUX_MIB_TCPRCVCOLLAPSED); |
3105 | skb = next; | 3159 | skb = next; |
@@ -3145,7 +3199,7 @@ tcp_collapse(struct sock *sk, struct sk_buff *head, | |||
3145 | nskb->mac.raw = nskb->head + (skb->mac.raw-skb->head); | 3199 | nskb->mac.raw = nskb->head + (skb->mac.raw-skb->head); |
3146 | memcpy(nskb->cb, skb->cb, sizeof(skb->cb)); | 3200 | memcpy(nskb->cb, skb->cb, sizeof(skb->cb)); |
3147 | TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(nskb)->end_seq = start; | 3201 | TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(nskb)->end_seq = start; |
3148 | __skb_insert(nskb, skb->prev, skb, skb->list); | 3202 | __skb_insert(nskb, skb->prev, skb, list); |
3149 | sk_stream_set_owner_r(nskb, sk); | 3203 | sk_stream_set_owner_r(nskb, sk); |
3150 | 3204 | ||
3151 | /* Copy data, releasing collapsed skbs. */ | 3205 | /* Copy data, releasing collapsed skbs. */ |
@@ -3164,7 +3218,7 @@ tcp_collapse(struct sock *sk, struct sk_buff *head, | |||
3164 | } | 3218 | } |
3165 | if (!before(start, TCP_SKB_CB(skb)->end_seq)) { | 3219 | if (!before(start, TCP_SKB_CB(skb)->end_seq)) { |
3166 | struct sk_buff *next = skb->next; | 3220 | struct sk_buff *next = skb->next; |
3167 | __skb_unlink(skb, skb->list); | 3221 | __skb_unlink(skb, list); |
3168 | __kfree_skb(skb); | 3222 | __kfree_skb(skb); |
3169 | NET_INC_STATS_BH(LINUX_MIB_TCPRCVCOLLAPSED); | 3223 | NET_INC_STATS_BH(LINUX_MIB_TCPRCVCOLLAPSED); |
3170 | skb = next; | 3224 | skb = next; |
@@ -3200,7 +3254,8 @@ static void tcp_collapse_ofo_queue(struct sock *sk) | |||
3200 | if (skb == (struct sk_buff *)&tp->out_of_order_queue || | 3254 | if (skb == (struct sk_buff *)&tp->out_of_order_queue || |
3201 | after(TCP_SKB_CB(skb)->seq, end) || | 3255 | after(TCP_SKB_CB(skb)->seq, end) || |
3202 | before(TCP_SKB_CB(skb)->end_seq, start)) { | 3256 | before(TCP_SKB_CB(skb)->end_seq, start)) { |
3203 | tcp_collapse(sk, head, skb, start, end); | 3257 | tcp_collapse(sk, &tp->out_of_order_queue, |
3258 | head, skb, start, end); | ||
3204 | head = skb; | 3259 | head = skb; |
3205 | if (skb == (struct sk_buff *)&tp->out_of_order_queue) | 3260 | if (skb == (struct sk_buff *)&tp->out_of_order_queue) |
3206 | break; | 3261 | break; |
@@ -3237,7 +3292,8 @@ static int tcp_prune_queue(struct sock *sk) | |||
3237 | tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4U * tp->advmss); | 3292 | tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4U * tp->advmss); |
3238 | 3293 | ||
3239 | tcp_collapse_ofo_queue(sk); | 3294 | tcp_collapse_ofo_queue(sk); |
3240 | tcp_collapse(sk, sk->sk_receive_queue.next, | 3295 | tcp_collapse(sk, &sk->sk_receive_queue, |
3296 | sk->sk_receive_queue.next, | ||
3241 | (struct sk_buff*)&sk->sk_receive_queue, | 3297 | (struct sk_buff*)&sk->sk_receive_queue, |
3242 | tp->copied_seq, tp->rcv_nxt); | 3298 | tp->copied_seq, tp->rcv_nxt); |
3243 | sk_stream_mem_reclaim(sk); | 3299 | sk_stream_mem_reclaim(sk); |
@@ -3286,12 +3342,12 @@ void tcp_cwnd_application_limited(struct sock *sk) | |||
3286 | { | 3342 | { |
3287 | struct tcp_sock *tp = tcp_sk(sk); | 3343 | struct tcp_sock *tp = tcp_sk(sk); |
3288 | 3344 | ||
3289 | if (tp->ca_state == TCP_CA_Open && | 3345 | if (inet_csk(sk)->icsk_ca_state == TCP_CA_Open && |
3290 | sk->sk_socket && !test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) { | 3346 | sk->sk_socket && !test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) { |
3291 | /* Limited by application or receiver window. */ | 3347 | /* Limited by application or receiver window. */ |
3292 | u32 win_used = max(tp->snd_cwnd_used, 2U); | 3348 | u32 win_used = max(tp->snd_cwnd_used, 2U); |
3293 | if (win_used < tp->snd_cwnd) { | 3349 | if (win_used < tp->snd_cwnd) { |
3294 | tp->snd_ssthresh = tcp_current_ssthresh(tp); | 3350 | tp->snd_ssthresh = tcp_current_ssthresh(sk); |
3295 | tp->snd_cwnd = (tp->snd_cwnd + win_used) >> 1; | 3351 | tp->snd_cwnd = (tp->snd_cwnd + win_used) >> 1; |
3296 | } | 3352 | } |
3297 | tp->snd_cwnd_used = 0; | 3353 | tp->snd_cwnd_used = 0; |
@@ -3370,13 +3426,13 @@ static void __tcp_ack_snd_check(struct sock *sk, int ofo_possible) | |||
3370 | struct tcp_sock *tp = tcp_sk(sk); | 3426 | struct tcp_sock *tp = tcp_sk(sk); |
3371 | 3427 | ||
3372 | /* More than one full frame received... */ | 3428 | /* More than one full frame received... */ |
3373 | if (((tp->rcv_nxt - tp->rcv_wup) > tp->ack.rcv_mss | 3429 | if (((tp->rcv_nxt - tp->rcv_wup) > inet_csk(sk)->icsk_ack.rcv_mss |
3374 | /* ... and right edge of window advances far enough. | 3430 | /* ... and right edge of window advances far enough. |
3375 | * (tcp_recvmsg() will send ACK otherwise). Or... | 3431 | * (tcp_recvmsg() will send ACK otherwise). Or... |
3376 | */ | 3432 | */ |
3377 | && __tcp_select_window(sk) >= tp->rcv_wnd) || | 3433 | && __tcp_select_window(sk) >= tp->rcv_wnd) || |
3378 | /* We ACK each frame or... */ | 3434 | /* We ACK each frame or... */ |
3379 | tcp_in_quickack_mode(tp) || | 3435 | tcp_in_quickack_mode(sk) || |
3380 | /* We have out of order data. */ | 3436 | /* We have out of order data. */ |
3381 | (ofo_possible && | 3437 | (ofo_possible && |
3382 | skb_peek(&tp->out_of_order_queue))) { | 3438 | skb_peek(&tp->out_of_order_queue))) { |
@@ -3390,8 +3446,7 @@ static void __tcp_ack_snd_check(struct sock *sk, int ofo_possible) | |||
3390 | 3446 | ||
3391 | static __inline__ void tcp_ack_snd_check(struct sock *sk) | 3447 | static __inline__ void tcp_ack_snd_check(struct sock *sk) |
3392 | { | 3448 | { |
3393 | struct tcp_sock *tp = tcp_sk(sk); | 3449 | if (!inet_csk_ack_scheduled(sk)) { |
3394 | if (!tcp_ack_scheduled(tp)) { | ||
3395 | /* We sent a data segment already. */ | 3450 | /* We sent a data segment already. */ |
3396 | return; | 3451 | return; |
3397 | } | 3452 | } |
@@ -3462,7 +3517,7 @@ static void tcp_check_urg(struct sock * sk, struct tcphdr * th) | |||
3462 | struct sk_buff *skb = skb_peek(&sk->sk_receive_queue); | 3517 | struct sk_buff *skb = skb_peek(&sk->sk_receive_queue); |
3463 | tp->copied_seq++; | 3518 | tp->copied_seq++; |
3464 | if (skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq)) { | 3519 | if (skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq)) { |
3465 | __skb_unlink(skb, skb->list); | 3520 | __skb_unlink(skb, &sk->sk_receive_queue); |
3466 | __kfree_skb(skb); | 3521 | __kfree_skb(skb); |
3467 | } | 3522 | } |
3468 | } | 3523 | } |
@@ -3645,7 +3700,7 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, | |||
3645 | tp->rcv_nxt == tp->rcv_wup) | 3700 | tp->rcv_nxt == tp->rcv_wup) |
3646 | tcp_store_ts_recent(tp); | 3701 | tcp_store_ts_recent(tp); |
3647 | 3702 | ||
3648 | tcp_rcv_rtt_measure_ts(tp, skb); | 3703 | tcp_rcv_rtt_measure_ts(sk, skb); |
3649 | 3704 | ||
3650 | /* We know that such packets are checksummed | 3705 | /* We know that such packets are checksummed |
3651 | * on entry. | 3706 | * on entry. |
@@ -3678,7 +3733,7 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, | |||
3678 | tp->rcv_nxt == tp->rcv_wup) | 3733 | tp->rcv_nxt == tp->rcv_wup) |
3679 | tcp_store_ts_recent(tp); | 3734 | tcp_store_ts_recent(tp); |
3680 | 3735 | ||
3681 | tcp_rcv_rtt_measure_ts(tp, skb); | 3736 | tcp_rcv_rtt_measure_ts(sk, skb); |
3682 | 3737 | ||
3683 | __skb_pull(skb, tcp_header_len); | 3738 | __skb_pull(skb, tcp_header_len); |
3684 | tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; | 3739 | tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; |
@@ -3699,7 +3754,7 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, | |||
3699 | tp->rcv_nxt == tp->rcv_wup) | 3754 | tp->rcv_nxt == tp->rcv_wup) |
3700 | tcp_store_ts_recent(tp); | 3755 | tcp_store_ts_recent(tp); |
3701 | 3756 | ||
3702 | tcp_rcv_rtt_measure_ts(tp, skb); | 3757 | tcp_rcv_rtt_measure_ts(sk, skb); |
3703 | 3758 | ||
3704 | if ((int)skb->truesize > sk->sk_forward_alloc) | 3759 | if ((int)skb->truesize > sk->sk_forward_alloc) |
3705 | goto step5; | 3760 | goto step5; |
@@ -3719,7 +3774,7 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, | |||
3719 | /* Well, only one small jumplet in fast path... */ | 3774 | /* Well, only one small jumplet in fast path... */ |
3720 | tcp_ack(sk, skb, FLAG_DATA); | 3775 | tcp_ack(sk, skb, FLAG_DATA); |
3721 | tcp_data_snd_check(sk, tp); | 3776 | tcp_data_snd_check(sk, tp); |
3722 | if (!tcp_ack_scheduled(tp)) | 3777 | if (!inet_csk_ack_scheduled(sk)) |
3723 | goto no_ack; | 3778 | goto no_ack; |
3724 | } | 3779 | } |
3725 | 3780 | ||
@@ -3741,7 +3796,7 @@ slow_path: | |||
3741 | * RFC1323: H1. Apply PAWS check first. | 3796 | * RFC1323: H1. Apply PAWS check first. |
3742 | */ | 3797 | */ |
3743 | if (tcp_fast_parse_options(skb, th, tp) && tp->rx_opt.saw_tstamp && | 3798 | if (tcp_fast_parse_options(skb, th, tp) && tp->rx_opt.saw_tstamp && |
3744 | tcp_paws_discard(tp, skb)) { | 3799 | tcp_paws_discard(sk, skb)) { |
3745 | if (!th->rst) { | 3800 | if (!th->rst) { |
3746 | NET_INC_STATS_BH(LINUX_MIB_PAWSESTABREJECTED); | 3801 | NET_INC_STATS_BH(LINUX_MIB_PAWSESTABREJECTED); |
3747 | tcp_send_dupack(sk, skb); | 3802 | tcp_send_dupack(sk, skb); |
@@ -3788,7 +3843,7 @@ step5: | |||
3788 | if(th->ack) | 3843 | if(th->ack) |
3789 | tcp_ack(sk, skb, FLAG_SLOWPATH); | 3844 | tcp_ack(sk, skb, FLAG_SLOWPATH); |
3790 | 3845 | ||
3791 | tcp_rcv_rtt_measure_ts(tp, skb); | 3846 | tcp_rcv_rtt_measure_ts(sk, skb); |
3792 | 3847 | ||
3793 | /* Process urgent data. */ | 3848 | /* Process urgent data. */ |
3794 | tcp_urg(sk, skb, th); | 3849 | tcp_urg(sk, skb, th); |
@@ -3817,6 +3872,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, | |||
3817 | tcp_parse_options(skb, &tp->rx_opt, 0); | 3872 | tcp_parse_options(skb, &tp->rx_opt, 0); |
3818 | 3873 | ||
3819 | if (th->ack) { | 3874 | if (th->ack) { |
3875 | struct inet_connection_sock *icsk; | ||
3820 | /* rfc793: | 3876 | /* rfc793: |
3821 | * "If the state is SYN-SENT then | 3877 | * "If the state is SYN-SENT then |
3822 | * first check the ACK bit | 3878 | * first check the ACK bit |
@@ -3920,7 +3976,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, | |||
3920 | 3976 | ||
3921 | tcp_init_metrics(sk); | 3977 | tcp_init_metrics(sk); |
3922 | 3978 | ||
3923 | tcp_init_congestion_control(tp); | 3979 | tcp_init_congestion_control(sk); |
3924 | 3980 | ||
3925 | /* Prevent spurious tcp_cwnd_restart() on first data | 3981 | /* Prevent spurious tcp_cwnd_restart() on first data |
3926 | * packet. | 3982 | * packet. |
@@ -3930,7 +3986,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, | |||
3930 | tcp_init_buffer_space(sk); | 3986 | tcp_init_buffer_space(sk); |
3931 | 3987 | ||
3932 | if (sock_flag(sk, SOCK_KEEPOPEN)) | 3988 | if (sock_flag(sk, SOCK_KEEPOPEN)) |
3933 | tcp_reset_keepalive_timer(sk, keepalive_time_when(tp)); | 3989 | inet_csk_reset_keepalive_timer(sk, keepalive_time_when(tp)); |
3934 | 3990 | ||
3935 | if (!tp->rx_opt.snd_wscale) | 3991 | if (!tp->rx_opt.snd_wscale) |
3936 | __tcp_fast_path_on(tp, tp->snd_wnd); | 3992 | __tcp_fast_path_on(tp, tp->snd_wnd); |
@@ -3942,7 +3998,11 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, | |||
3942 | sk_wake_async(sk, 0, POLL_OUT); | 3998 | sk_wake_async(sk, 0, POLL_OUT); |
3943 | } | 3999 | } |
3944 | 4000 | ||
3945 | if (sk->sk_write_pending || tp->defer_accept || tp->ack.pingpong) { | 4001 | icsk = inet_csk(sk); |
4002 | |||
4003 | if (sk->sk_write_pending || | ||
4004 | icsk->icsk_accept_queue.rskq_defer_accept || | ||
4005 | icsk->icsk_ack.pingpong) { | ||
3946 | /* Save one ACK. Data will be ready after | 4006 | /* Save one ACK. Data will be ready after |
3947 | * several ticks, if write_pending is set. | 4007 | * several ticks, if write_pending is set. |
3948 | * | 4008 | * |
@@ -3950,12 +4010,13 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, | |||
3950 | * look so _wonderfully_ clever, that I was not able | 4010 | * look so _wonderfully_ clever, that I was not able |
3951 | * to stand against the temptation 8) --ANK | 4011 | * to stand against the temptation 8) --ANK |
3952 | */ | 4012 | */ |
3953 | tcp_schedule_ack(tp); | 4013 | inet_csk_schedule_ack(sk); |
3954 | tp->ack.lrcvtime = tcp_time_stamp; | 4014 | icsk->icsk_ack.lrcvtime = tcp_time_stamp; |
3955 | tp->ack.ato = TCP_ATO_MIN; | 4015 | icsk->icsk_ack.ato = TCP_ATO_MIN; |
3956 | tcp_incr_quickack(tp); | 4016 | tcp_incr_quickack(sk); |
3957 | tcp_enter_quickack_mode(tp); | 4017 | tcp_enter_quickack_mode(sk); |
3958 | tcp_reset_xmit_timer(sk, TCP_TIME_DACK, TCP_DELACK_MAX); | 4018 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, |
4019 | TCP_DELACK_MAX, TCP_RTO_MAX); | ||
3959 | 4020 | ||
3960 | discard: | 4021 | discard: |
3961 | __kfree_skb(skb); | 4022 | __kfree_skb(skb); |
@@ -4111,7 +4172,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | |||
4111 | } | 4172 | } |
4112 | 4173 | ||
4113 | if (tcp_fast_parse_options(skb, th, tp) && tp->rx_opt.saw_tstamp && | 4174 | if (tcp_fast_parse_options(skb, th, tp) && tp->rx_opt.saw_tstamp && |
4114 | tcp_paws_discard(tp, skb)) { | 4175 | tcp_paws_discard(sk, skb)) { |
4115 | if (!th->rst) { | 4176 | if (!th->rst) { |
4116 | NET_INC_STATS_BH(LINUX_MIB_PAWSESTABREJECTED); | 4177 | NET_INC_STATS_BH(LINUX_MIB_PAWSESTABREJECTED); |
4117 | tcp_send_dupack(sk, skb); | 4178 | tcp_send_dupack(sk, skb); |
@@ -4180,7 +4241,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | |||
4180 | */ | 4241 | */ |
4181 | if (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr && | 4242 | if (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr && |
4182 | !tp->srtt) | 4243 | !tp->srtt) |
4183 | tcp_ack_saw_tstamp(tp, 0, 0); | 4244 | tcp_ack_saw_tstamp(sk, NULL, 0); |
4184 | 4245 | ||
4185 | if (tp->rx_opt.tstamp_ok) | 4246 | if (tp->rx_opt.tstamp_ok) |
4186 | tp->advmss -= TCPOLEN_TSTAMP_ALIGNED; | 4247 | tp->advmss -= TCPOLEN_TSTAMP_ALIGNED; |
@@ -4192,7 +4253,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | |||
4192 | 4253 | ||
4193 | tcp_init_metrics(sk); | 4254 | tcp_init_metrics(sk); |
4194 | 4255 | ||
4195 | tcp_init_congestion_control(tp); | 4256 | tcp_init_congestion_control(sk); |
4196 | 4257 | ||
4197 | /* Prevent spurious tcp_cwnd_restart() on | 4258 | /* Prevent spurious tcp_cwnd_restart() on |
4198 | * first data packet. | 4259 | * first data packet. |
@@ -4227,9 +4288,9 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | |||
4227 | return 1; | 4288 | return 1; |
4228 | } | 4289 | } |
4229 | 4290 | ||
4230 | tmo = tcp_fin_time(tp); | 4291 | tmo = tcp_fin_time(sk); |
4231 | if (tmo > TCP_TIMEWAIT_LEN) { | 4292 | if (tmo > TCP_TIMEWAIT_LEN) { |
4232 | tcp_reset_keepalive_timer(sk, tmo - TCP_TIMEWAIT_LEN); | 4293 | inet_csk_reset_keepalive_timer(sk, tmo - TCP_TIMEWAIT_LEN); |
4233 | } else if (th->fin || sock_owned_by_user(sk)) { | 4294 | } else if (th->fin || sock_owned_by_user(sk)) { |
4234 | /* Bad case. We could lose such FIN otherwise. | 4295 | /* Bad case. We could lose such FIN otherwise. |
4235 | * It is not a big problem, but it looks confusing | 4296 | * It is not a big problem, but it looks confusing |
@@ -4237,7 +4298,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | |||
4237 | * if it spins in bh_lock_sock(), but it is really | 4298 | * if it spins in bh_lock_sock(), but it is really |
4238 | * marginal case. | 4299 | * marginal case. |
4239 | */ | 4300 | */ |
4240 | tcp_reset_keepalive_timer(sk, tmo); | 4301 | inet_csk_reset_keepalive_timer(sk, tmo); |
4241 | } else { | 4302 | } else { |
4242 | tcp_time_wait(sk, TCP_FIN_WAIT2, tmo); | 4303 | tcp_time_wait(sk, TCP_FIN_WAIT2, tmo); |
4243 | goto discard; | 4304 | goto discard; |