Skip to content

Commit 8191792

Browse files
q2vendavem330
authored andcommitted
tcp: Remove dead code and fields for bhash2.
Now all sockets including TIME_WAIT are linked to bhash2 using sock_common.skc_bind_node. We no longer use inet_bind2_bucket.deathrow, sock.sk_bind2_node, and inet_timewait_sock.tw_bind2_node. Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 770041d commit 8191792

File tree

5 files changed

+1
-35
lines changed

5 files changed

+1
-35
lines changed

include/net/inet_hashtables.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ struct inet_bind2_bucket {
107107
struct hlist_node bhash_node;
108108
/* List of sockets hashed to this bucket */
109109
struct hlist_head owners;
110-
/* bhash has twsk in owners, but bhash2 has twsk in
111-
* deathrow not to add a member in struct sock_common.
112-
*/
113-
struct hlist_head deathrow;
114110
};
115111

116112
static inline struct net *ib_net(const struct inet_bind_bucket *ib)

include/net/inet_timewait_sock.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,9 @@ struct inet_timewait_sock {
7575
struct timer_list tw_timer;
7676
struct inet_bind_bucket *tw_tb;
7777
struct inet_bind2_bucket *tw_tb2;
78-
struct hlist_node tw_bind2_node;
7978
};
8079
#define tw_tclass tw_tos
8180

82-
#define twsk_for_each_bound_bhash2(__tw, list) \
83-
hlist_for_each_entry(__tw, list, tw_bind2_node)
84-
8581
static inline struct inet_timewait_sock *inet_twsk(const struct sock *sk)
8682
{
8783
return (struct inet_timewait_sock *)sk;

include/net/sock.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ struct sk_filter;
352352
* @sk_txtime_report_errors: set report errors mode for SO_TXTIME
353353
* @sk_txtime_unused: unused txtime flags
354354
* @ns_tracker: tracker for netns reference
355-
* @sk_bind2_node: bind node in the bhash2 table
356355
*/
357356
struct sock {
358357
/*
@@ -544,7 +543,6 @@ struct sock {
544543
#endif
545544
struct rcu_head sk_rcu;
546545
netns_tracker ns_tracker;
547-
struct hlist_node sk_bind2_node;
548546
};
549547

550548
enum sk_pacing {
@@ -890,8 +888,6 @@ static inline void sk_add_bind_node(struct sock *sk,
890888
hlist_for_each_entry_safe(__sk, tmp, list, sk_node)
891889
#define sk_for_each_bound(__sk, list) \
892890
hlist_for_each_entry(__sk, list, sk_bind_node)
893-
#define sk_for_each_bound_bhash2(__sk, list) \
894-
hlist_for_each_entry(__sk, list, sk_bind2_node)
895891

896892
/**
897893
* sk_for_each_entry_offset_rcu - iterate over a list at a given struct offset

net/ipv4/inet_connection_sock.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ static bool inet_bhash2_conflict(const struct sock *sk,
216216
bool relax, bool reuseport_cb_ok,
217217
bool reuseport_ok)
218218
{
219-
struct inet_timewait_sock *tw2;
220219
struct sock *sk2;
221220

222221
sk_for_each_bound(sk2, &tb2->owners) {
@@ -225,25 +224,13 @@ static bool inet_bhash2_conflict(const struct sock *sk,
225224
return true;
226225
}
227226

228-
twsk_for_each_bound_bhash2(tw2, &tb2->deathrow) {
229-
sk2 = (struct sock *)tw2;
230-
231-
if (__inet_bhash2_conflict(sk, sk2, sk_uid, relax,
232-
reuseport_cb_ok, reuseport_ok))
233-
return true;
234-
}
235-
236227
return false;
237228
}
238229

239230
#define sk_for_each_bound_bhash(__sk, __tb2, __tb) \
240231
hlist_for_each_entry(__tb2, &(__tb)->bhash2, bhash_node) \
241232
sk_for_each_bound(sk2, &(__tb2)->owners)
242233

243-
#define twsk_for_each_bound_bhash(__sk, __tb2, __tb) \
244-
hlist_for_each_entry(__tb2, &(__tb)->bhash2, bhash_node) \
245-
sk_for_each_bound_bhash2(sk2, &(__tb2)->deathrow)
246-
247234
/* This should be called only when the tb and tb2 hashbuckets' locks are held */
248235
static int inet_csk_bind_conflict(const struct sock *sk,
249236
const struct inet_bind_bucket *tb,
@@ -283,14 +270,6 @@ static int inet_csk_bind_conflict(const struct sock *sk,
283270
return true;
284271
}
285272

286-
twsk_for_each_bound_bhash(sk2, tb2, tb) {
287-
if (!inet_bind_conflict(sk, sk2, uid, relax, reuseport_cb_ok, reuseport_ok))
288-
continue;
289-
290-
if (inet_rcv_saddr_equal(sk, sk2, true))
291-
return true;
292-
}
293-
294273
return false;
295274
}
296275

net/ipv4/inet_hashtables.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ static void inet_bind2_bucket_init(struct inet_bind2_bucket *tb2,
122122
tb2->rcv_saddr = sk->sk_rcv_saddr;
123123
#endif
124124
INIT_HLIST_HEAD(&tb2->owners);
125-
INIT_HLIST_HEAD(&tb2->deathrow);
126125
hlist_add_head(&tb2->node, &head->chain);
127126
hlist_add_head(&tb2->bhash_node, &tb->bhash2);
128127
}
@@ -144,7 +143,7 @@ struct inet_bind2_bucket *inet_bind2_bucket_create(struct kmem_cache *cachep,
144143
/* Caller must hold hashbucket lock for this tb with local BH disabled */
145144
void inet_bind2_bucket_destroy(struct kmem_cache *cachep, struct inet_bind2_bucket *tb)
146145
{
147-
if (hlist_empty(&tb->owners) && hlist_empty(&tb->deathrow)) {
146+
if (hlist_empty(&tb->owners)) {
148147
__hlist_del(&tb->node);
149148
__hlist_del(&tb->bhash_node);
150149
kmem_cache_free(cachep, tb);

0 commit comments

Comments
 (0)