aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@ghostprotocols.net>2005-08-09 23:00:51 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2005-08-29 18:38:39 -0400
commit77d8bf9c6208eb535f05718168ffcc476be0ca8c (patch)
tree255d84f4f222161235d54f82793667cccc509229 /net/ipv4
parent0f7ff9274e72fd254fbd1ab117bbc1db6e7cdb34 (diff)
[INET]: Move the TCP hashtable functions/structs to inet_hashtables.[ch]
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/Makefile2
-rw-r--r--net/ipv4/inet_hashtables.c51
-rw-r--r--net/ipv4/tcp_ipv4.c26
3 files changed, 52 insertions, 27 deletions
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index 61c7386bcd2e..2d8d30e83eb0 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -4,7 +4,7 @@
4 4
5obj-y := route.o inetpeer.o protocol.o \ 5obj-y := route.o inetpeer.o protocol.o \
6 ip_input.o ip_fragment.o ip_forward.o ip_options.o \ 6 ip_input.o ip_fragment.o ip_forward.o ip_options.o \
7 ip_output.o ip_sockglue.o \ 7 ip_output.o ip_sockglue.o inet_hashtables.o \
8 tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \ 8 tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \
9 tcp_minisocks.o tcp_cong.o \ 9 tcp_minisocks.o tcp_cong.o \
10 datagram.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \ 10 datagram.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
new file mode 100644
index 000000000000..343a890bd617
--- /dev/null
+++ b/net/ipv4/inet_hashtables.c
@@ -0,0 +1,51 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Generic INET transport hashtables
7 *
8 * Authors: Lotsa people, from code originally in tcp
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15
16#include <linux/config.h>
17#include <linux/slab.h>
18
19#include <net/inet_hashtables.h>
20
21/*
22 * Allocate and initialize a new local port bind bucket.
23 * The bindhash mutex for snum's hash chain must be held here.
24 */
25struct inet_bind_bucket *inet_bind_bucket_create(kmem_cache_t *cachep,
26 struct inet_bind_hashbucket *head,
27 const unsigned short snum)
28{
29 struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, SLAB_ATOMIC);
30
31 if (tb != NULL) {
32 tb->port = snum;
33 tb->fastreuse = 0;
34 INIT_HLIST_HEAD(&tb->owners);
35 hlist_add_head(&tb->node, &head->chain);
36 }
37 return tb;
38}
39
40EXPORT_SYMBOL(inet_bind_bucket_create);
41
42/*
43 * Caller must hold hashbucket lock for this tb with local BH disabled
44 */
45void inet_bind_bucket_destroy(kmem_cache_t *cachep, struct inet_bind_bucket *tb)
46{
47 if (hlist_empty(&tb->owners)) {
48 __hlist_del(&tb->node);
49 kmem_cache_free(cachep, tb);
50 }
51}
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 4138630556e3..58e36ed88f25 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -104,32 +104,6 @@ struct inet_hashinfo __cacheline_aligned tcp_hashinfo = {
104int sysctl_local_port_range[2] = { 1024, 4999 }; 104int sysctl_local_port_range[2] = { 1024, 4999 };
105int tcp_port_rover = 1024 - 1; 105int tcp_port_rover = 1024 - 1;
106 106
107/* Allocate and initialize a new local port bind bucket.
108 * The bindhash mutex for snum's hash chain must be held here.
109 */
110struct inet_bind_bucket *inet_bind_bucket_create(kmem_cache_t *cachep,
111 struct inet_bind_hashbucket *head,
112 const unsigned short snum)
113{
114 struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, SLAB_ATOMIC);
115 if (tb) {
116 tb->port = snum;
117 tb->fastreuse = 0;
118 INIT_HLIST_HEAD(&tb->owners);
119 hlist_add_head(&tb->node, &head->chain);
120 }
121 return tb;
122}
123
124/* Caller must hold hashbucket lock for this tb with local BH disabled */
125void inet_bind_bucket_destroy(kmem_cache_t *cachep, struct inet_bind_bucket *tb)
126{
127 if (hlist_empty(&tb->owners)) {
128 __hlist_del(&tb->node);
129 kmem_cache_free(cachep, tb);
130 }
131}
132
133/* Caller must disable local BH processing. */ 107/* Caller must disable local BH processing. */
134static __inline__ void __tcp_inherit_port(struct sock *sk, struct sock *child) 108static __inline__ void __tcp_inherit_port(struct sock *sk, struct sock *child)
135{ 109{