diff options
author | Neal Cardwell <ncardwell@google.com> | 2012-04-19 05:55:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-04-21 16:36:42 -0400 |
commit | 900f65d361d333c949ef76a828343075f4fdf523 (patch) | |
tree | 8b4474c6c9df1fcad4d946c64bcc1535450d0927 /net/ipv6 | |
parent | e66e9a31474dcce5be6f1186dc933d8a991c707b (diff) |
tcp: move duplicate code from tcp_v4_init_sock()/tcp_v6_init_sock()
This commit moves the (substantial) common code shared between
tcp_v4_init_sock() and tcp_v6_init_sock() to a new address-family
independent function, tcp_init_sock().
Centralizing this functionality should help avoid drift issues,
e.g. where the IPv4 side is updated without a corresponding update to
IPv6. There was already some drift: IPv4 initialized snd_cwnd to
TCP_INIT_CWND, while the IPv6 side was still initializing snd_cwnd to
2 (in this case it should not matter, since snd_cwnd is also
initialized in tcp_init_metrics(), but the general risks and
maintenance overhead remain).
When diffing the old and new code, note that new tcp_init_sock()
function uses the order of steps from the tcp_v4_init_sock()
implementation (the order is slightly different in
tcp_v6_init_sock()).
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/tcp_ipv6.c | 50 |
1 files changed, 1 insertions, 49 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 050c55186bc4..24dac6b83fb9 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -1831,62 +1831,14 @@ static int tcp_v6_init_sock(struct sock *sk) | |||
1831 | struct inet_connection_sock *icsk = inet_csk(sk); | 1831 | struct inet_connection_sock *icsk = inet_csk(sk); |
1832 | struct tcp_sock *tp = tcp_sk(sk); | 1832 | struct tcp_sock *tp = tcp_sk(sk); |
1833 | 1833 | ||
1834 | skb_queue_head_init(&tp->out_of_order_queue); | 1834 | tcp_init_sock(sk); |
1835 | tcp_init_xmit_timers(sk); | ||
1836 | tcp_prequeue_init(tp); | ||
1837 | |||
1838 | icsk->icsk_rto = TCP_TIMEOUT_INIT; | ||
1839 | tp->mdev = TCP_TIMEOUT_INIT; | ||
1840 | |||
1841 | /* So many TCP implementations out there (incorrectly) count the | ||
1842 | * initial SYN frame in their delayed-ACK and congestion control | ||
1843 | * algorithms that we must have the following bandaid to talk | ||
1844 | * efficiently to them. -DaveM | ||
1845 | */ | ||
1846 | tp->snd_cwnd = 2; | ||
1847 | |||
1848 | /* See draft-stevens-tcpca-spec-01 for discussion of the | ||
1849 | * initialization of these values. | ||
1850 | */ | ||
1851 | tp->snd_ssthresh = TCP_INFINITE_SSTHRESH; | ||
1852 | tp->snd_cwnd_clamp = ~0; | ||
1853 | tp->mss_cache = TCP_MSS_DEFAULT; | ||
1854 | |||
1855 | tp->reordering = sysctl_tcp_reordering; | ||
1856 | |||
1857 | sk->sk_state = TCP_CLOSE; | ||
1858 | 1835 | ||
1859 | icsk->icsk_af_ops = &ipv6_specific; | 1836 | icsk->icsk_af_ops = &ipv6_specific; |
1860 | icsk->icsk_ca_ops = &tcp_init_congestion_ops; | ||
1861 | icsk->icsk_sync_mss = tcp_sync_mss; | ||
1862 | sk->sk_write_space = sk_stream_write_space; | ||
1863 | sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); | ||
1864 | 1837 | ||
1865 | #ifdef CONFIG_TCP_MD5SIG | 1838 | #ifdef CONFIG_TCP_MD5SIG |
1866 | tp->af_specific = &tcp_sock_ipv6_specific; | 1839 | tp->af_specific = &tcp_sock_ipv6_specific; |
1867 | #endif | 1840 | #endif |
1868 | 1841 | ||
1869 | /* TCP Cookie Transactions */ | ||
1870 | if (sysctl_tcp_cookie_size > 0) { | ||
1871 | /* Default, cookies without s_data_payload. */ | ||
1872 | tp->cookie_values = | ||
1873 | kzalloc(sizeof(*tp->cookie_values), | ||
1874 | sk->sk_allocation); | ||
1875 | if (tp->cookie_values != NULL) | ||
1876 | kref_init(&tp->cookie_values->kref); | ||
1877 | } | ||
1878 | /* Presumed zeroed, in order of appearance: | ||
1879 | * cookie_in_always, cookie_out_never, | ||
1880 | * s_data_constant, s_data_in, s_data_out | ||
1881 | */ | ||
1882 | sk->sk_sndbuf = sysctl_tcp_wmem[1]; | ||
1883 | sk->sk_rcvbuf = sysctl_tcp_rmem[1]; | ||
1884 | |||
1885 | local_bh_disable(); | ||
1886 | sock_update_memcg(sk); | ||
1887 | sk_sockets_allocated_inc(sk); | ||
1888 | local_bh_enable(); | ||
1889 | |||
1890 | return 0; | 1842 | return 0; |
1891 | } | 1843 | } |
1892 | 1844 | ||