diff options
Diffstat (limited to 'net/ipv4/tcp_output.c')
-rw-r--r-- | net/ipv4/tcp_output.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 5d451593ef16..b44cf81d8178 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -314,7 +314,7 @@ static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb) | |||
314 | struct tcp_sock *tp = tcp_sk(sk); | 314 | struct tcp_sock *tp = tcp_sk(sk); |
315 | 315 | ||
316 | tp->ecn_flags = 0; | 316 | tp->ecn_flags = 0; |
317 | if (sysctl_tcp_ecn == 1) { | 317 | if (sock_net(sk)->ipv4.sysctl_tcp_ecn == 1) { |
318 | TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ECE | TCPHDR_CWR; | 318 | TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ECE | TCPHDR_CWR; |
319 | tp->ecn_flags = TCP_ECN_OK; | 319 | tp->ecn_flags = TCP_ECN_OK; |
320 | } | 320 | } |
@@ -622,7 +622,7 @@ static unsigned int tcp_syn_options(struct sock *sk, struct sk_buff *skb, | |||
622 | 622 | ||
623 | if (likely(sysctl_tcp_timestamps && *md5 == NULL)) { | 623 | if (likely(sysctl_tcp_timestamps && *md5 == NULL)) { |
624 | opts->options |= OPTION_TS; | 624 | opts->options |= OPTION_TS; |
625 | opts->tsval = TCP_SKB_CB(skb)->when; | 625 | opts->tsval = TCP_SKB_CB(skb)->when + tp->tsoffset; |
626 | opts->tsecr = tp->rx_opt.ts_recent; | 626 | opts->tsecr = tp->rx_opt.ts_recent; |
627 | remaining -= TCPOLEN_TSTAMP_ALIGNED; | 627 | remaining -= TCPOLEN_TSTAMP_ALIGNED; |
628 | } | 628 | } |
@@ -806,7 +806,7 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb | |||
806 | 806 | ||
807 | if (likely(tp->rx_opt.tstamp_ok)) { | 807 | if (likely(tp->rx_opt.tstamp_ok)) { |
808 | opts->options |= OPTION_TS; | 808 | opts->options |= OPTION_TS; |
809 | opts->tsval = tcb ? tcb->when : 0; | 809 | opts->tsval = tcb ? tcb->when + tp->tsoffset : 0; |
810 | opts->tsecr = tp->rx_opt.ts_recent; | 810 | opts->tsecr = tp->rx_opt.ts_recent; |
811 | size += TCPOLEN_TSTAMP_ALIGNED; | 811 | size += TCPOLEN_TSTAMP_ALIGNED; |
812 | } | 812 | } |
@@ -1298,7 +1298,6 @@ static void __pskb_trim_head(struct sk_buff *skb, int len) | |||
1298 | eat = min_t(int, len, skb_headlen(skb)); | 1298 | eat = min_t(int, len, skb_headlen(skb)); |
1299 | if (eat) { | 1299 | if (eat) { |
1300 | __skb_pull(skb, eat); | 1300 | __skb_pull(skb, eat); |
1301 | skb->avail_size -= eat; | ||
1302 | len -= eat; | 1301 | len -= eat; |
1303 | if (!len) | 1302 | if (!len) |
1304 | return; | 1303 | return; |
@@ -1331,7 +1330,7 @@ static void __pskb_trim_head(struct sk_buff *skb, int len) | |||
1331 | /* Remove acked data from a packet in the transmit queue. */ | 1330 | /* Remove acked data from a packet in the transmit queue. */ |
1332 | int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) | 1331 | int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) |
1333 | { | 1332 | { |
1334 | if (skb_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) | 1333 | if (skb_unclone(skb, GFP_ATOMIC)) |
1335 | return -ENOMEM; | 1334 | return -ENOMEM; |
1336 | 1335 | ||
1337 | __pskb_trim_head(skb, len); | 1336 | __pskb_trim_head(skb, len); |
@@ -1351,8 +1350,8 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) | |||
1351 | return 0; | 1350 | return 0; |
1352 | } | 1351 | } |
1353 | 1352 | ||
1354 | /* Calculate MSS. Not accounting for SACKs here. */ | 1353 | /* Calculate MSS not accounting any TCP options. */ |
1355 | int tcp_mtu_to_mss(struct sock *sk, int pmtu) | 1354 | static inline int __tcp_mtu_to_mss(struct sock *sk, int pmtu) |
1356 | { | 1355 | { |
1357 | const struct tcp_sock *tp = tcp_sk(sk); | 1356 | const struct tcp_sock *tp = tcp_sk(sk); |
1358 | const struct inet_connection_sock *icsk = inet_csk(sk); | 1357 | const struct inet_connection_sock *icsk = inet_csk(sk); |
@@ -1381,13 +1380,17 @@ int tcp_mtu_to_mss(struct sock *sk, int pmtu) | |||
1381 | /* Then reserve room for full set of TCP options and 8 bytes of data */ | 1380 | /* Then reserve room for full set of TCP options and 8 bytes of data */ |
1382 | if (mss_now < 48) | 1381 | if (mss_now < 48) |
1383 | mss_now = 48; | 1382 | mss_now = 48; |
1384 | |||
1385 | /* Now subtract TCP options size, not including SACKs */ | ||
1386 | mss_now -= tp->tcp_header_len - sizeof(struct tcphdr); | ||
1387 | |||
1388 | return mss_now; | 1383 | return mss_now; |
1389 | } | 1384 | } |
1390 | 1385 | ||
1386 | /* Calculate MSS. Not accounting for SACKs here. */ | ||
1387 | int tcp_mtu_to_mss(struct sock *sk, int pmtu) | ||
1388 | { | ||
1389 | /* Subtract TCP options size, not including SACKs */ | ||
1390 | return __tcp_mtu_to_mss(sk, pmtu) - | ||
1391 | (tcp_sk(sk)->tcp_header_len - sizeof(struct tcphdr)); | ||
1392 | } | ||
1393 | |||
1391 | /* Inverse of above */ | 1394 | /* Inverse of above */ |
1392 | int tcp_mss_to_mtu(struct sock *sk, int mss) | 1395 | int tcp_mss_to_mtu(struct sock *sk, int mss) |
1393 | { | 1396 | { |
@@ -1806,8 +1809,11 @@ static bool tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb) | |||
1806 | goto send_now; | 1809 | goto send_now; |
1807 | } | 1810 | } |
1808 | 1811 | ||
1809 | /* Ok, it looks like it is advisable to defer. */ | 1812 | /* Ok, it looks like it is advisable to defer. |
1810 | tp->tso_deferred = 1 | (jiffies << 1); | 1813 | * Do not rearm the timer if already set to not break TCP ACK clocking. |
1814 | */ | ||
1815 | if (!tp->tso_deferred) | ||
1816 | tp->tso_deferred = 1 | (jiffies << 1); | ||
1811 | 1817 | ||
1812 | return true; | 1818 | return true; |
1813 | 1819 | ||
@@ -2703,6 +2709,7 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst, | |||
2703 | skb_reserve(skb, MAX_TCP_HEADER); | 2709 | skb_reserve(skb, MAX_TCP_HEADER); |
2704 | 2710 | ||
2705 | skb_dst_set(skb, dst); | 2711 | skb_dst_set(skb, dst); |
2712 | security_skb_owned_by(skb, sk); | ||
2706 | 2713 | ||
2707 | mss = dst_metric_advmss(dst); | 2714 | mss = dst_metric_advmss(dst); |
2708 | if (tp->rx_opt.user_mss && tp->rx_opt.user_mss < mss) | 2715 | if (tp->rx_opt.user_mss && tp->rx_opt.user_mss < mss) |
@@ -2930,7 +2937,7 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn) | |||
2930 | */ | 2937 | */ |
2931 | if (tp->rx_opt.user_mss && tp->rx_opt.user_mss < tp->rx_opt.mss_clamp) | 2938 | if (tp->rx_opt.user_mss && tp->rx_opt.user_mss < tp->rx_opt.mss_clamp) |
2932 | tp->rx_opt.mss_clamp = tp->rx_opt.user_mss; | 2939 | tp->rx_opt.mss_clamp = tp->rx_opt.user_mss; |
2933 | space = tcp_mtu_to_mss(sk, inet_csk(sk)->icsk_pmtu_cookie) - | 2940 | space = __tcp_mtu_to_mss(sk, inet_csk(sk)->icsk_pmtu_cookie) - |
2934 | MAX_TCP_OPTION_SPACE; | 2941 | MAX_TCP_OPTION_SPACE; |
2935 | 2942 | ||
2936 | syn_data = skb_copy_expand(syn, skb_headroom(syn), space, | 2943 | syn_data = skb_copy_expand(syn, skb_headroom(syn), space, |