Lines Matching refs:tw
29 void inet_twsk_bind_unhash(struct inet_timewait_sock *tw, in inet_twsk_bind_unhash() argument
32 struct inet_bind2_bucket *tb2 = tw->tw_tb2; in inet_twsk_bind_unhash()
33 struct inet_bind_bucket *tb = tw->tw_tb; in inet_twsk_bind_unhash()
38 __hlist_del(&tw->tw_bind_node); in inet_twsk_bind_unhash()
39 tw->tw_tb = NULL; in inet_twsk_bind_unhash()
42 __hlist_del(&tw->tw_bind2_node); in inet_twsk_bind_unhash()
43 tw->tw_tb2 = NULL; in inet_twsk_bind_unhash()
46 __sock_put((struct sock *)tw); in inet_twsk_bind_unhash()
50 static void inet_twsk_kill(struct inet_timewait_sock *tw) in inet_twsk_kill() argument
52 struct inet_hashinfo *hashinfo = tw->tw_dr->hashinfo; in inet_twsk_kill()
53 spinlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash); in inet_twsk_kill()
57 sk_nulls_del_node_init_rcu((struct sock *)tw); in inet_twsk_kill()
61 bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), tw->tw_num, in inet_twsk_kill()
63 bhead2 = inet_bhashfn_portaddr(hashinfo, (struct sock *)tw, in inet_twsk_kill()
64 twsk_net(tw), tw->tw_num); in inet_twsk_kill()
68 inet_twsk_bind_unhash(tw, hashinfo); in inet_twsk_kill()
72 refcount_dec(&tw->tw_dr->tw_refcount); in inet_twsk_kill()
73 inet_twsk_put(tw); in inet_twsk_kill()
76 void inet_twsk_free(struct inet_timewait_sock *tw) in inet_twsk_free() argument
78 struct module *owner = tw->tw_prot->owner; in inet_twsk_free()
79 twsk_destructor((struct sock *)tw); in inet_twsk_free()
80 kmem_cache_free(tw->tw_prot->twsk_prot->twsk_slab, tw); in inet_twsk_free()
84 void inet_twsk_put(struct inet_timewait_sock *tw) in inet_twsk_put() argument
86 if (refcount_dec_and_test(&tw->tw_refcnt)) in inet_twsk_put()
87 inet_twsk_free(tw); in inet_twsk_put()
91 static void inet_twsk_add_node_rcu(struct inet_timewait_sock *tw, in inet_twsk_add_node_rcu() argument
94 hlist_nulls_add_head_rcu(&tw->tw_node, list); in inet_twsk_add_node_rcu()
97 static void inet_twsk_add_bind_node(struct inet_timewait_sock *tw, in inet_twsk_add_bind_node() argument
100 hlist_add_head(&tw->tw_bind_node, list); in inet_twsk_add_bind_node()
103 static void inet_twsk_add_bind2_node(struct inet_timewait_sock *tw, in inet_twsk_add_bind2_node() argument
106 hlist_add_head(&tw->tw_bind2_node, list); in inet_twsk_add_bind2_node()
114 void inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, in inet_twsk_hashdance() argument
127 bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), inet->inet_num, in inet_twsk_hashdance()
129 bhead2 = inet_bhashfn_portaddr(hashinfo, sk, twsk_net(tw), inet->inet_num); in inet_twsk_hashdance()
134 tw->tw_tb = icsk->icsk_bind_hash; in inet_twsk_hashdance()
136 inet_twsk_add_bind_node(tw, &tw->tw_tb->owners); in inet_twsk_hashdance()
138 tw->tw_tb2 = icsk->icsk_bind2_hash; in inet_twsk_hashdance()
140 inet_twsk_add_bind2_node(tw, &tw->tw_tb2->deathrow); in inet_twsk_hashdance()
147 inet_twsk_add_node_rcu(tw, &ehead->chain); in inet_twsk_hashdance()
164 refcount_set(&tw->tw_refcnt, 3); in inet_twsk_hashdance()
170 struct inet_timewait_sock *tw = from_timer(tw, t, tw_timer); in tw_timer_handler() local
172 inet_twsk_kill(tw); in tw_timer_handler()
179 struct inet_timewait_sock *tw; in inet_twsk_alloc() local
185 tw = kmem_cache_alloc(sk->sk_prot_creator->twsk_prot->twsk_slab, in inet_twsk_alloc()
187 if (tw) { in inet_twsk_alloc()
190 tw->tw_dr = dr; in inet_twsk_alloc()
192 tw->tw_daddr = inet->inet_daddr; in inet_twsk_alloc()
193 tw->tw_rcv_saddr = inet->inet_rcv_saddr; in inet_twsk_alloc()
194 tw->tw_bound_dev_if = sk->sk_bound_dev_if; in inet_twsk_alloc()
195 tw->tw_tos = inet->tos; in inet_twsk_alloc()
196 tw->tw_num = inet->inet_num; in inet_twsk_alloc()
197 tw->tw_state = TCP_TIME_WAIT; in inet_twsk_alloc()
198 tw->tw_substate = state; in inet_twsk_alloc()
199 tw->tw_sport = inet->inet_sport; in inet_twsk_alloc()
200 tw->tw_dport = inet->inet_dport; in inet_twsk_alloc()
201 tw->tw_family = sk->sk_family; in inet_twsk_alloc()
202 tw->tw_reuse = sk->sk_reuse; in inet_twsk_alloc()
203 tw->tw_reuseport = sk->sk_reuseport; in inet_twsk_alloc()
204 tw->tw_hash = sk->sk_hash; in inet_twsk_alloc()
205 tw->tw_ipv6only = 0; in inet_twsk_alloc()
206 tw->tw_transparent = inet_test_bit(TRANSPARENT, sk); in inet_twsk_alloc()
207 tw->tw_prot = sk->sk_prot_creator; in inet_twsk_alloc()
208 atomic64_set(&tw->tw_cookie, atomic64_read(&sk->sk_cookie)); in inet_twsk_alloc()
209 twsk_net_set(tw, sock_net(sk)); in inet_twsk_alloc()
210 timer_setup(&tw->tw_timer, tw_timer_handler, TIMER_PINNED); in inet_twsk_alloc()
216 refcount_set(&tw->tw_refcnt, 0); in inet_twsk_alloc()
218 __module_get(tw->tw_prot->owner); in inet_twsk_alloc()
221 return tw; in inet_twsk_alloc()
233 void inet_twsk_deschedule_put(struct inet_timewait_sock *tw) in inet_twsk_deschedule_put() argument
235 if (del_timer_sync(&tw->tw_timer)) in inet_twsk_deschedule_put()
236 inet_twsk_kill(tw); in inet_twsk_deschedule_put()
237 inet_twsk_put(tw); in inet_twsk_deschedule_put()
241 void __inet_twsk_schedule(struct inet_timewait_sock *tw, int timeo, bool rearm) in __inet_twsk_schedule() argument
271 __NET_INC_STATS(twsk_net(tw), kill ? LINUX_MIB_TIMEWAITKILLED : in __inet_twsk_schedule()
273 BUG_ON(mod_timer(&tw->tw_timer, jiffies + timeo)); in __inet_twsk_schedule()
274 refcount_inc(&tw->tw_dr->tw_refcount); in __inet_twsk_schedule()
276 mod_timer_pending(&tw->tw_timer, jiffies + timeo); in __inet_twsk_schedule()
283 struct inet_timewait_sock *tw; in inet_twsk_purge() local
310 tw = inet_twsk(sk); in inet_twsk_purge()
311 if ((tw->tw_family != family) || in inet_twsk_purge()
312 refcount_read(&twsk_net(tw)->ns.count)) in inet_twsk_purge()
315 if (unlikely(!refcount_inc_not_zero(&tw->tw_refcnt))) in inet_twsk_purge()
318 if (unlikely((tw->tw_family != family) || in inet_twsk_purge()
319 refcount_read(&twsk_net(tw)->ns.count))) { in inet_twsk_purge()
320 inet_twsk_put(tw); in inet_twsk_purge()
326 inet_twsk_deschedule_put(tw); in inet_twsk_purge()