tcp: move duplicate code from tcp_v4_init_sock()/tcp_v6_init_sock()
Subsystems (3)
Neal Cardwell
maintainerPATCH 1/1 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()).
--- include/net/tcp.h | 1 + net/ipv4/tcp.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ net/ipv4/tcp_ipv4.c | 52 +--------------------------------------- net/ipv6/tcp_ipv6.c | 50 +--------------------------------------- 4 files changed, 68 insertions(+), 99 deletions(-)
include/net/tcp.h +1 -0
@@ -395,6 +395,7 @@ extern void tcp_enter_loss(struct sock *sk, int how);extern void tcp_clear_retrans (struct tcp_sock *tp);extern void tcp_update_metrics (struct sock *sk);extern void tcp_close (struct sock *sk,long timeout); +extern void tcp_init_sock (struct sock *sk);extern unsigned int tcp_poll (struct file * file,struct socket *sock,struct poll_table_struct *wait); extern int tcp_getsockopt(struct sock *sk, int level, int optname,
net/ipv4/tcp.c +64 -0
70 lines not on this page · raw message
net/ipv4/tcp_ipv4.c +2 -50
64 lines not on this page · raw message
net/ipv6/tcp_ipv6.c +1 -49
63 lines not on this page · raw message
Signature · 1 line
1.7.7.3
Quoted 12 lines · Neal Cardwell
This commit moves the (substantial) common code shared between
tcp_v4_init_sock()andtcp_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_cwndtoTCP_INIT_CWND, while the IPv6 side was still initializingsnd_cwndto 2 (in this case it should not matter, sincesnd_cwndis also initialized intcp_init_metrics(), but the general risks and maintenance overhead remain).
Quoted 7 lines
When diffing the old and new code, note that new
tcp_init_sock()function uses the order of steps from thetcp_v4_init_sock()implementation (the order is slightly different intcp_v6_init_sock()).Signed-off-by Neal Cardwell <[email protected]>---
Quoted 18 lines · Eric Dumazet
Quoted 17 lines · Neal Cardwell
This commit moves the (substantial) common code shared between
tcp_v4_init_sock()andtcp_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_cwndtoTCP_INIT_CWND, while the IPv6 side was still initializingsnd_cwndto 2 (in this case it should not matter, sincesnd_cwndis also initialized intcp_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 thetcp_v4_init_sock()implementation (the order is slightly different intcp_v6_init_sock()).
Quoted 4 lines
Quoted 2 lines
Signed-off-by Neal Cardwell <[email protected]>---
Acked-by Eric Dumazet <[email protected]>
Btw, there's also tcp_create_openreq_child which duplicates quite much init code.
Signature · 1 line
i.
From: Neal Cardwell <[email protected]>
Date: Thu, 19 Apr 2012 15:55:21 -0400
Quoted 12 lines
This commit moves the (substantial) common code shared between
tcp_v4_init_sock()andtcp_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_cwndtoTCP_INIT_CWND, while the IPv6 side was still initializingsnd_cwndto 2 (in this case it should not matter, sincesnd_cwndis also initialized intcp_init_metrics(), but the general risks and maintenance overhead remain).
Quoted 6 lines
When diffing the old and new code, note that new
tcp_init_sock()function uses the order of steps from thetcp_v4_init_sock()implementation (the order is slightly different intcp_v6_init_sock()).Signed-off-by Neal Cardwell <[email protected]>
Applied.