aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_input.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r--net/ipv4/tcp_input.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index c53b7f35c51d..eeaac399420d 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -671,6 +671,7 @@ static void tcp_rtt_estimator(struct sock *sk, const __u32 mrtt)
671{ 671{
672 struct tcp_sock *tp = tcp_sk(sk); 672 struct tcp_sock *tp = tcp_sk(sk);
673 long m = mrtt; /* RTT */ 673 long m = mrtt; /* RTT */
674 u32 srtt = tp->srtt;
674 675
675 /* The following amusing code comes from Jacobson's 676 /* The following amusing code comes from Jacobson's
676 * article in SIGCOMM '88. Note that rtt and mdev 677 * article in SIGCOMM '88. Note that rtt and mdev
@@ -688,11 +689,9 @@ static void tcp_rtt_estimator(struct sock *sk, const __u32 mrtt)
688 * does not matter how to _calculate_ it. Seems, it was trap 689 * does not matter how to _calculate_ it. Seems, it was trap
689 * that VJ failed to avoid. 8) 690 * that VJ failed to avoid. 8)
690 */ 691 */
691 if (m == 0) 692 if (srtt != 0) {
692 m = 1; 693 m -= (srtt >> 3); /* m is now error in rtt est */
693 if (tp->srtt != 0) { 694 srtt += m; /* rtt = 7/8 rtt + 1/8 new */
694 m -= (tp->srtt >> 3); /* m is now error in rtt est */
695 tp->srtt += m; /* rtt = 7/8 rtt + 1/8 new */
696 if (m < 0) { 695 if (m < 0) {
697 m = -m; /* m is now abs(error) */ 696 m = -m; /* m is now abs(error) */
698 m -= (tp->mdev >> 2); /* similar update on mdev */ 697 m -= (tp->mdev >> 2); /* similar update on mdev */
@@ -723,11 +722,12 @@ static void tcp_rtt_estimator(struct sock *sk, const __u32 mrtt)
723 } 722 }
724 } else { 723 } else {
725 /* no previous measure. */ 724 /* no previous measure. */
726 tp->srtt = m << 3; /* take the measured time to be rtt */ 725 srtt = m << 3; /* take the measured time to be rtt */
727 tp->mdev = m << 1; /* make sure rto = 3*rtt */ 726 tp->mdev = m << 1; /* make sure rto = 3*rtt */
728 tp->mdev_max = tp->rttvar = max(tp->mdev, tcp_rto_min(sk)); 727 tp->mdev_max = tp->rttvar = max(tp->mdev, tcp_rto_min(sk));
729 tp->rtt_seq = tp->snd_nxt; 728 tp->rtt_seq = tp->snd_nxt;
730 } 729 }
730 tp->srtt = max(1U, srtt);
731} 731}
732 732
733/* Set the sk_pacing_rate to allow proper sizing of TSO packets. 733/* Set the sk_pacing_rate to allow proper sizing of TSO packets.
@@ -746,8 +746,10 @@ static void tcp_update_pacing_rate(struct sock *sk)
746 746
747 rate *= max(tp->snd_cwnd, tp->packets_out); 747 rate *= max(tp->snd_cwnd, tp->packets_out);
748 748
749 /* Correction for small srtt : minimum srtt being 8 (1 jiffy << 3), 749 /* Correction for small srtt and scheduling constraints.
750 * be conservative and assume srtt = 1 (125 us instead of 1.25 ms) 750 * For small rtt, consider noise is too high, and use
751 * the minimal value (srtt = 1 -> 125 us for HZ=1000)
752 *
751 * We probably need usec resolution in the future. 753 * We probably need usec resolution in the future.
752 * Note: This also takes care of possible srtt=0 case, 754 * Note: This also takes care of possible srtt=0 case,
753 * when tcp_rtt_estimator() was not yet called. 755 * when tcp_rtt_estimator() was not yet called.
@@ -766,7 +768,7 @@ static void tcp_update_pacing_rate(struct sock *sk)
766/* Calculate rto without backoff. This is the second half of Van Jacobson's 768/* Calculate rto without backoff. This is the second half of Van Jacobson's
767 * routine referred to above. 769 * routine referred to above.
768 */ 770 */
769void tcp_set_rto(struct sock *sk) 771static void tcp_set_rto(struct sock *sk)
770{ 772{
771 const struct tcp_sock *tp = tcp_sk(sk); 773 const struct tcp_sock *tp = tcp_sk(sk);
772 /* Old crap is replaced with new one. 8) 774 /* Old crap is replaced with new one. 8)
@@ -1943,8 +1945,9 @@ void tcp_enter_loss(struct sock *sk, int how)
1943 if (skb == tcp_send_head(sk)) 1945 if (skb == tcp_send_head(sk))
1944 break; 1946 break;
1945 1947
1946 if (TCP_SKB_CB(skb)->sacked & TCPCB_RETRANS) 1948 if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS)
1947 tp->undo_marker = 0; 1949 tp->undo_marker = 0;
1950
1948 TCP_SKB_CB(skb)->sacked &= (~TCPCB_TAGBITS)|TCPCB_SACKED_ACKED; 1951 TCP_SKB_CB(skb)->sacked &= (~TCPCB_TAGBITS)|TCPCB_SACKED_ACKED;
1949 if (!(TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_ACKED) || how) { 1952 if (!(TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_ACKED) || how) {
1950 TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_ACKED; 1953 TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_ACKED;
@@ -3686,7 +3689,7 @@ const u8 *tcp_parse_md5sig_option(const struct tcphdr *th)
3686 int opcode = *ptr++; 3689 int opcode = *ptr++;
3687 int opsize; 3690 int opsize;
3688 3691
3689 switch(opcode) { 3692 switch (opcode) {
3690 case TCPOPT_EOL: 3693 case TCPOPT_EOL:
3691 return NULL; 3694 return NULL;
3692 case TCPOPT_NOP: 3695 case TCPOPT_NOP:
@@ -4046,7 +4049,7 @@ static void tcp_sack_remove(struct tcp_sock *tp)
4046 WARN_ON(before(tp->rcv_nxt, sp->end_seq)); 4049 WARN_ON(before(tp->rcv_nxt, sp->end_seq));
4047 4050
4048 /* Zap this SACK, by moving forward any other SACKS. */ 4051 /* Zap this SACK, by moving forward any other SACKS. */
4049 for (i=this_sack+1; i < num_sacks; i++) 4052 for (i = this_sack+1; i < num_sacks; i++)
4050 tp->selective_acks[i-1] = tp->selective_acks[i]; 4053 tp->selective_acks[i-1] = tp->selective_acks[i];
4051 num_sacks--; 4054 num_sacks--;
4052 continue; 4055 continue;