diff options
Diffstat (limited to 'net/ipv4/tcp_output.c')
-rw-r--r-- | net/ipv4/tcp_output.c | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 454cf84b6154..bb7e80a284e7 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -221,14 +221,14 @@ void tcp_select_initial_window(int __space, __u32 mss, | |||
221 | * following RFC2414. Senders, not following this RFC, | 221 | * following RFC2414. Senders, not following this RFC, |
222 | * will be satisfied with 2. | 222 | * will be satisfied with 2. |
223 | */ | 223 | */ |
224 | if (mss > (1<<*rcv_wscale)) { | 224 | if (mss > (1 << *rcv_wscale)) { |
225 | int init_cwnd = 4; | 225 | int init_cwnd = 4; |
226 | if (mss > 1460*3) | 226 | if (mss > 1460 * 3) |
227 | init_cwnd = 2; | 227 | init_cwnd = 2; |
228 | else if (mss > 1460) | 228 | else if (mss > 1460) |
229 | init_cwnd = 3; | 229 | init_cwnd = 3; |
230 | if (*rcv_wnd > init_cwnd*mss) | 230 | if (*rcv_wnd > init_cwnd * mss) |
231 | *rcv_wnd = init_cwnd*mss; | 231 | *rcv_wnd = init_cwnd * mss; |
232 | } | 232 | } |
233 | 233 | ||
234 | /* Set the clamp no higher than max representable value */ | 234 | /* Set the clamp no higher than max representable value */ |
@@ -278,11 +278,10 @@ static u16 tcp_select_window(struct sock *sk) | |||
278 | return new_win; | 278 | return new_win; |
279 | } | 279 | } |
280 | 280 | ||
281 | static inline void TCP_ECN_send_synack(struct tcp_sock *tp, | 281 | static inline void TCP_ECN_send_synack(struct tcp_sock *tp, struct sk_buff *skb) |
282 | struct sk_buff *skb) | ||
283 | { | 282 | { |
284 | TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR; | 283 | TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR; |
285 | if (!(tp->ecn_flags&TCP_ECN_OK)) | 284 | if (!(tp->ecn_flags & TCP_ECN_OK)) |
286 | TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE; | 285 | TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE; |
287 | } | 286 | } |
288 | 287 | ||
@@ -292,7 +291,7 @@ static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb) | |||
292 | 291 | ||
293 | tp->ecn_flags = 0; | 292 | tp->ecn_flags = 0; |
294 | if (sysctl_tcp_ecn) { | 293 | if (sysctl_tcp_ecn) { |
295 | TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR; | 294 | TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE | TCPCB_FLAG_CWR; |
296 | tp->ecn_flags = TCP_ECN_OK; | 295 | tp->ecn_flags = TCP_ECN_OK; |
297 | } | 296 | } |
298 | } | 297 | } |
@@ -314,7 +313,7 @@ static inline void TCP_ECN_send(struct sock *sk, struct sk_buff *skb, | |||
314 | if (skb->len != tcp_header_len && | 313 | if (skb->len != tcp_header_len && |
315 | !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) { | 314 | !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) { |
316 | INET_ECN_xmit(sk); | 315 | INET_ECN_xmit(sk); |
317 | if (tp->ecn_flags&TCP_ECN_QUEUE_CWR) { | 316 | if (tp->ecn_flags & TCP_ECN_QUEUE_CWR) { |
318 | tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR; | 317 | tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR; |
319 | tcp_hdr(skb)->cwr = 1; | 318 | tcp_hdr(skb)->cwr = 1; |
320 | skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN; | 319 | skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN; |
@@ -431,7 +430,7 @@ static void tcp_syn_build_options(__be32 *ptr, int mss, int ts, int sack, | |||
431 | (TCPOPT_NOP << 16) | | 430 | (TCPOPT_NOP << 16) | |
432 | (TCPOPT_MD5SIG << 8) | | 431 | (TCPOPT_MD5SIG << 8) | |
433 | TCPOLEN_MD5SIG); | 432 | TCPOLEN_MD5SIG); |
434 | *md5_hash = (__u8 *) ptr; | 433 | *md5_hash = (__u8 *)ptr; |
435 | } | 434 | } |
436 | #endif | 435 | #endif |
437 | } | 436 | } |
@@ -447,7 +446,8 @@ static void tcp_syn_build_options(__be32 *ptr, int mss, int ts, int sack, | |||
447 | * We are working here with either a clone of the original | 446 | * We are working here with either a clone of the original |
448 | * SKB, or a fresh unique copy made by the retransmit engine. | 447 | * SKB, or a fresh unique copy made by the retransmit engine. |
449 | */ | 448 | */ |
450 | static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, gfp_t gfp_mask) | 449 | static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, |
450 | gfp_t gfp_mask) | ||
451 | { | 451 | { |
452 | const struct inet_connection_sock *icsk = inet_csk(sk); | 452 | const struct inet_connection_sock *icsk = inet_csk(sk); |
453 | struct inet_sock *inet; | 453 | struct inet_sock *inet; |
@@ -551,8 +551,8 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, | |||
551 | th->urg_ptr = 0; | 551 | th->urg_ptr = 0; |
552 | 552 | ||
553 | if (unlikely(tp->urg_mode && | 553 | if (unlikely(tp->urg_mode && |
554 | between(tp->snd_up, tcb->seq+1, tcb->seq+0xFFFF))) { | 554 | between(tp->snd_up, tcb->seq + 1, tcb->seq + 0xFFFF))) { |
555 | th->urg_ptr = htons(tp->snd_up-tcb->seq); | 555 | th->urg_ptr = htons(tp->snd_up - tcb->seq); |
556 | th->urg = 1; | 556 | th->urg = 1; |
557 | } | 557 | } |
558 | 558 | ||
@@ -616,7 +616,6 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, | |||
616 | #undef SYSCTL_FLAG_SACK | 616 | #undef SYSCTL_FLAG_SACK |
617 | } | 617 | } |
618 | 618 | ||
619 | |||
620 | /* This routine just queue's the buffer | 619 | /* This routine just queue's the buffer |
621 | * | 620 | * |
622 | * NOTE: probe0 timer is not checked, do not forget tcp_push_pending_frames, | 621 | * NOTE: probe0 timer is not checked, do not forget tcp_push_pending_frames, |
@@ -634,7 +633,8 @@ static void tcp_queue_skb(struct sock *sk, struct sk_buff *skb) | |||
634 | sk_mem_charge(sk, skb->truesize); | 633 | sk_mem_charge(sk, skb->truesize); |
635 | } | 634 | } |
636 | 635 | ||
637 | static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned int mss_now) | 636 | static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, |
637 | unsigned int mss_now) | ||
638 | { | 638 | { |
639 | if (skb->len <= mss_now || !sk_can_gso(sk)) { | 639 | if (skb->len <= mss_now || !sk_can_gso(sk)) { |
640 | /* Avoid the costly divide in the normal | 640 | /* Avoid the costly divide in the normal |
@@ -670,7 +670,8 @@ static void tcp_adjust_fackets_out(struct sock *sk, struct sk_buff *skb, | |||
670 | * packet to the list. This won't be called frequently, I hope. | 670 | * packet to the list. This won't be called frequently, I hope. |
671 | * Remember, these are still headerless SKBs at this point. | 671 | * Remember, these are still headerless SKBs at this point. |
672 | */ | 672 | */ |
673 | int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss_now) | 673 | int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, |
674 | unsigned int mss_now) | ||
674 | { | 675 | { |
675 | struct tcp_sock *tp = tcp_sk(sk); | 676 | struct tcp_sock *tp = tcp_sk(sk); |
676 | struct sk_buff *buff; | 677 | struct sk_buff *buff; |
@@ -708,13 +709,14 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss | |||
708 | 709 | ||
709 | /* PSH and FIN should only be set in the second packet. */ | 710 | /* PSH and FIN should only be set in the second packet. */ |
710 | flags = TCP_SKB_CB(skb)->flags; | 711 | flags = TCP_SKB_CB(skb)->flags; |
711 | TCP_SKB_CB(skb)->flags = flags & ~(TCPCB_FLAG_FIN|TCPCB_FLAG_PSH); | 712 | TCP_SKB_CB(skb)->flags = flags & ~(TCPCB_FLAG_FIN | TCPCB_FLAG_PSH); |
712 | TCP_SKB_CB(buff)->flags = flags; | 713 | TCP_SKB_CB(buff)->flags = flags; |
713 | TCP_SKB_CB(buff)->sacked = TCP_SKB_CB(skb)->sacked; | 714 | TCP_SKB_CB(buff)->sacked = TCP_SKB_CB(skb)->sacked; |
714 | 715 | ||
715 | if (!skb_shinfo(skb)->nr_frags && skb->ip_summed != CHECKSUM_PARTIAL) { | 716 | if (!skb_shinfo(skb)->nr_frags && skb->ip_summed != CHECKSUM_PARTIAL) { |
716 | /* Copy and checksum data tail into the new buffer. */ | 717 | /* Copy and checksum data tail into the new buffer. */ |
717 | buff->csum = csum_partial_copy_nocheck(skb->data + len, skb_put(buff, nsize), | 718 | buff->csum = csum_partial_copy_nocheck(skb->data + len, |
719 | skb_put(buff, nsize), | ||
718 | nsize, 0); | 720 | nsize, 0); |
719 | 721 | ||
720 | skb_trim(skb, len); | 722 | skb_trim(skb, len); |
@@ -781,7 +783,7 @@ static void __pskb_trim_head(struct sk_buff *skb, int len) | |||
781 | 783 | ||
782 | eat = len; | 784 | eat = len; |
783 | k = 0; | 785 | k = 0; |
784 | for (i=0; i<skb_shinfo(skb)->nr_frags; i++) { | 786 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
785 | if (skb_shinfo(skb)->frags[i].size <= eat) { | 787 | if (skb_shinfo(skb)->frags[i].size <= eat) { |
786 | put_page(skb_shinfo(skb)->frags[i].page); | 788 | put_page(skb_shinfo(skb)->frags[i].page); |
787 | eat -= skb_shinfo(skb)->frags[i].size; | 789 | eat -= skb_shinfo(skb)->frags[i].size; |
@@ -804,8 +806,7 @@ static void __pskb_trim_head(struct sk_buff *skb, int len) | |||
804 | 806 | ||
805 | int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) | 807 | int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) |
806 | { | 808 | { |
807 | if (skb_cloned(skb) && | 809 | if (skb_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) |
808 | pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) | ||
809 | return -ENOMEM; | 810 | return -ENOMEM; |
810 | 811 | ||
811 | /* If len == headlen, we avoid __skb_pull to preserve alignment. */ | 812 | /* If len == headlen, we avoid __skb_pull to preserve alignment. */ |
@@ -909,7 +910,6 @@ void tcp_mtup_init(struct sock *sk) | |||
909 | NOTE2. inet_csk(sk)->icsk_pmtu_cookie and tp->mss_cache | 910 | NOTE2. inet_csk(sk)->icsk_pmtu_cookie and tp->mss_cache |
910 | are READ ONLY outside this function. --ANK (980731) | 911 | are READ ONLY outside this function. --ANK (980731) |
911 | */ | 912 | */ |
912 | |||
913 | unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) | 913 | unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) |
914 | { | 914 | { |
915 | struct tcp_sock *tp = tcp_sk(sk); | 915 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -922,8 +922,8 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) | |||
922 | mss_now = tcp_mtu_to_mss(sk, pmtu); | 922 | mss_now = tcp_mtu_to_mss(sk, pmtu); |
923 | 923 | ||
924 | /* Bound mss with half of window */ | 924 | /* Bound mss with half of window */ |
925 | if (tp->max_window && mss_now > (tp->max_window>>1)) | 925 | if (tp->max_window && mss_now > (tp->max_window >> 1)) |
926 | mss_now = max((tp->max_window>>1), 68U - tp->tcp_header_len); | 926 | mss_now = max((tp->max_window >> 1), 68U - tp->tcp_header_len); |
927 | 927 | ||
928 | /* And store cached results */ | 928 | /* And store cached results */ |
929 | icsk->icsk_pmtu_cookie = pmtu; | 929 | icsk->icsk_pmtu_cookie = pmtu; |
@@ -977,8 +977,7 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed) | |||
977 | inet_csk(sk)->icsk_ext_hdr_len - | 977 | inet_csk(sk)->icsk_ext_hdr_len - |
978 | tp->tcp_header_len); | 978 | tp->tcp_header_len); |
979 | 979 | ||
980 | if (tp->max_window && | 980 | if (tp->max_window && (xmit_size_goal > (tp->max_window >> 1))) |
981 | (xmit_size_goal > (tp->max_window >> 1))) | ||
982 | xmit_size_goal = max((tp->max_window >> 1), | 981 | xmit_size_goal = max((tp->max_window >> 1), |
983 | 68U - tp->tcp_header_len); | 982 | 68U - tp->tcp_header_len); |
984 | 983 | ||
@@ -990,7 +989,6 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed) | |||
990 | } | 989 | } |
991 | 990 | ||
992 | /* Congestion window validation. (RFC2861) */ | 991 | /* Congestion window validation. (RFC2861) */ |
993 | |||
994 | static void tcp_cwnd_validate(struct sock *sk) | 992 | static void tcp_cwnd_validate(struct sock *sk) |
995 | { | 993 | { |
996 | struct tcp_sock *tp = tcp_sk(sk); | 994 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -1017,8 +1015,7 @@ static void tcp_cwnd_validate(struct sock *sk) | |||
1017 | * per input skb which could be mostly avoided here (if desired). | 1015 | * per input skb which could be mostly avoided here (if desired). |
1018 | */ | 1016 | */ |
1019 | static unsigned int tcp_mss_split_point(struct sock *sk, struct sk_buff *skb, | 1017 | static unsigned int tcp_mss_split_point(struct sock *sk, struct sk_buff *skb, |
1020 | unsigned int mss_now, | 1018 | unsigned int mss_now, unsigned int cwnd) |
1021 | unsigned int cwnd) | ||
1022 | { | 1019 | { |
1023 | struct tcp_sock *tp = tcp_sk(sk); | 1020 | struct tcp_sock *tp = tcp_sk(sk); |
1024 | u32 needed, window, cwnd_len; | 1021 | u32 needed, window, cwnd_len; |
@@ -1039,7 +1036,8 @@ static unsigned int tcp_mss_split_point(struct sock *sk, struct sk_buff *skb, | |||
1039 | /* Can at least one segment of SKB be sent right now, according to the | 1036 | /* Can at least one segment of SKB be sent right now, according to the |
1040 | * congestion window rules? If so, return how many segments are allowed. | 1037 | * congestion window rules? If so, return how many segments are allowed. |
1041 | */ | 1038 | */ |
1042 | static inline unsigned int tcp_cwnd_test(struct tcp_sock *tp, struct sk_buff *skb) | 1039 | static inline unsigned int tcp_cwnd_test(struct tcp_sock *tp, |
1040 | struct sk_buff *skb) | ||
1043 | { | 1041 | { |
1044 | u32 in_flight, cwnd; | 1042 | u32 in_flight, cwnd; |
1045 | 1043 | ||
@@ -1059,13 +1057,12 @@ static inline unsigned int tcp_cwnd_test(struct tcp_sock *tp, struct sk_buff *sk | |||
1059 | /* This must be invoked the first time we consider transmitting | 1057 | /* This must be invoked the first time we consider transmitting |
1060 | * SKB onto the wire. | 1058 | * SKB onto the wire. |
1061 | */ | 1059 | */ |
1062 | static int tcp_init_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned int mss_now) | 1060 | static int tcp_init_tso_segs(struct sock *sk, struct sk_buff *skb, |
1061 | unsigned int mss_now) | ||
1063 | { | 1062 | { |
1064 | int tso_segs = tcp_skb_pcount(skb); | 1063 | int tso_segs = tcp_skb_pcount(skb); |
1065 | 1064 | ||
1066 | if (!tso_segs || | 1065 | if (!tso_segs || (tso_segs > 1 && tcp_skb_mss(skb) != mss_now)) { |
1067 | (tso_segs > 1 && | ||
1068 | tcp_skb_mss(skb) != mss_now)) { | ||
1069 | tcp_set_skb_tso_segs(sk, skb, mss_now); | 1066 | tcp_set_skb_tso_segs(sk, skb, mss_now); |
1070 | tso_segs = tcp_skb_pcount(skb); | 1067 | tso_segs = tcp_skb_pcount(skb); |
1071 | } | 1068 | } |
@@ -1085,16 +1082,13 @@ static inline int tcp_minshall_check(const struct tcp_sock *tp) | |||
1085 | * 4. Or TCP_CORK is not set, and all sent packets are ACKed. | 1082 | * 4. Or TCP_CORK is not set, and all sent packets are ACKed. |
1086 | * With Minshall's modification: all sent small packets are ACKed. | 1083 | * With Minshall's modification: all sent small packets are ACKed. |
1087 | */ | 1084 | */ |
1088 | |||
1089 | static inline int tcp_nagle_check(const struct tcp_sock *tp, | 1085 | static inline int tcp_nagle_check(const struct tcp_sock *tp, |
1090 | const struct sk_buff *skb, | 1086 | const struct sk_buff *skb, |
1091 | unsigned mss_now, int nonagle) | 1087 | unsigned mss_now, int nonagle) |
1092 | { | 1088 | { |
1093 | return (skb->len < mss_now && | 1089 | return (skb->len < mss_now && |
1094 | ((nonagle&TCP_NAGLE_CORK) || | 1090 | ((nonagle & TCP_NAGLE_CORK) || |
1095 | (!nonagle && | 1091 | (!nonagle && tp->packets_out && tcp_minshall_check(tp)))); |
1096 | tp->packets_out && | ||
1097 | tcp_minshall_check(tp)))); | ||
1098 | } | 1092 | } |
1099 | 1093 | ||
1100 | /* Return non-zero if the Nagle test allows this packet to be | 1094 | /* Return non-zero if the Nagle test allows this packet to be |
@@ -1126,7 +1120,8 @@ static inline int tcp_nagle_test(struct tcp_sock *tp, struct sk_buff *skb, | |||
1126 | } | 1120 | } |
1127 | 1121 | ||
1128 | /* Does at least the first segment of SKB fit into the send window? */ | 1122 | /* Does at least the first segment of SKB fit into the send window? */ |
1129 | static inline int tcp_snd_wnd_test(struct tcp_sock *tp, struct sk_buff *skb, unsigned int cur_mss) | 1123 | static inline int tcp_snd_wnd_test(struct tcp_sock *tp, struct sk_buff *skb, |
1124 | unsigned int cur_mss) | ||
1130 | { | 1125 | { |
1131 | u32 end_seq = TCP_SKB_CB(skb)->end_seq; | 1126 | u32 end_seq = TCP_SKB_CB(skb)->end_seq; |
1132 | 1127 | ||
@@ -1152,8 +1147,7 @@ static unsigned int tcp_snd_test(struct sock *sk, struct sk_buff *skb, | |||
1152 | return 0; | 1147 | return 0; |
1153 | 1148 | ||
1154 | cwnd_quota = tcp_cwnd_test(tp, skb); | 1149 | cwnd_quota = tcp_cwnd_test(tp, skb); |
1155 | if (cwnd_quota && | 1150 | if (cwnd_quota && !tcp_snd_wnd_test(tp, skb, cur_mss)) |
1156 | !tcp_snd_wnd_test(tp, skb, cur_mss)) | ||
1157 | cwnd_quota = 0; | 1151 | cwnd_quota = 0; |
1158 | 1152 | ||
1159 | return cwnd_quota; | 1153 | return cwnd_quota; |
@@ -1177,7 +1171,8 @@ int tcp_may_send_now(struct sock *sk) | |||
1177 | * know that all the data is in scatter-gather pages, and that the | 1171 | * know that all the data is in scatter-gather pages, and that the |
1178 | * packet has never been sent out before (and thus is not cloned). | 1172 | * packet has never been sent out before (and thus is not cloned). |
1179 | */ | 1173 | */ |
1180 | static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len, unsigned int mss_now) | 1174 | static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len, |
1175 | unsigned int mss_now) | ||
1181 | { | 1176 | { |
1182 | struct sk_buff *buff; | 1177 | struct sk_buff *buff; |
1183 | int nlen = skb->len - len; | 1178 | int nlen = skb->len - len; |
@@ -1203,7 +1198,7 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len, | |||
1203 | 1198 | ||
1204 | /* PSH and FIN should only be set in the second packet. */ | 1199 | /* PSH and FIN should only be set in the second packet. */ |
1205 | flags = TCP_SKB_CB(skb)->flags; | 1200 | flags = TCP_SKB_CB(skb)->flags; |
1206 | TCP_SKB_CB(skb)->flags = flags & ~(TCPCB_FLAG_FIN|TCPCB_FLAG_PSH); | 1201 | TCP_SKB_CB(skb)->flags = flags & ~(TCPCB_FLAG_FIN | TCPCB_FLAG_PSH); |
1207 | TCP_SKB_CB(buff)->flags = flags; | 1202 | TCP_SKB_CB(buff)->flags = flags; |
1208 | 1203 | ||
1209 | /* This packet was never sent out yet, so no SACK bits. */ | 1204 | /* This packet was never sent out yet, so no SACK bits. */ |
@@ -1247,8 +1242,7 @@ static int tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb) | |||
1247 | 1242 | ||
1248 | in_flight = tcp_packets_in_flight(tp); | 1243 | in_flight = tcp_packets_in_flight(tp); |
1249 | 1244 | ||
1250 | BUG_ON(tcp_skb_pcount(skb) <= 1 || | 1245 | BUG_ON(tcp_skb_pcount(skb) <= 1 || (tp->snd_cwnd <= in_flight)); |
1251 | (tp->snd_cwnd <= in_flight)); | ||
1252 | 1246 | ||
1253 | send_win = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; | 1247 | send_win = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; |
1254 | 1248 | ||
@@ -1281,7 +1275,7 @@ static int tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb) | |||
1281 | } | 1275 | } |
1282 | 1276 | ||
1283 | /* Ok, it looks like it is advisable to defer. */ | 1277 | /* Ok, it looks like it is advisable to defer. */ |
1284 | tp->tso_deferred = 1 | (jiffies<<1); | 1278 | tp->tso_deferred = 1 | (jiffies << 1); |
1285 | 1279 | ||
1286 | return 1; | 1280 | return 1; |
1287 | 1281 | ||
@@ -1293,7 +1287,8 @@ send_now: | |||
1293 | /* Create a new MTU probe if we are ready. | 1287 | /* Create a new MTU probe if we are ready. |
1294 | * Returns 0 if we should wait to probe (no cwnd available), | 1288 | * Returns 0 if we should wait to probe (no cwnd available), |
1295 | * 1 if a probe was sent, | 1289 | * 1 if a probe was sent, |
1296 | * -1 otherwise */ | 1290 | * -1 otherwise |
1291 | */ | ||
1297 | static int tcp_mtu_probe(struct sock *sk) | 1292 | static int tcp_mtu_probe(struct sock *sk) |
1298 | { | 1293 | { |
1299 | struct tcp_sock *tp = tcp_sk(sk); | 1294 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -1318,7 +1313,7 @@ static int tcp_mtu_probe(struct sock *sk) | |||
1318 | 1313 | ||
1319 | /* Very simple search strategy: just double the MSS. */ | 1314 | /* Very simple search strategy: just double the MSS. */ |
1320 | mss_now = tcp_current_mss(sk, 0); | 1315 | mss_now = tcp_current_mss(sk, 0); |
1321 | probe_size = 2*tp->mss_cache; | 1316 | probe_size = 2 * tp->mss_cache; |
1322 | size_needed = probe_size + (tp->reordering + 1) * tp->mss_cache; | 1317 | size_needed = probe_size + (tp->reordering + 1) * tp->mss_cache; |
1323 | if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high)) { | 1318 | if (probe_size > tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_high)) { |
1324 | /* TODO: set timer for probe_converge_event */ | 1319 | /* TODO: set timer for probe_converge_event */ |
@@ -1366,7 +1361,8 @@ static int tcp_mtu_probe(struct sock *sk) | |||
1366 | skb_copy_bits(skb, 0, skb_put(nskb, copy), copy); | 1361 | skb_copy_bits(skb, 0, skb_put(nskb, copy), copy); |
1367 | else | 1362 | else |
1368 | nskb->csum = skb_copy_and_csum_bits(skb, 0, | 1363 | nskb->csum = skb_copy_and_csum_bits(skb, 0, |
1369 | skb_put(nskb, copy), copy, nskb->csum); | 1364 | skb_put(nskb, copy), |
1365 | copy, nskb->csum); | ||
1370 | 1366 | ||
1371 | if (skb->len <= copy) { | 1367 | if (skb->len <= copy) { |
1372 | /* We've eaten all the data from this skb. | 1368 | /* We've eaten all the data from this skb. |
@@ -1380,7 +1376,8 @@ static int tcp_mtu_probe(struct sock *sk) | |||
1380 | if (!skb_shinfo(skb)->nr_frags) { | 1376 | if (!skb_shinfo(skb)->nr_frags) { |
1381 | skb_pull(skb, copy); | 1377 | skb_pull(skb, copy); |
1382 | if (skb->ip_summed != CHECKSUM_PARTIAL) | 1378 | if (skb->ip_summed != CHECKSUM_PARTIAL) |
1383 | skb->csum = csum_partial(skb->data, skb->len, 0); | 1379 | skb->csum = csum_partial(skb->data, |
1380 | skb->len, 0); | ||
1384 | } else { | 1381 | } else { |
1385 | __pskb_trim_head(skb, copy); | 1382 | __pskb_trim_head(skb, copy); |
1386 | tcp_set_skb_tso_segs(sk, skb, mss_now); | 1383 | tcp_set_skb_tso_segs(sk, skb, mss_now); |
@@ -1400,7 +1397,7 @@ static int tcp_mtu_probe(struct sock *sk) | |||
1400 | TCP_SKB_CB(nskb)->when = tcp_time_stamp; | 1397 | TCP_SKB_CB(nskb)->when = tcp_time_stamp; |
1401 | if (!tcp_transmit_skb(sk, nskb, 1, GFP_ATOMIC)) { | 1398 | if (!tcp_transmit_skb(sk, nskb, 1, GFP_ATOMIC)) { |
1402 | /* Decrement cwnd here because we are sending | 1399 | /* Decrement cwnd here because we are sending |
1403 | * effectively two packets. */ | 1400 | * effectively two packets. */ |
1404 | tp->snd_cwnd--; | 1401 | tp->snd_cwnd--; |
1405 | tcp_event_new_data_sent(sk, nskb); | 1402 | tcp_event_new_data_sent(sk, nskb); |
1406 | 1403 | ||
@@ -1414,7 +1411,6 @@ static int tcp_mtu_probe(struct sock *sk) | |||
1414 | return -1; | 1411 | return -1; |
1415 | } | 1412 | } |
1416 | 1413 | ||
1417 | |||
1418 | /* This routine writes packets to the network. It advances the | 1414 | /* This routine writes packets to the network. It advances the |
1419 | * send_head. This happens as incoming acks open up the remote | 1415 | * send_head. This happens as incoming acks open up the remote |
1420 | * window for us. | 1416 | * window for us. |
@@ -1626,7 +1622,8 @@ u32 __tcp_select_window(struct sock *sk) | |||
1626 | icsk->icsk_ack.quick = 0; | 1622 | icsk->icsk_ack.quick = 0; |
1627 | 1623 | ||
1628 | if (tcp_memory_pressure) | 1624 | if (tcp_memory_pressure) |
1629 | tp->rcv_ssthresh = min(tp->rcv_ssthresh, 4U*tp->advmss); | 1625 | tp->rcv_ssthresh = min(tp->rcv_ssthresh, |
1626 | 4U * tp->advmss); | ||
1630 | 1627 | ||
1631 | if (free_space < mss) | 1628 | if (free_space < mss) |
1632 | return 0; | 1629 | return 0; |
@@ -1659,7 +1656,7 @@ u32 __tcp_select_window(struct sock *sk) | |||
1659 | * is too small. | 1656 | * is too small. |
1660 | */ | 1657 | */ |
1661 | if (window <= free_space - mss || window > free_space) | 1658 | if (window <= free_space - mss || window > free_space) |
1662 | window = (free_space/mss)*mss; | 1659 | window = (free_space / mss) * mss; |
1663 | else if (mss == full_space && | 1660 | else if (mss == full_space && |
1664 | free_space > window + (full_space >> 1)) | 1661 | free_space > window + (full_space >> 1)) |
1665 | window = free_space; | 1662 | window = free_space; |
@@ -1669,7 +1666,8 @@ u32 __tcp_select_window(struct sock *sk) | |||
1669 | } | 1666 | } |
1670 | 1667 | ||
1671 | /* Attempt to collapse two adjacent SKB's during retransmission. */ | 1668 | /* Attempt to collapse two adjacent SKB's during retransmission. */ |
1672 | static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int mss_now) | 1669 | static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, |
1670 | int mss_now) | ||
1673 | { | 1671 | { |
1674 | struct tcp_sock *tp = tcp_sk(sk); | 1672 | struct tcp_sock *tp = tcp_sk(sk); |
1675 | struct sk_buff *next_skb = tcp_write_queue_next(sk, skb); | 1673 | struct sk_buff *next_skb = tcp_write_queue_next(sk, skb); |
@@ -1762,12 +1760,12 @@ void tcp_simple_retransmit(struct sock *sk) | |||
1762 | if (skb == tcp_send_head(sk)) | 1760 | if (skb == tcp_send_head(sk)) |
1763 | break; | 1761 | break; |
1764 | if (skb->len > mss && | 1762 | if (skb->len > mss && |
1765 | !(TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_ACKED)) { | 1763 | !(TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)) { |
1766 | if (TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_RETRANS) { | 1764 | if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS) { |
1767 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; | 1765 | TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; |
1768 | tp->retrans_out -= tcp_skb_pcount(skb); | 1766 | tp->retrans_out -= tcp_skb_pcount(skb); |
1769 | } | 1767 | } |
1770 | if (!(TCP_SKB_CB(skb)->sacked&TCPCB_LOST)) { | 1768 | if (!(TCP_SKB_CB(skb)->sacked & TCPCB_LOST)) { |
1771 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; | 1769 | TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; |
1772 | tp->lost_out += tcp_skb_pcount(skb); | 1770 | tp->lost_out += tcp_skb_pcount(skb); |
1773 | lost = 1; | 1771 | lost = 1; |
@@ -1846,8 +1844,10 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) | |||
1846 | (skb->len < (cur_mss >> 1)) && | 1844 | (skb->len < (cur_mss >> 1)) && |
1847 | (tcp_write_queue_next(sk, skb) != tcp_send_head(sk)) && | 1845 | (tcp_write_queue_next(sk, skb) != tcp_send_head(sk)) && |
1848 | (!tcp_skb_is_last(sk, skb)) && | 1846 | (!tcp_skb_is_last(sk, skb)) && |
1849 | (skb_shinfo(skb)->nr_frags == 0 && skb_shinfo(tcp_write_queue_next(sk, skb))->nr_frags == 0) && | 1847 | (skb_shinfo(skb)->nr_frags == 0 && |
1850 | (tcp_skb_pcount(skb) == 1 && tcp_skb_pcount(tcp_write_queue_next(sk, skb)) == 1) && | 1848 | skb_shinfo(tcp_write_queue_next(sk, skb))->nr_frags == 0) && |
1849 | (tcp_skb_pcount(skb) == 1 && | ||
1850 | tcp_skb_pcount(tcp_write_queue_next(sk, skb)) == 1) && | ||
1851 | (sysctl_tcp_retrans_collapse != 0)) | 1851 | (sysctl_tcp_retrans_collapse != 0)) |
1852 | tcp_retrans_try_collapse(sk, skb, cur_mss); | 1852 | tcp_retrans_try_collapse(sk, skb, cur_mss); |
1853 | 1853 | ||
@@ -1885,7 +1885,7 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) | |||
1885 | tp->total_retrans++; | 1885 | tp->total_retrans++; |
1886 | 1886 | ||
1887 | #if FASTRETRANS_DEBUG > 0 | 1887 | #if FASTRETRANS_DEBUG > 0 |
1888 | if (TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_RETRANS) { | 1888 | if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS) { |
1889 | if (net_ratelimit()) | 1889 | if (net_ratelimit()) |
1890 | printk(KERN_DEBUG "retrans_out leaked.\n"); | 1890 | printk(KERN_DEBUG "retrans_out leaked.\n"); |
1891 | } | 1891 | } |
@@ -1927,7 +1927,7 @@ void tcp_xmit_retransmit_queue(struct sock *sk) | |||
1927 | if (tp->retransmit_skb_hint) { | 1927 | if (tp->retransmit_skb_hint) { |
1928 | skb = tp->retransmit_skb_hint; | 1928 | skb = tp->retransmit_skb_hint; |
1929 | packet_cnt = tp->retransmit_cnt_hint; | 1929 | packet_cnt = tp->retransmit_cnt_hint; |
1930 | }else{ | 1930 | } else { |
1931 | skb = tcp_write_queue_head(sk); | 1931 | skb = tcp_write_queue_head(sk); |
1932 | packet_cnt = 0; | 1932 | packet_cnt = 0; |
1933 | } | 1933 | } |
@@ -1954,7 +1954,7 @@ void tcp_xmit_retransmit_queue(struct sock *sk) | |||
1954 | return; | 1954 | return; |
1955 | 1955 | ||
1956 | if (sacked & TCPCB_LOST) { | 1956 | if (sacked & TCPCB_LOST) { |
1957 | if (!(sacked&(TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS))) { | 1957 | if (!(sacked & (TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS))) { |
1958 | if (tcp_retransmit_skb(sk, skb)) { | 1958 | if (tcp_retransmit_skb(sk, skb)) { |
1959 | tp->retransmit_skb_hint = NULL; | 1959 | tp->retransmit_skb_hint = NULL; |
1960 | return; | 1960 | return; |
@@ -2036,7 +2036,6 @@ void tcp_xmit_retransmit_queue(struct sock *sk) | |||
2036 | } | 2036 | } |
2037 | } | 2037 | } |
2038 | 2038 | ||
2039 | |||
2040 | /* Send a fin. The caller locks the socket for us. This cannot be | 2039 | /* Send a fin. The caller locks the socket for us. This cannot be |
2041 | * allowed to fail queueing a FIN frame under any circumstances. | 2040 | * allowed to fail queueing a FIN frame under any circumstances. |
2042 | */ | 2041 | */ |
@@ -2122,14 +2121,14 @@ void tcp_send_active_reset(struct sock *sk, gfp_t priority) | |||
2122 | */ | 2121 | */ |
2123 | int tcp_send_synack(struct sock *sk) | 2122 | int tcp_send_synack(struct sock *sk) |
2124 | { | 2123 | { |
2125 | struct sk_buff* skb; | 2124 | struct sk_buff *skb; |
2126 | 2125 | ||
2127 | skb = tcp_write_queue_head(sk); | 2126 | skb = tcp_write_queue_head(sk); |
2128 | if (skb == NULL || !(TCP_SKB_CB(skb)->flags&TCPCB_FLAG_SYN)) { | 2127 | if (skb == NULL || !(TCP_SKB_CB(skb)->flags & TCPCB_FLAG_SYN)) { |
2129 | printk(KERN_DEBUG "tcp_send_synack: wrong queue state\n"); | 2128 | printk(KERN_DEBUG "tcp_send_synack: wrong queue state\n"); |
2130 | return -EFAULT; | 2129 | return -EFAULT; |
2131 | } | 2130 | } |
2132 | if (!(TCP_SKB_CB(skb)->flags&TCPCB_FLAG_ACK)) { | 2131 | if (!(TCP_SKB_CB(skb)->flags & TCPCB_FLAG_ACK)) { |
2133 | if (skb_cloned(skb)) { | 2132 | if (skb_cloned(skb)) { |
2134 | struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC); | 2133 | struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC); |
2135 | if (nskb == NULL) | 2134 | if (nskb == NULL) |
@@ -2153,8 +2152,8 @@ int tcp_send_synack(struct sock *sk) | |||
2153 | /* | 2152 | /* |
2154 | * Prepare a SYN-ACK. | 2153 | * Prepare a SYN-ACK. |
2155 | */ | 2154 | */ |
2156 | struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst, | 2155 | struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst, |
2157 | struct request_sock *req) | 2156 | struct request_sock *req) |
2158 | { | 2157 | { |
2159 | struct inet_request_sock *ireq = inet_rsk(req); | 2158 | struct inet_request_sock *ireq = inet_rsk(req); |
2160 | struct tcp_sock *tp = tcp_sk(sk); | 2159 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -2372,9 +2371,10 @@ void tcp_send_delayed_ack(struct sock *sk) | |||
2372 | 2371 | ||
2373 | if (ato > TCP_DELACK_MIN) { | 2372 | if (ato > TCP_DELACK_MIN) { |
2374 | const struct tcp_sock *tp = tcp_sk(sk); | 2373 | const struct tcp_sock *tp = tcp_sk(sk); |
2375 | int max_ato = HZ/2; | 2374 | int max_ato = HZ / 2; |
2376 | 2375 | ||
2377 | if (icsk->icsk_ack.pingpong || (icsk->icsk_ack.pending & ICSK_ACK_PUSHED)) | 2376 | if (icsk->icsk_ack.pingpong || |
2377 | (icsk->icsk_ack.pending & ICSK_ACK_PUSHED)) | ||
2378 | max_ato = TCP_DELACK_MAX; | 2378 | max_ato = TCP_DELACK_MAX; |
2379 | 2379 | ||
2380 | /* Slow path, intersegment interval is "high". */ | 2380 | /* Slow path, intersegment interval is "high". */ |
@@ -2384,7 +2384,7 @@ void tcp_send_delayed_ack(struct sock *sk) | |||
2384 | * directly. | 2384 | * directly. |
2385 | */ | 2385 | */ |
2386 | if (tp->srtt) { | 2386 | if (tp->srtt) { |
2387 | int rtt = max(tp->srtt>>3, TCP_DELACK_MIN); | 2387 | int rtt = max(tp->srtt >> 3, TCP_DELACK_MIN); |
2388 | 2388 | ||
2389 | if (rtt < max_ato) | 2389 | if (rtt < max_ato) |
2390 | max_ato = rtt; | 2390 | max_ato = rtt; |