aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/tcp_ipv6.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2008-02-03 07:06:04 -0500
committerDavid S. Miller <davem@davemloft.net>2008-02-03 07:28:52 -0500
commitab1e0a13d70299e792fd0527cefd070c1405fa5b (patch)
treed470e7b94b0e33ea59b12713366f1bee0b94f78c /net/ipv6/tcp_ipv6.c
parent9dc7f30e3bac329998a2a9bb814bd0abc7cb58e2 (diff)
[SOCK] proto: Add hashinfo member to struct proto
This way we can remove TCP and DCCP specific versions of sk->sk_prot->get_port: both v4 and v6 use inet_csk_get_port sk->sk_prot->hash: inet_hash is directly used, only v6 need a specific version to deal with mapped sockets sk->sk_prot->unhash: both v4 and v6 use inet_hash directly struct inet_connection_sock_af_ops also gets a new member, bind_conflict, so that inet_csk_get_port can find the per family routine. Now only the lookup routines receive as a parameter a struct inet_hashtable. With this we further reuse code, reducing the difference among INET transport protocols. Eventually work has to be done on UDP and SCTP to make them share this infrastructure and get as a bonus inet_diag interfaces so that iproute can be used with these protocols. net-2.6/net/ipv4/inet_hashtables.c: struct proto | +8 struct inet_connection_sock_af_ops | +8 2 structs changed __inet_hash_nolisten | +18 __inet_hash | -210 inet_put_port | +8 inet_bind_bucket_create | +1 __inet_hash_connect | -8 5 functions changed, 27 bytes added, 218 bytes removed, diff: -191 net-2.6/net/core/sock.c: proto_seq_show | +3 1 function changed, 3 bytes added, diff: +3 net-2.6/net/ipv4/inet_connection_sock.c: inet_csk_get_port | +15 1 function changed, 15 bytes added, diff: +15 net-2.6/net/ipv4/tcp.c: tcp_set_state | -7 1 function changed, 7 bytes removed, diff: -7 net-2.6/net/ipv4/tcp_ipv4.c: tcp_v4_get_port | -31 tcp_v4_hash | -48 tcp_v4_destroy_sock | -7 tcp_v4_syn_recv_sock | -2 tcp_unhash | -179 5 functions changed, 267 bytes removed, diff: -267 net-2.6/net/ipv6/inet6_hashtables.c: __inet6_hash | +8 1 function changed, 8 bytes added, diff: +8 net-2.6/net/ipv4/inet_hashtables.c: inet_unhash | +190 inet_hash | +242 2 functions changed, 432 bytes added, diff: +432 vmlinux: 16 functions changed, 485 bytes added, 492 bytes removed, diff: -7 /home/acme/git/net-2.6/net/ipv6/tcp_ipv6.c: tcp_v6_get_port | -31 tcp_v6_hash | -7 tcp_v6_syn_recv_sock | -9 3 functions changed, 47 bytes removed, diff: -47 /home/acme/git/net-2.6/net/dccp/proto.c: dccp_destroy_sock | -7 dccp_unhash | -179 dccp_hash | -49 dccp_set_state | -7 dccp_done | +1 5 functions changed, 1 bytes added, 242 bytes removed, diff: -241 /home/acme/git/net-2.6/net/dccp/ipv4.c: dccp_v4_get_port | -31 dccp_v4_request_recv_sock | -2 2 functions changed, 33 bytes removed, diff: -33 /home/acme/git/net-2.6/net/dccp/ipv6.c: dccp_v6_get_port | -31 dccp_v6_hash | -7 dccp_v6_request_recv_sock | +5 3 functions changed, 5 bytes added, 38 bytes removed, diff: -33 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/tcp_ipv6.c')
-rw-r--r--net/ipv6/tcp_ipv6.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 59d0029e93a7..12750f2b05ab 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -86,12 +86,6 @@ static struct tcp_sock_af_ops tcp_sock_ipv6_specific;
86static struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific; 86static struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific;
87#endif 87#endif
88 88
89static int tcp_v6_get_port(struct sock *sk, unsigned short snum)
90{
91 return inet_csk_get_port(&tcp_hashinfo, sk, snum,
92 inet6_csk_bind_conflict);
93}
94
95static void tcp_v6_hash(struct sock *sk) 89static void tcp_v6_hash(struct sock *sk)
96{ 90{
97 if (sk->sk_state != TCP_CLOSE) { 91 if (sk->sk_state != TCP_CLOSE) {
@@ -100,7 +94,7 @@ static void tcp_v6_hash(struct sock *sk)
100 return; 94 return;
101 } 95 }
102 local_bh_disable(); 96 local_bh_disable();
103 __inet6_hash(&tcp_hashinfo, sk); 97 __inet6_hash(sk);
104 local_bh_enable(); 98 local_bh_enable();
105 } 99 }
106} 100}
@@ -1504,8 +1498,8 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1504 } 1498 }
1505#endif 1499#endif
1506 1500
1507 __inet6_hash(&tcp_hashinfo, newsk); 1501 __inet6_hash(newsk);
1508 inet_inherit_port(&tcp_hashinfo, sk, newsk); 1502 inet_inherit_port(sk, newsk);
1509 1503
1510 return newsk; 1504 return newsk;
1511 1505
@@ -1833,6 +1827,7 @@ static struct inet_connection_sock_af_ops ipv6_specific = {
1833 .getsockopt = ipv6_getsockopt, 1827 .getsockopt = ipv6_getsockopt,
1834 .addr2sockaddr = inet6_csk_addr2sockaddr, 1828 .addr2sockaddr = inet6_csk_addr2sockaddr,
1835 .sockaddr_len = sizeof(struct sockaddr_in6), 1829 .sockaddr_len = sizeof(struct sockaddr_in6),
1830 .bind_conflict = inet6_csk_bind_conflict,
1836#ifdef CONFIG_COMPAT 1831#ifdef CONFIG_COMPAT
1837 .compat_setsockopt = compat_ipv6_setsockopt, 1832 .compat_setsockopt = compat_ipv6_setsockopt,
1838 .compat_getsockopt = compat_ipv6_getsockopt, 1833 .compat_getsockopt = compat_ipv6_getsockopt,
@@ -1864,6 +1859,7 @@ static struct inet_connection_sock_af_ops ipv6_mapped = {
1864 .getsockopt = ipv6_getsockopt, 1859 .getsockopt = ipv6_getsockopt,
1865 .addr2sockaddr = inet6_csk_addr2sockaddr, 1860 .addr2sockaddr = inet6_csk_addr2sockaddr,
1866 .sockaddr_len = sizeof(struct sockaddr_in6), 1861 .sockaddr_len = sizeof(struct sockaddr_in6),
1862 .bind_conflict = inet6_csk_bind_conflict,
1867#ifdef CONFIG_COMPAT 1863#ifdef CONFIG_COMPAT
1868 .compat_setsockopt = compat_ipv6_setsockopt, 1864 .compat_setsockopt = compat_ipv6_setsockopt,
1869 .compat_getsockopt = compat_ipv6_getsockopt, 1865 .compat_getsockopt = compat_ipv6_getsockopt,
@@ -2127,8 +2123,8 @@ struct proto tcpv6_prot = {
2127 .recvmsg = tcp_recvmsg, 2123 .recvmsg = tcp_recvmsg,
2128 .backlog_rcv = tcp_v6_do_rcv, 2124 .backlog_rcv = tcp_v6_do_rcv,
2129 .hash = tcp_v6_hash, 2125 .hash = tcp_v6_hash,
2130 .unhash = tcp_unhash, 2126 .unhash = inet_unhash,
2131 .get_port = tcp_v6_get_port, 2127 .get_port = inet_csk_get_port,
2132 .enter_memory_pressure = tcp_enter_memory_pressure, 2128 .enter_memory_pressure = tcp_enter_memory_pressure,
2133 .sockets_allocated = &tcp_sockets_allocated, 2129 .sockets_allocated = &tcp_sockets_allocated,
2134 .memory_allocated = &tcp_memory_allocated, 2130 .memory_allocated = &tcp_memory_allocated,
@@ -2141,6 +2137,7 @@ struct proto tcpv6_prot = {
2141 .obj_size = sizeof(struct tcp6_sock), 2137 .obj_size = sizeof(struct tcp6_sock),
2142 .twsk_prot = &tcp6_timewait_sock_ops, 2138 .twsk_prot = &tcp6_timewait_sock_ops,
2143 .rsk_prot = &tcp6_request_sock_ops, 2139 .rsk_prot = &tcp6_request_sock_ops,
2140 .hashinfo = &tcp_hashinfo,
2144#ifdef CONFIG_COMPAT 2141#ifdef CONFIG_COMPAT
2145 .compat_setsockopt = compat_tcp_setsockopt, 2142 .compat_setsockopt = compat_tcp_setsockopt,
2146 .compat_getsockopt = compat_tcp_getsockopt, 2143 .compat_getsockopt = compat_tcp_getsockopt,