Lines Matching refs:tw

28 void inet_twsk_bind_unhash(struct inet_timewait_sock *tw,  in inet_twsk_bind_unhash()  argument
31 struct inet_bind_bucket *tb = tw->tw_tb; in inet_twsk_bind_unhash()
36 __hlist_del(&tw->tw_bind_node); in inet_twsk_bind_unhash()
37 tw->tw_tb = NULL; in inet_twsk_bind_unhash()
39 __sock_put((struct sock *)tw); in inet_twsk_bind_unhash()
43 static void inet_twsk_kill(struct inet_timewait_sock *tw) in inet_twsk_kill() argument
45 struct inet_hashinfo *hashinfo = tw->tw_dr->hashinfo; in inet_twsk_kill()
46 spinlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash); in inet_twsk_kill()
50 sk_nulls_del_node_init_rcu((struct sock *)tw); in inet_twsk_kill()
54 bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), tw->tw_num, in inet_twsk_kill()
58 inet_twsk_bind_unhash(tw, hashinfo); in inet_twsk_kill()
61 atomic_dec(&tw->tw_dr->tw_count); in inet_twsk_kill()
62 inet_twsk_put(tw); in inet_twsk_kill()
65 void inet_twsk_free(struct inet_timewait_sock *tw) in inet_twsk_free() argument
67 struct module *owner = tw->tw_prot->owner; in inet_twsk_free()
68 twsk_destructor((struct sock *)tw); in inet_twsk_free()
70 pr_debug("%s timewait_sock %p released\n", tw->tw_prot->name, tw); in inet_twsk_free()
72 kmem_cache_free(tw->tw_prot->twsk_prot->twsk_slab, tw); in inet_twsk_free()
76 void inet_twsk_put(struct inet_timewait_sock *tw) in inet_twsk_put() argument
78 if (refcount_dec_and_test(&tw->tw_refcnt)) in inet_twsk_put()
79 inet_twsk_free(tw); in inet_twsk_put()
83 static void inet_twsk_add_node_rcu(struct inet_timewait_sock *tw, in inet_twsk_add_node_rcu() argument
86 hlist_nulls_add_head_rcu(&tw->tw_node, list); in inet_twsk_add_node_rcu()
89 static void inet_twsk_add_bind_node(struct inet_timewait_sock *tw, in inet_twsk_add_bind_node() argument
92 hlist_add_head(&tw->tw_bind_node, list); in inet_twsk_add_bind_node()
100 void inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, in inet_twsk_hashdance() argument
112 bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), inet->inet_num, in inet_twsk_hashdance()
115 tw->tw_tb = icsk->icsk_bind_hash; in inet_twsk_hashdance()
117 inet_twsk_add_bind_node(tw, &tw->tw_tb->owners); in inet_twsk_hashdance()
122 inet_twsk_add_node_rcu(tw, &ehead->chain); in inet_twsk_hashdance()
139 refcount_set(&tw->tw_refcnt, 3); in inet_twsk_hashdance()
145 struct inet_timewait_sock *tw = from_timer(tw, t, tw_timer); in tw_timer_handler() local
147 if (tw->tw_kill) in tw_timer_handler()
148 __NET_INC_STATS(twsk_net(tw), LINUX_MIB_TIMEWAITKILLED); in tw_timer_handler()
150 __NET_INC_STATS(twsk_net(tw), LINUX_MIB_TIMEWAITED); in tw_timer_handler()
151 inet_twsk_kill(tw); in tw_timer_handler()
158 struct inet_timewait_sock *tw; in inet_twsk_alloc() local
163 tw = kmem_cache_alloc(sk->sk_prot_creator->twsk_prot->twsk_slab, in inet_twsk_alloc()
165 if (tw) { in inet_twsk_alloc()
168 tw->tw_dr = dr; in inet_twsk_alloc()
170 tw->tw_daddr = inet->inet_daddr; in inet_twsk_alloc()
171 tw->tw_rcv_saddr = inet->inet_rcv_saddr; in inet_twsk_alloc()
172 tw->tw_bound_dev_if = sk->sk_bound_dev_if; in inet_twsk_alloc()
173 tw->tw_tos = inet->tos; in inet_twsk_alloc()
174 tw->tw_num = inet->inet_num; in inet_twsk_alloc()
175 tw->tw_state = TCP_TIME_WAIT; in inet_twsk_alloc()
176 tw->tw_substate = state; in inet_twsk_alloc()
177 tw->tw_sport = inet->inet_sport; in inet_twsk_alloc()
178 tw->tw_dport = inet->inet_dport; in inet_twsk_alloc()
179 tw->tw_family = sk->sk_family; in inet_twsk_alloc()
180 tw->tw_reuse = sk->sk_reuse; in inet_twsk_alloc()
181 tw->tw_reuseport = sk->sk_reuseport; in inet_twsk_alloc()
182 tw->tw_hash = sk->sk_hash; in inet_twsk_alloc()
183 tw->tw_ipv6only = 0; in inet_twsk_alloc()
184 tw->tw_transparent = inet->transparent; in inet_twsk_alloc()
185 tw->tw_prot = sk->sk_prot_creator; in inet_twsk_alloc()
186 atomic64_set(&tw->tw_cookie, atomic64_read(&sk->sk_cookie)); in inet_twsk_alloc()
187 twsk_net_set(tw, sock_net(sk)); in inet_twsk_alloc()
188 timer_setup(&tw->tw_timer, tw_timer_handler, TIMER_PINNED); in inet_twsk_alloc()
194 refcount_set(&tw->tw_refcnt, 0); in inet_twsk_alloc()
196 __module_get(tw->tw_prot->owner); in inet_twsk_alloc()
199 return tw; in inet_twsk_alloc()
211 void inet_twsk_deschedule_put(struct inet_timewait_sock *tw) in inet_twsk_deschedule_put() argument
213 if (del_timer_sync(&tw->tw_timer)) in inet_twsk_deschedule_put()
214 inet_twsk_kill(tw); in inet_twsk_deschedule_put()
215 inet_twsk_put(tw); in inet_twsk_deschedule_put()
219 void __inet_twsk_schedule(struct inet_timewait_sock *tw, int timeo, bool rearm) in __inet_twsk_schedule() argument
246 tw->tw_kill = timeo <= 4*HZ; in __inet_twsk_schedule()
248 BUG_ON(mod_timer(&tw->tw_timer, jiffies + timeo)); in __inet_twsk_schedule()
249 atomic_inc(&tw->tw_dr->tw_count); in __inet_twsk_schedule()
251 mod_timer_pending(&tw->tw_timer, jiffies + timeo); in __inet_twsk_schedule()
258 struct inet_timewait_sock *tw; in inet_twsk_purge() local
272 tw = inet_twsk(sk); in inet_twsk_purge()
273 if ((tw->tw_family != family) || in inet_twsk_purge()
274 refcount_read(&twsk_net(tw)->count)) in inet_twsk_purge()
277 if (unlikely(!refcount_inc_not_zero(&tw->tw_refcnt))) in inet_twsk_purge()
280 if (unlikely((tw->tw_family != family) || in inet_twsk_purge()
281 refcount_read(&twsk_net(tw)->count))) { in inet_twsk_purge()
282 inet_twsk_put(tw); in inet_twsk_purge()
288 inet_twsk_deschedule_put(tw); in inet_twsk_purge()