aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/inet_hashtables.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/inet_hashtables.h')
-rw-r--r--include/net/inet_hashtables.h29
1 files changed, 23 insertions, 6 deletions
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 2dbbbff5e1e3..9141e95529e7 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -111,6 +111,7 @@ struct inet_bind_hashbucket {
111 */ 111 */
112struct inet_listen_hashbucket { 112struct inet_listen_hashbucket {
113 spinlock_t lock; 113 spinlock_t lock;
114 unsigned int count;
114 struct hlist_head head; 115 struct hlist_head head;
115}; 116};
116 117
@@ -132,12 +133,13 @@ struct inet_hashinfo {
132 /* Ok, let's try this, I give up, we do need a local binding 133 /* Ok, let's try this, I give up, we do need a local binding
133 * TCP hash as well as the others for fast bind/connect. 134 * TCP hash as well as the others for fast bind/connect.
134 */ 135 */
136 struct kmem_cache *bind_bucket_cachep;
135 struct inet_bind_hashbucket *bhash; 137 struct inet_bind_hashbucket *bhash;
136
137 unsigned int bhash_size; 138 unsigned int bhash_size;
138 /* 4 bytes hole on 64 bit */
139 139
140 struct kmem_cache *bind_bucket_cachep; 140 /* The 2nd listener table hashed by local port and address */
141 unsigned int lhash2_mask;
142 struct inet_listen_hashbucket *lhash2;
141 143
142 /* All the above members are written once at bootup and 144 /* All the above members are written once at bootup and
143 * never written again _or_ are predominantly read-access. 145 * never written again _or_ are predominantly read-access.
@@ -145,14 +147,25 @@ struct inet_hashinfo {
145 * Now align to a new cache line as all the following members 147 * Now align to a new cache line as all the following members
146 * might be often dirty. 148 * might be often dirty.
147 */ 149 */
148 /* All sockets in TCP_LISTEN state will be in here. This is the only 150 /* All sockets in TCP_LISTEN state will be in listening_hash.
149 * table where wildcard'd TCP sockets can exist. Hash function here 151 * This is the only table where wildcard'd TCP sockets can
150 * is just local port number. 152 * exist. listening_hash is only hashed by local port number.
153 * If lhash2 is initialized, the same socket will also be hashed
154 * to lhash2 by port and address.
151 */ 155 */
152 struct inet_listen_hashbucket listening_hash[INET_LHTABLE_SIZE] 156 struct inet_listen_hashbucket listening_hash[INET_LHTABLE_SIZE]
153 ____cacheline_aligned_in_smp; 157 ____cacheline_aligned_in_smp;
154}; 158};
155 159
160#define inet_lhash2_for_each_icsk_rcu(__icsk, list) \
161 hlist_for_each_entry_rcu(__icsk, list, icsk_listen_portaddr_node)
162
163static inline struct inet_listen_hashbucket *
164inet_lhash2_bucket(struct inet_hashinfo *h, u32 hash)
165{
166 return &h->lhash2[hash & h->lhash2_mask];
167}
168
156static inline struct inet_ehash_bucket *inet_ehash_bucket( 169static inline struct inet_ehash_bucket *inet_ehash_bucket(
157 struct inet_hashinfo *hashinfo, 170 struct inet_hashinfo *hashinfo,
158 unsigned int hash) 171 unsigned int hash)
@@ -208,6 +221,10 @@ int __inet_inherit_port(const struct sock *sk, struct sock *child);
208void inet_put_port(struct sock *sk); 221void inet_put_port(struct sock *sk);
209 222
210void inet_hashinfo_init(struct inet_hashinfo *h); 223void inet_hashinfo_init(struct inet_hashinfo *h);
224void inet_hashinfo2_init(struct inet_hashinfo *h, const char *name,
225 unsigned long numentries, int scale,
226 unsigned long low_limit,
227 unsigned long high_limit);
211 228
212bool inet_ehash_insert(struct sock *sk, struct sock *osk); 229bool inet_ehash_insert(struct sock *sk, struct sock *osk);
213bool inet_ehash_nolisten(struct sock *sk, struct sock *osk); 230bool inet_ehash_nolisten(struct sock *sk, struct sock *osk);