diff options
Diffstat (limited to 'include/net/inet_hashtables.h')
-rw-r--r-- | include/net/inet_hashtables.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 3a6c11ca421d..da9705525f15 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
@@ -14,12 +14,15 @@ | |||
14 | #ifndef _INET_HASHTABLES_H | 14 | #ifndef _INET_HASHTABLES_H |
15 | #define _INET_HASHTABLES_H | 15 | #define _INET_HASHTABLES_H |
16 | 16 | ||
17 | #include <linux/interrupt.h> | ||
17 | #include <linux/ip.h> | 18 | #include <linux/ip.h> |
18 | #include <linux/list.h> | 19 | #include <linux/list.h> |
19 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
20 | #include <linux/spinlock.h> | 21 | #include <linux/spinlock.h> |
21 | #include <linux/types.h> | 22 | #include <linux/types.h> |
22 | 23 | ||
24 | #include <net/sock.h> | ||
25 | |||
23 | /* This is for all connections with a full identity, no wildcards. | 26 | /* This is for all connections with a full identity, no wildcards. |
24 | * New scheme, half the table is for TIME_WAIT, the other half is | 27 | * New scheme, half the table is for TIME_WAIT, the other half is |
25 | * for the rest. I'll experiment with dynamic table growth later. | 28 | * for the rest. I'll experiment with dynamic table growth later. |
@@ -113,6 +116,7 @@ struct inet_hashinfo { | |||
113 | atomic_t lhash_users; | 116 | atomic_t lhash_users; |
114 | wait_queue_head_t lhash_wait; | 117 | wait_queue_head_t lhash_wait; |
115 | spinlock_t portalloc_lock; | 118 | spinlock_t portalloc_lock; |
119 | kmem_cache_t *bind_bucket_cachep; | ||
116 | }; | 120 | }; |
117 | 121 | ||
118 | static inline int inet_ehashfn(const __u32 laddr, const __u16 lport, | 122 | static inline int inet_ehashfn(const __u32 laddr, const __u16 lport, |
@@ -148,6 +152,9 @@ static inline int inet_bhashfn(const __u16 lport, const int bhash_size) | |||
148 | return lport & (bhash_size - 1); | 152 | return lport & (bhash_size - 1); |
149 | } | 153 | } |
150 | 154 | ||
155 | extern void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb, | ||
156 | const unsigned short snum); | ||
157 | |||
151 | /* These can have wildcards, don't try too hard. */ | 158 | /* These can have wildcards, don't try too hard. */ |
152 | static inline int inet_lhashfn(const unsigned short num) | 159 | static inline int inet_lhashfn(const unsigned short num) |
153 | { | 160 | { |
@@ -159,4 +166,29 @@ static inline int inet_sk_listen_hashfn(const struct sock *sk) | |||
159 | return inet_lhashfn(inet_sk(sk)->num); | 166 | return inet_lhashfn(inet_sk(sk)->num); |
160 | } | 167 | } |
161 | 168 | ||
169 | /* Caller must disable local BH processing. */ | ||
170 | static inline void __inet_inherit_port(struct inet_hashinfo *table, | ||
171 | struct sock *sk, struct sock *child) | ||
172 | { | ||
173 | const int bhash = inet_bhashfn(inet_sk(child)->num, table->bhash_size); | ||
174 | struct inet_bind_hashbucket *head = &table->bhash[bhash]; | ||
175 | struct inet_bind_bucket *tb; | ||
176 | |||
177 | spin_lock(&head->lock); | ||
178 | tb = inet_sk(sk)->bind_hash; | ||
179 | sk_add_bind_node(child, &tb->owners); | ||
180 | inet_sk(child)->bind_hash = tb; | ||
181 | spin_unlock(&head->lock); | ||
182 | } | ||
183 | |||
184 | static inline void inet_inherit_port(struct inet_hashinfo *table, | ||
185 | struct sock *sk, struct sock *child) | ||
186 | { | ||
187 | local_bh_disable(); | ||
188 | __inet_inherit_port(table, sk, child); | ||
189 | local_bh_enable(); | ||
190 | } | ||
191 | |||
192 | extern void inet_put_port(struct inet_hashinfo *table, struct sock *sk); | ||
193 | |||
162 | #endif /* _INET_HASHTABLES_H */ | 194 | #endif /* _INET_HASHTABLES_H */ |