Skip to content

Commit 770041d

Browse files
q2vendavem330
authored andcommitted
tcp: Link sk and twsk to tb2->owners using skc_bind_node.
Now we can use sk_bind_node/tw_bind_node for bhash2, which means we need not link TIME_WAIT sockets separately. The dead code and sk_bind2_node will be removed in the next patch. Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b2cb9f9 commit 770041d

File tree

5 files changed

+9
-26
lines changed

5 files changed

+9
-26
lines changed

include/net/sock.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -873,16 +873,6 @@ static inline void sk_add_bind_node(struct sock *sk,
873873
hlist_add_head(&sk->sk_bind_node, list);
874874
}
875875

876-
static inline void __sk_del_bind2_node(struct sock *sk)
877-
{
878-
__hlist_del(&sk->sk_bind2_node);
879-
}
880-
881-
static inline void sk_add_bind2_node(struct sock *sk, struct hlist_head *list)
882-
{
883-
hlist_add_head(&sk->sk_bind2_node, list);
884-
}
885-
886876
#define sk_for_each(__sk, list) \
887877
hlist_for_each_entry(__sk, list, sk_node)
888878
#define sk_for_each_rcu(__sk, list) \

net/ipv4/inet_connection_sock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static bool inet_bhash2_conflict(const struct sock *sk,
219219
struct inet_timewait_sock *tw2;
220220
struct sock *sk2;
221221

222-
sk_for_each_bound_bhash2(sk2, &tb2->owners) {
222+
sk_for_each_bound(sk2, &tb2->owners) {
223223
if (__inet_bhash2_conflict(sk, sk2, sk_uid, relax,
224224
reuseport_cb_ok, reuseport_ok))
225225
return true;
@@ -238,7 +238,7 @@ static bool inet_bhash2_conflict(const struct sock *sk,
238238

239239
#define sk_for_each_bound_bhash(__sk, __tb2, __tb) \
240240
hlist_for_each_entry(__tb2, &(__tb)->bhash2, bhash_node) \
241-
sk_for_each_bound_bhash2(sk2, &(__tb2)->owners)
241+
sk_for_each_bound(sk2, &(__tb2)->owners)
242242

243243
#define twsk_for_each_bound_bhash(__sk, __tb2, __tb) \
244244
hlist_for_each_entry(__tb2, &(__tb)->bhash2, bhash_node) \

net/ipv4/inet_diag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ void inet_diag_dump_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *skb,
11041104
if (!net_eq(ib2_net(tb2), net))
11051105
continue;
11061106

1107-
sk_for_each_bound_bhash2(sk, &tb2->owners) {
1107+
sk_for_each_bound(sk, &tb2->owners) {
11081108
struct inet_sock *inet = inet_sk(sk);
11091109

11101110
if (num < s_num)

net/ipv4/inet_hashtables.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb,
169169
{
170170
inet_sk(sk)->inet_num = port;
171171
inet_csk(sk)->icsk_bind_hash = tb;
172-
sk_add_bind2_node(sk, &tb2->owners);
173172
inet_csk(sk)->icsk_bind2_hash = tb2;
173+
sk_add_bind_node(sk, &tb2->owners);
174174
}
175175

176176
/*
@@ -197,7 +197,7 @@ static void __inet_put_port(struct sock *sk)
197197
if (inet_csk(sk)->icsk_bind2_hash) {
198198
struct inet_bind2_bucket *tb2 = inet_csk(sk)->icsk_bind2_hash;
199199

200-
__sk_del_bind2_node(sk);
200+
__sk_del_bind_node(sk);
201201
inet_csk(sk)->icsk_bind2_hash = NULL;
202202
inet_bind2_bucket_destroy(hashinfo->bind2_bucket_cachep, tb2);
203203
}
@@ -937,7 +937,7 @@ static int __inet_bhash2_update_saddr(struct sock *sk, void *saddr, int family,
937937
spin_lock_bh(&head->lock);
938938

939939
spin_lock(&head2->lock);
940-
__sk_del_bind2_node(sk);
940+
__sk_del_bind_node(sk);
941941
inet_bind2_bucket_destroy(hinfo->bind2_bucket_cachep, inet_csk(sk)->icsk_bind2_hash);
942942
spin_unlock(&head2->lock);
943943

@@ -954,8 +954,8 @@ static int __inet_bhash2_update_saddr(struct sock *sk, void *saddr, int family,
954954
tb2 = new_tb2;
955955
inet_bind2_bucket_init(tb2, net, head2, inet_csk(sk)->icsk_bind_hash, sk);
956956
}
957-
sk_add_bind2_node(sk, &tb2->owners);
958957
inet_csk(sk)->icsk_bind2_hash = tb2;
958+
sk_add_bind_node(sk, &tb2->owners);
959959
spin_unlock(&head2->lock);
960960

961961
spin_unlock_bh(&head->lock);

net/ipv4/inet_timewait_sock.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ void inet_twsk_bind_unhash(struct inet_timewait_sock *tw,
3535
if (!tb)
3636
return;
3737

38+
__sk_del_bind_node((struct sock *)tw);
3839
tw->tw_tb = NULL;
39-
40-
__hlist_del(&tw->tw_bind2_node);
4140
tw->tw_tb2 = NULL;
4241
inet_bind2_bucket_destroy(hashinfo->bind2_bucket_cachep, tb2);
4342
inet_bind_bucket_destroy(hashinfo->bind_bucket_cachep, tb);
@@ -93,12 +92,6 @@ static void inet_twsk_add_node_rcu(struct inet_timewait_sock *tw,
9392
hlist_nulls_add_head_rcu(&tw->tw_node, list);
9493
}
9594

96-
static void inet_twsk_add_bind2_node(struct inet_timewait_sock *tw,
97-
struct hlist_head *list)
98-
{
99-
hlist_add_head(&tw->tw_bind2_node, list);
100-
}
101-
10295
/*
10396
* Enter the time wait state. This is called with locally disabled BH.
10497
* Essentially we whip up a timewait bucket, copy the relevant info into it
@@ -129,7 +122,7 @@ void inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
129122

130123
tw->tw_tb2 = icsk->icsk_bind2_hash;
131124
WARN_ON(!icsk->icsk_bind2_hash);
132-
inet_twsk_add_bind2_node(tw, &tw->tw_tb2->deathrow);
125+
sk_add_bind_node((struct sock *)tw, &tw->tw_tb2->owners);
133126

134127
spin_unlock(&bhead2->lock);
135128
spin_unlock(&bhead->lock);

0 commit comments

Comments
 (0)