aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_output.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/tcp_output.c')
-rw-r--r--net/ipv4/tcp_output.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index bdd71db8bf90..9a253faefc81 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -43,24 +43,24 @@
43#include <linux/smp_lock.h> 43#include <linux/smp_lock.h>
44 44
45/* People can turn this off for buggy TCP's found in printers etc. */ 45/* People can turn this off for buggy TCP's found in printers etc. */
46int sysctl_tcp_retrans_collapse = 1; 46int sysctl_tcp_retrans_collapse __read_mostly = 1;
47 47
48/* People can turn this on to work with those rare, broken TCPs that 48/* People can turn this on to work with those rare, broken TCPs that
49 * interpret the window field as a signed quantity. 49 * interpret the window field as a signed quantity.
50 */ 50 */
51int sysctl_tcp_workaround_signed_windows = 0; 51int sysctl_tcp_workaround_signed_windows __read_mostly = 0;
52 52
53/* This limits the percentage of the congestion window which we 53/* This limits the percentage of the congestion window which we
54 * will allow a single TSO frame to consume. Building TSO frames 54 * will allow a single TSO frame to consume. Building TSO frames
55 * which are too large can cause TCP streams to be bursty. 55 * which are too large can cause TCP streams to be bursty.
56 */ 56 */
57int sysctl_tcp_tso_win_divisor = 3; 57int sysctl_tcp_tso_win_divisor __read_mostly = 3;
58 58
59int sysctl_tcp_mtu_probing = 0; 59int sysctl_tcp_mtu_probing __read_mostly = 0;
60int sysctl_tcp_base_mss = 512; 60int sysctl_tcp_base_mss __read_mostly = 512;
61 61
62/* By default, RFC2861 behavior. */ 62/* By default, RFC2861 behavior. */
63int sysctl_tcp_slow_start_after_idle = 1; 63int sysctl_tcp_slow_start_after_idle __read_mostly = 1;
64 64
65static void update_send_head(struct sock *sk, struct tcp_sock *tp, 65static void update_send_head(struct sock *sk, struct tcp_sock *tp,
66 struct sk_buff *skb) 66 struct sk_buff *skb)
@@ -201,6 +201,7 @@ void tcp_select_initial_window(int __space, __u32 mss,
201 * See RFC1323 for an explanation of the limit to 14 201 * See RFC1323 for an explanation of the limit to 14
202 */ 202 */
203 space = max_t(u32, sysctl_tcp_rmem[2], sysctl_rmem_max); 203 space = max_t(u32, sysctl_tcp_rmem[2], sysctl_rmem_max);
204 space = min_t(u32, space, *window_clamp);
204 while (space > 65535 && (*rcv_wscale) < 14) { 205 while (space > 65535 && (*rcv_wscale) < 14) {
205 space >>= 1; 206 space >>= 1;
206 (*rcv_wscale)++; 207 (*rcv_wscale)++;
@@ -268,7 +269,7 @@ static u16 tcp_select_window(struct sock *sk)
268 return new_win; 269 return new_win;
269} 270}
270 271
271static void tcp_build_and_update_options(__u32 *ptr, struct tcp_sock *tp, 272static void tcp_build_and_update_options(__be32 *ptr, struct tcp_sock *tp,
272 __u32 tstamp) 273 __u32 tstamp)
273{ 274{
274 if (tp->rx_opt.tstamp_ok) { 275 if (tp->rx_opt.tstamp_ok) {
@@ -304,7 +305,7 @@ static void tcp_build_and_update_options(__u32 *ptr, struct tcp_sock *tp,
304 * MAX_SYN_SIZE to match the new maximum number of options that you 305 * MAX_SYN_SIZE to match the new maximum number of options that you
305 * can generate. 306 * can generate.
306 */ 307 */
307static void tcp_syn_build_options(__u32 *ptr, int mss, int ts, int sack, 308static void tcp_syn_build_options(__be32 *ptr, int mss, int ts, int sack,
308 int offer_wscale, int wscale, __u32 tstamp, 309 int offer_wscale, int wscale, __u32 tstamp,
309 __u32 ts_recent) 310 __u32 ts_recent)
310{ 311{
@@ -423,7 +424,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
423 th->dest = inet->dport; 424 th->dest = inet->dport;
424 th->seq = htonl(tcb->seq); 425 th->seq = htonl(tcb->seq);
425 th->ack_seq = htonl(tp->rcv_nxt); 426 th->ack_seq = htonl(tp->rcv_nxt);
426 *(((__u16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) | 427 *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) |
427 tcb->flags); 428 tcb->flags);
428 429
429 if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) { 430 if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) {
@@ -444,7 +445,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
444 } 445 }
445 446
446 if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) { 447 if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) {
447 tcp_syn_build_options((__u32 *)(th + 1), 448 tcp_syn_build_options((__be32 *)(th + 1),
448 tcp_advertise_mss(sk), 449 tcp_advertise_mss(sk),
449 (sysctl_flags & SYSCTL_FLAG_TSTAMPS), 450 (sysctl_flags & SYSCTL_FLAG_TSTAMPS),
450 (sysctl_flags & SYSCTL_FLAG_SACK), 451 (sysctl_flags & SYSCTL_FLAG_SACK),
@@ -453,7 +454,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
453 tcb->when, 454 tcb->when,
454 tp->rx_opt.ts_recent); 455 tp->rx_opt.ts_recent);
455 } else { 456 } else {
456 tcp_build_and_update_options((__u32 *)(th + 1), 457 tcp_build_and_update_options((__be32 *)(th + 1),
457 tp, tcb->when); 458 tp, tcb->when);
458 TCP_ECN_send(sk, tp, skb, tcp_header_size); 459 TCP_ECN_send(sk, tp, skb, tcp_header_size);
459 } 460 }
@@ -466,7 +467,8 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
466 if (skb->len != tcp_header_size) 467 if (skb->len != tcp_header_size)
467 tcp_event_data_sent(tp, skb, sk); 468 tcp_event_data_sent(tp, skb, sk);
468 469
469 TCP_INC_STATS(TCP_MIB_OUTSEGS); 470 if (after(tcb->end_seq, tp->snd_nxt) || tcb->seq == tcb->end_seq)
471 TCP_INC_STATS(TCP_MIB_OUTSEGS);
470 472
471 err = icsk->icsk_af_ops->queue_xmit(skb, 0); 473 err = icsk->icsk_af_ops->queue_xmit(skb, 0);
472 if (likely(err <= 0)) 474 if (likely(err <= 0))
@@ -510,8 +512,7 @@ static void tcp_queue_skb(struct sock *sk, struct sk_buff *skb)
510 512
511static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned int mss_now) 513static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned int mss_now)
512{ 514{
513 if (skb->len <= mss_now || 515 if (skb->len <= mss_now || !sk_can_gso(sk)) {
514 !(sk->sk_route_caps & NETIF_F_TSO)) {
515 /* Avoid the costly divide in the normal 516 /* Avoid the costly divide in the normal
516 * non-TSO case. 517 * non-TSO case.
517 */ 518 */
@@ -525,7 +526,7 @@ static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned
525 factor /= mss_now; 526 factor /= mss_now;
526 skb_shinfo(skb)->gso_segs = factor; 527 skb_shinfo(skb)->gso_segs = factor;
527 skb_shinfo(skb)->gso_size = mss_now; 528 skb_shinfo(skb)->gso_size = mss_now;
528 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; 529 skb_shinfo(skb)->gso_type = sk->sk_gso_type;
529 } 530 }
530} 531}
531 532
@@ -576,7 +577,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
576 TCP_SKB_CB(buff)->sacked = TCP_SKB_CB(skb)->sacked; 577 TCP_SKB_CB(buff)->sacked = TCP_SKB_CB(skb)->sacked;
577 TCP_SKB_CB(skb)->sacked &= ~TCPCB_AT_TAIL; 578 TCP_SKB_CB(skb)->sacked &= ~TCPCB_AT_TAIL;
578 579
579 if (!skb_shinfo(skb)->nr_frags && skb->ip_summed != CHECKSUM_HW) { 580 if (!skb_shinfo(skb)->nr_frags && skb->ip_summed != CHECKSUM_PARTIAL) {
580 /* Copy and checksum data tail into the new buffer. */ 581 /* Copy and checksum data tail into the new buffer. */
581 buff->csum = csum_partial_copy_nocheck(skb->data + len, skb_put(buff, nsize), 582 buff->csum = csum_partial_copy_nocheck(skb->data + len, skb_put(buff, nsize),
582 nsize, 0); 583 nsize, 0);
@@ -585,7 +586,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
585 586
586 skb->csum = csum_block_sub(skb->csum, buff->csum, len); 587 skb->csum = csum_block_sub(skb->csum, buff->csum, len);
587 } else { 588 } else {
588 skb->ip_summed = CHECKSUM_HW; 589 skb->ip_summed = CHECKSUM_PARTIAL;
589 skb_split(skb, buff, len); 590 skb_split(skb, buff, len);
590 } 591 }
591 592
@@ -688,7 +689,7 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
688 __pskb_trim_head(skb, len - skb_headlen(skb)); 689 __pskb_trim_head(skb, len - skb_headlen(skb));
689 690
690 TCP_SKB_CB(skb)->seq += len; 691 TCP_SKB_CB(skb)->seq += len;
691 skb->ip_summed = CHECKSUM_HW; 692 skb->ip_summed = CHECKSUM_PARTIAL;
692 693
693 skb->truesize -= len; 694 skb->truesize -= len;
694 sk->sk_wmem_queued -= len; 695 sk->sk_wmem_queued -= len;
@@ -824,9 +825,7 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed)
824 825
825 mss_now = tp->mss_cache; 826 mss_now = tp->mss_cache;
826 827
827 if (large_allowed && 828 if (large_allowed && sk_can_gso(sk) && !tp->urg_mode)
828 (sk->sk_route_caps & NETIF_F_TSO) &&
829 !tp->urg_mode)
830 doing_tso = 1; 829 doing_tso = 1;
831 830
832 if (dst) { 831 if (dst) {
@@ -1063,7 +1062,7 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len,
1063 /* This packet was never sent out yet, so no SACK bits. */ 1062 /* This packet was never sent out yet, so no SACK bits. */
1064 TCP_SKB_CB(buff)->sacked = 0; 1063 TCP_SKB_CB(buff)->sacked = 0;
1065 1064
1066 buff->ip_summed = skb->ip_summed = CHECKSUM_HW; 1065 buff->ip_summed = skb->ip_summed = CHECKSUM_PARTIAL;
1067 skb_split(skb, buff, len); 1066 skb_split(skb, buff, len);
1068 1067
1069 /* Fix up tso_factor for both original and new SKB. */ 1068 /* Fix up tso_factor for both original and new SKB. */
@@ -1207,8 +1206,7 @@ static int tcp_mtu_probe(struct sock *sk)
1207 TCP_SKB_CB(nskb)->flags = TCPCB_FLAG_ACK; 1206 TCP_SKB_CB(nskb)->flags = TCPCB_FLAG_ACK;
1208 TCP_SKB_CB(nskb)->sacked = 0; 1207 TCP_SKB_CB(nskb)->sacked = 0;
1209 nskb->csum = 0; 1208 nskb->csum = 0;
1210 if (skb->ip_summed == CHECKSUM_HW) 1209 nskb->ip_summed = skb->ip_summed;
1211 nskb->ip_summed = CHECKSUM_HW;
1212 1210
1213 len = 0; 1211 len = 0;
1214 while (len < probe_size) { 1212 while (len < probe_size) {
@@ -1232,7 +1230,7 @@ static int tcp_mtu_probe(struct sock *sk)
1232 ~(TCPCB_FLAG_FIN|TCPCB_FLAG_PSH); 1230 ~(TCPCB_FLAG_FIN|TCPCB_FLAG_PSH);
1233 if (!skb_shinfo(skb)->nr_frags) { 1231 if (!skb_shinfo(skb)->nr_frags) {
1234 skb_pull(skb, copy); 1232 skb_pull(skb, copy);
1235 if (skb->ip_summed != CHECKSUM_HW) 1233 if (skb->ip_summed != CHECKSUM_PARTIAL)
1236 skb->csum = csum_partial(skb->data, skb->len, 0); 1234 skb->csum = csum_partial(skb->data, skb->len, 0);
1237 } else { 1235 } else {
1238 __pskb_trim_head(skb, copy); 1236 __pskb_trim_head(skb, copy);
@@ -1573,10 +1571,9 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int m
1573 1571
1574 memcpy(skb_put(skb, next_skb_size), next_skb->data, next_skb_size); 1572 memcpy(skb_put(skb, next_skb_size), next_skb->data, next_skb_size);
1575 1573
1576 if (next_skb->ip_summed == CHECKSUM_HW) 1574 skb->ip_summed = next_skb->ip_summed;
1577 skb->ip_summed = CHECKSUM_HW;
1578 1575
1579 if (skb->ip_summed != CHECKSUM_HW) 1576 if (skb->ip_summed != CHECKSUM_PARTIAL)
1580 skb->csum = csum_block_add(skb->csum, next_skb->csum, skb_size); 1577 skb->csum = csum_block_add(skb->csum, next_skb->csum, skb_size);
1581 1578
1582 /* Update sequence range on original skb. */ 1579 /* Update sequence range on original skb. */
@@ -2044,8 +2041,6 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
2044 memset(th, 0, sizeof(struct tcphdr)); 2041 memset(th, 0, sizeof(struct tcphdr));
2045 th->syn = 1; 2042 th->syn = 1;
2046 th->ack = 1; 2043 th->ack = 1;
2047 if (dst->dev->features&NETIF_F_TSO)
2048 ireq->ecn_ok = 0;
2049 TCP_ECN_make_synack(req, th); 2044 TCP_ECN_make_synack(req, th);
2050 th->source = inet_sk(sk)->sport; 2045 th->source = inet_sk(sk)->sport;
2051 th->dest = ireq->rmt_port; 2046 th->dest = ireq->rmt_port;
@@ -2075,7 +2070,7 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
2075 th->window = htons(req->rcv_wnd); 2070 th->window = htons(req->rcv_wnd);
2076 2071
2077 TCP_SKB_CB(skb)->when = tcp_time_stamp; 2072 TCP_SKB_CB(skb)->when = tcp_time_stamp;
2078 tcp_syn_build_options((__u32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok, 2073 tcp_syn_build_options((__be32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok,
2079 ireq->sack_ok, ireq->wscale_ok, ireq->rcv_wscale, 2074 ireq->sack_ok, ireq->wscale_ok, ireq->rcv_wscale,
2080 TCP_SKB_CB(skb)->when, 2075 TCP_SKB_CB(skb)->when,
2081 req->ts_recent); 2076 req->ts_recent);
@@ -2162,10 +2157,9 @@ int tcp_connect(struct sock *sk)
2162 skb_shinfo(buff)->gso_size = 0; 2157 skb_shinfo(buff)->gso_size = 0;
2163 skb_shinfo(buff)->gso_type = 0; 2158 skb_shinfo(buff)->gso_type = 0;
2164 buff->csum = 0; 2159 buff->csum = 0;
2160 tp->snd_nxt = tp->write_seq;
2165 TCP_SKB_CB(buff)->seq = tp->write_seq++; 2161 TCP_SKB_CB(buff)->seq = tp->write_seq++;
2166 TCP_SKB_CB(buff)->end_seq = tp->write_seq; 2162 TCP_SKB_CB(buff)->end_seq = tp->write_seq;
2167 tp->snd_nxt = tp->write_seq;
2168 tp->pushed_seq = tp->write_seq;
2169 2163
2170 /* Send it off. */ 2164 /* Send it off. */
2171 TCP_SKB_CB(buff)->when = tcp_time_stamp; 2165 TCP_SKB_CB(buff)->when = tcp_time_stamp;
@@ -2175,6 +2169,12 @@ int tcp_connect(struct sock *sk)
2175 sk_charge_skb(sk, buff); 2169 sk_charge_skb(sk, buff);
2176 tp->packets_out += tcp_skb_pcount(buff); 2170 tp->packets_out += tcp_skb_pcount(buff);
2177 tcp_transmit_skb(sk, buff, 1, GFP_KERNEL); 2171 tcp_transmit_skb(sk, buff, 1, GFP_KERNEL);
2172
2173 /* We change tp->snd_nxt after the tcp_transmit_skb() call
2174 * in order to make this packet get counted in tcpOutSegs.
2175 */
2176 tp->snd_nxt = tp->write_seq;
2177 tp->pushed_seq = tp->write_seq;
2178 TCP_INC_STATS(TCP_MIB_ACTIVEOPENS); 2178 TCP_INC_STATS(TCP_MIB_ACTIVEOPENS);
2179 2179
2180 /* Timer for repeating the SYN until an answer. */ 2180 /* Timer for repeating the SYN until an answer. */