aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorYuchung Cheng <ycheng@google.com>2013-02-22 03:59:06 -0500
committerDavid S. Miller <davem@davemloft.net>2013-02-22 15:10:19 -0500
commit1b63edd6ecc55c3a61b40297b49e2323783bddfd (patch)
tree6572656aae76924fe38380e3edb650dd5965ef26 /net
parentcbda4eaffa2da9cefb89dd748803da689596d28b (diff)
tcp: fix SYN-data space mis-accounting
In fast open the sender unncessarily reduces the space available for data in SYN by 12 bytes. This is because in the sender incorrectly reserves space for TS option twice in tcp_send_syn_data(): tcp_mtu_to_mss() already accounts for TS option space. But it further reserves MAX_TCP_OPTION_SPACE when computing the payload space. Signed-off-by: Yuchung Cheng <ycheng@google.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/tcp_output.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index fd0cea114b5d..e2b4461074da 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1351,8 +1351,8 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
1351 return 0; 1351 return 0;
1352} 1352}
1353 1353
1354/* Calculate MSS. Not accounting for SACKs here. */ 1354/* Calculate MSS not accounting any TCP options. */
1355int tcp_mtu_to_mss(struct sock *sk, int pmtu) 1355static inline int __tcp_mtu_to_mss(struct sock *sk, int pmtu)
1356{ 1356{
1357 const struct tcp_sock *tp = tcp_sk(sk); 1357 const struct tcp_sock *tp = tcp_sk(sk);
1358 const struct inet_connection_sock *icsk = inet_csk(sk); 1358 const struct inet_connection_sock *icsk = inet_csk(sk);
@@ -1381,13 +1381,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 */ 1381 /* Then reserve room for full set of TCP options and 8 bytes of data */
1382 if (mss_now < 48) 1382 if (mss_now < 48)
1383 mss_now = 48; 1383 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; 1384 return mss_now;
1389} 1385}
1390 1386
1387/* Calculate MSS. Not accounting for SACKs here. */
1388int tcp_mtu_to_mss(struct sock *sk, int pmtu)
1389{
1390 /* Subtract TCP options size, not including SACKs */
1391 return __tcp_mtu_to_mss(sk, pmtu) -
1392 (tcp_sk(sk)->tcp_header_len - sizeof(struct tcphdr));
1393}
1394
1391/* Inverse of above */ 1395/* Inverse of above */
1392int tcp_mss_to_mtu(struct sock *sk, int mss) 1396int tcp_mss_to_mtu(struct sock *sk, int mss)
1393{ 1397{
@@ -2930,7 +2934,7 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
2930 */ 2934 */
2931 if (tp->rx_opt.user_mss && tp->rx_opt.user_mss < tp->rx_opt.mss_clamp) 2935 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; 2936 tp->rx_opt.mss_clamp = tp->rx_opt.user_mss;
2933 space = tcp_mtu_to_mss(sk, inet_csk(sk)->icsk_pmtu_cookie) - 2937 space = __tcp_mtu_to_mss(sk, inet_csk(sk)->icsk_pmtu_cookie) -
2934 MAX_TCP_OPTION_SPACE; 2938 MAX_TCP_OPTION_SPACE;
2935 2939
2936 syn_data = skb_copy_expand(syn, skb_headroom(syn), space, 2940 syn_data = skb_copy_expand(syn, skb_headroom(syn), space,