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.
6 * Generic INET transport hashtables
8 * Authors: Lotsa people, from code originally in tcp
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.
16 #include <linux/config.h>
17 #include <linux/slab.h>
19 #include <net/inet_hashtables.h>
22 * Allocate and initialize a new local port bind bucket.
23 * The bindhash mutex for snum's hash chain must be held here.
25 struct inet_bind_bucket *inet_bind_bucket_create(kmem_cache_t *cachep,
26 struct inet_bind_hashbucket *head,
27 const unsigned short snum)
29 struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, SLAB_ATOMIC);
34 INIT_HLIST_HEAD(&tb->owners);
35 hlist_add_head(&tb->node, &head->chain);
40 EXPORT_SYMBOL(inet_bind_bucket_create);
43 * Caller must hold hashbucket lock for this tb with local BH disabled
45 void inet_bind_bucket_destroy(kmem_cache_t *cachep, struct inet_bind_bucket *tb)
47 if (hlist_empty(&tb->owners)) {
48 __hlist_del(&tb->node);
49 kmem_cache_free(cachep, tb);