diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2008-02-03 07:06:04 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-02-03 07:28:52 -0500 |
commit | ab1e0a13d70299e792fd0527cefd070c1405fa5b (patch) | |
tree | d470e7b94b0e33ea59b12713366f1bee0b94f78c /net/ipv4/tcp_ipv4.c | |
parent | 9dc7f30e3bac329998a2a9bb814bd0abc7cb58e2 (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/ipv4/tcp_ipv4.c')
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 77c1939a2b0d..63414ea427c5 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -108,22 +108,6 @@ struct inet_hashinfo __cacheline_aligned tcp_hashinfo = { | |||
108 | .lhash_wait = __WAIT_QUEUE_HEAD_INITIALIZER(tcp_hashinfo.lhash_wait), | 108 | .lhash_wait = __WAIT_QUEUE_HEAD_INITIALIZER(tcp_hashinfo.lhash_wait), |
109 | }; | 109 | }; |
110 | 110 | ||
111 | static int tcp_v4_get_port(struct sock *sk, unsigned short snum) | ||
112 | { | ||
113 | return inet_csk_get_port(&tcp_hashinfo, sk, snum, | ||
114 | inet_csk_bind_conflict); | ||
115 | } | ||
116 | |||
117 | static void tcp_v4_hash(struct sock *sk) | ||
118 | { | ||
119 | inet_hash(&tcp_hashinfo, sk); | ||
120 | } | ||
121 | |||
122 | void tcp_unhash(struct sock *sk) | ||
123 | { | ||
124 | inet_unhash(&tcp_hashinfo, sk); | ||
125 | } | ||
126 | |||
127 | static inline __u32 tcp_v4_init_sequence(struct sk_buff *skb) | 111 | static inline __u32 tcp_v4_init_sequence(struct sk_buff *skb) |
128 | { | 112 | { |
129 | return secure_tcp_sequence_number(ip_hdr(skb)->daddr, | 113 | return secure_tcp_sequence_number(ip_hdr(skb)->daddr, |
@@ -1478,8 +1462,8 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
1478 | } | 1462 | } |
1479 | #endif | 1463 | #endif |
1480 | 1464 | ||
1481 | __inet_hash_nolisten(&tcp_hashinfo, newsk); | 1465 | __inet_hash_nolisten(newsk); |
1482 | __inet_inherit_port(&tcp_hashinfo, sk, newsk); | 1466 | __inet_inherit_port(sk, newsk); |
1483 | 1467 | ||
1484 | return newsk; | 1468 | return newsk; |
1485 | 1469 | ||
@@ -1827,6 +1811,7 @@ struct inet_connection_sock_af_ops ipv4_specific = { | |||
1827 | .getsockopt = ip_getsockopt, | 1811 | .getsockopt = ip_getsockopt, |
1828 | .addr2sockaddr = inet_csk_addr2sockaddr, | 1812 | .addr2sockaddr = inet_csk_addr2sockaddr, |
1829 | .sockaddr_len = sizeof(struct sockaddr_in), | 1813 | .sockaddr_len = sizeof(struct sockaddr_in), |
1814 | .bind_conflict = inet_csk_bind_conflict, | ||
1830 | #ifdef CONFIG_COMPAT | 1815 | #ifdef CONFIG_COMPAT |
1831 | .compat_setsockopt = compat_ip_setsockopt, | 1816 | .compat_setsockopt = compat_ip_setsockopt, |
1832 | .compat_getsockopt = compat_ip_getsockopt, | 1817 | .compat_getsockopt = compat_ip_getsockopt, |
@@ -1926,7 +1911,7 @@ int tcp_v4_destroy_sock(struct sock *sk) | |||
1926 | 1911 | ||
1927 | /* Clean up a referenced TCP bind bucket. */ | 1912 | /* Clean up a referenced TCP bind bucket. */ |
1928 | if (inet_csk(sk)->icsk_bind_hash) | 1913 | if (inet_csk(sk)->icsk_bind_hash) |
1929 | inet_put_port(&tcp_hashinfo, sk); | 1914 | inet_put_port(sk); |
1930 | 1915 | ||
1931 | /* | 1916 | /* |
1932 | * If sendmsg cached page exists, toss it. | 1917 | * If sendmsg cached page exists, toss it. |
@@ -2435,9 +2420,9 @@ struct proto tcp_prot = { | |||
2435 | .getsockopt = tcp_getsockopt, | 2420 | .getsockopt = tcp_getsockopt, |
2436 | .recvmsg = tcp_recvmsg, | 2421 | .recvmsg = tcp_recvmsg, |
2437 | .backlog_rcv = tcp_v4_do_rcv, | 2422 | .backlog_rcv = tcp_v4_do_rcv, |
2438 | .hash = tcp_v4_hash, | 2423 | .hash = inet_hash, |
2439 | .unhash = tcp_unhash, | 2424 | .unhash = inet_unhash, |
2440 | .get_port = tcp_v4_get_port, | 2425 | .get_port = inet_csk_get_port, |
2441 | .enter_memory_pressure = tcp_enter_memory_pressure, | 2426 | .enter_memory_pressure = tcp_enter_memory_pressure, |
2442 | .sockets_allocated = &tcp_sockets_allocated, | 2427 | .sockets_allocated = &tcp_sockets_allocated, |
2443 | .orphan_count = &tcp_orphan_count, | 2428 | .orphan_count = &tcp_orphan_count, |
@@ -2450,6 +2435,7 @@ struct proto tcp_prot = { | |||
2450 | .obj_size = sizeof(struct tcp_sock), | 2435 | .obj_size = sizeof(struct tcp_sock), |
2451 | .twsk_prot = &tcp_timewait_sock_ops, | 2436 | .twsk_prot = &tcp_timewait_sock_ops, |
2452 | .rsk_prot = &tcp_request_sock_ops, | 2437 | .rsk_prot = &tcp_request_sock_ops, |
2438 | .hashinfo = &tcp_hashinfo, | ||
2453 | #ifdef CONFIG_COMPAT | 2439 | #ifdef CONFIG_COMPAT |
2454 | .compat_setsockopt = compat_tcp_setsockopt, | 2440 | .compat_setsockopt = compat_tcp_setsockopt, |
2455 | .compat_getsockopt = compat_tcp_getsockopt, | 2441 | .compat_getsockopt = compat_tcp_getsockopt, |
@@ -2467,7 +2453,6 @@ void __init tcp_v4_init(struct net_proto_family *ops) | |||
2467 | EXPORT_SYMBOL(ipv4_specific); | 2453 | EXPORT_SYMBOL(ipv4_specific); |
2468 | EXPORT_SYMBOL(tcp_hashinfo); | 2454 | EXPORT_SYMBOL(tcp_hashinfo); |
2469 | EXPORT_SYMBOL(tcp_prot); | 2455 | EXPORT_SYMBOL(tcp_prot); |
2470 | EXPORT_SYMBOL(tcp_unhash); | ||
2471 | EXPORT_SYMBOL(tcp_v4_conn_request); | 2456 | EXPORT_SYMBOL(tcp_v4_conn_request); |
2472 | EXPORT_SYMBOL(tcp_v4_connect); | 2457 | EXPORT_SYMBOL(tcp_v4_connect); |
2473 | EXPORT_SYMBOL(tcp_v4_do_rcv); | 2458 | EXPORT_SYMBOL(tcp_v4_do_rcv); |