Lines Matching +full:one +full:- +full:timer +full:- +full:only

1 // SPDX-License-Identifier: GPL-2.0-only
22 * inet_twsk_bind_unhash - unhash a timewait socket from bind hash
33 struct inet_bind2_bucket *tb2 = tw->tw_tb2;
34 struct inet_bind_bucket *tb = tw->tw_tb;
40 tw->tw_tb = NULL;
41 tw->tw_tb2 = NULL;
42 inet_bind2_bucket_destroy(hashinfo->bind2_bucket_cachep, tb2);
51 struct inet_hashinfo *hashinfo = tw->tw_dr->hashinfo;
52 spinlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash);
60 bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), tw->tw_num,
61 hashinfo->bhash_size)];
63 twsk_net(tw), tw->tw_num);
65 spin_lock(&bhead->lock);
66 spin_lock(&bhead2->lock);
68 spin_unlock(&bhead2->lock);
69 spin_unlock(&bhead->lock);
71 refcount_dec(&tw->tw_dr->tw_refcount);
77 struct module *owner = tw->tw_prot->owner;
80 kmem_cache_free(tw->tw_prot->twsk_prot->twsk_slab, tw);
86 if (refcount_dec_and_test(&tw->tw_refcnt))
94 hlist_nulls_add_head_rcu(&tw->tw_node, list);
116 struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, sk->sk_hash);
117 spinlock_t *lock = inet_ehash_lockp(hashinfo, sk->sk_hash);
121 Note, that any socket with inet->num != 0 MUST be bound in
124 bhead = &hashinfo->bhash[inet_bhashfn(twsk_net(tw), inet->inet_num,
125 hashinfo->bhash_size)];
126 bhead2 = inet_bhashfn_portaddr(hashinfo, sk, twsk_net(tw), inet->inet_num);
129 spin_lock(&bhead->lock);
130 spin_lock(&bhead2->lock);
132 tw->tw_tb = icsk->icsk_bind_hash;
133 WARN_ON(!icsk->icsk_bind_hash);
135 tw->tw_tb2 = icsk->icsk_bind2_hash;
136 WARN_ON(!icsk->icsk_bind2_hash);
137 sk_add_bind_node((struct sock *)tw, &tw->tw_tb2->owners);
139 spin_unlock(&bhead2->lock);
140 spin_unlock(&bhead->lock);
145 inet_twsk_add_node_rcu(tw, &ehead->chain);
149 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
158 * - one reference for bhash chain.
159 * - one reference for ehash chain.
160 * - one reference for timer.
164 refcount_set(&tw->tw_refcnt, 3);
185 if (refcount_read(&dr->tw_refcount) - 1 >=
186 READ_ONCE(dr->sysctl_max_tw_buckets))
189 tw = kmem_cache_alloc(sk->sk_prot_creator->twsk_prot->twsk_slab,
194 tw->tw_dr = dr;
196 tw->tw_daddr = inet->inet_daddr;
197 tw->tw_rcv_saddr = inet->inet_rcv_saddr;
198 tw->tw_bound_dev_if = sk->sk_bound_dev_if;
199 tw->tw_tos = inet->tos;
200 tw->tw_num = inet->inet_num;
201 tw->tw_state = TCP_TIME_WAIT;
202 tw->tw_substate = state;
203 tw->tw_sport = inet->inet_sport;
204 tw->tw_dport = inet->inet_dport;
205 tw->tw_family = sk->sk_family;
206 tw->tw_reuse = sk->sk_reuse;
207 tw->tw_reuseport = sk->sk_reuseport;
208 tw->tw_hash = sk->sk_hash;
209 tw->tw_ipv6only = 0;
210 tw->tw_transparent = inet_test_bit(TRANSPARENT, sk);
211 tw->tw_connect_bind = !!(sk->sk_userlocks & SOCK_CONNECT_BIND);
212 tw->tw_prot = sk->sk_prot_creator;
213 atomic64_set(&tw->tw_cookie, atomic64_read(&sk->sk_cookie));
215 timer_setup(&tw->tw_timer, tw_timer_handler, 0);
217 tw->tw_validate_xmit_skb = NULL;
224 refcount_set(&tw->tw_refcnt, 0);
226 __module_get(tw->tw_prot->owner);
237 /* This is for handling early-kills of TIME_WAIT sockets.
243 struct inet_hashinfo *hashinfo = tw->tw_dr->hashinfo;
244 spinlock_t *lock = inet_ehash_lockp(hashinfo, tw->tw_hash);
251 * arming the timer, i.e. inet_twsk_purge can obtain a reference to
252 * a twsk that did not yet schedule the timer.
255 * After acquiring the lock, the timer is always scheduled (else
257 * the ehash lock only after completing the timer initialization.
262 * 3) cpu y calls inet_twsk_deschedule_put() and shuts timer down
263 * 4) cpu x tries to start timer, but mod_timer is a noop post-shutdown
264 * -> timer refcount is never decremented.
270 if (timer_shutdown_sync(&tw->tw_timer))
282 * RATIONALE: if FIN arrived and we entered TIME-WAIT state,
286 * time to detect the loss is about RTO*(2^N - 1) with exponential
288 * waited at least for one retransmitted FIN (maximal RTO is 120sec).
290 * only for 60sec, we should wait at least for 240 secs.
308 BUG_ON(mod_timer(&tw->tw_timer, jiffies + timeo));
309 refcount_inc(&tw->tw_dr->tw_refcount);
311 mod_timer_pending(&tw->tw_timer, jiffies + timeo);
318 struct inet_ehash_bucket *head = &hashinfo->ehash[0];
319 unsigned int ehash_mask = hashinfo->ehash_mask;
325 if (hlist_nulls_empty(&head->chain))
332 sk_nulls_for_each_rcu(sk, node, &head->chain) {
342 if (unlikely(!refcount_inc_not_zero(&sk->sk_refcnt)))
357 inet_csk_reqsk_queue_drop_and_put(req->rsk_listener,
364 * not the expected one, we must restart lookup.