Lines Matching refs:f
56 inet_frag_hashfn(const struct inet_frags *f, const struct inet_frag_queue *q) in inet_frag_hashfn() argument
58 return f->hashfn(q) & (INETFRAGS_HASHSZ - 1); in inet_frag_hashfn()
61 static bool inet_frag_may_rebuild(struct inet_frags *f) in inet_frag_may_rebuild() argument
64 f->last_rebuild_jiffies + INETFRAGS_MIN_REBUILD_INTERVAL); in inet_frag_may_rebuild()
67 static void inet_frag_secret_rebuild(struct inet_frags *f) in inet_frag_secret_rebuild() argument
71 write_seqlock_bh(&f->rnd_seqlock); in inet_frag_secret_rebuild()
73 if (!inet_frag_may_rebuild(f)) in inet_frag_secret_rebuild()
76 get_random_bytes(&f->rnd, sizeof(u32)); in inet_frag_secret_rebuild()
83 hb = &f->hash[i]; in inet_frag_secret_rebuild()
87 unsigned int hval = inet_frag_hashfn(f, q); in inet_frag_secret_rebuild()
95 hb_dest = &f->hash[hval]; in inet_frag_secret_rebuild()
114 f->rebuild = false; in inet_frag_secret_rebuild()
115 f->last_rebuild_jiffies = jiffies; in inet_frag_secret_rebuild()
117 write_sequnlock_bh(&f->rnd_seqlock); in inet_frag_secret_rebuild()
127 inet_evict_bucket(struct inet_frags *f, struct inet_frag_bucket *hb) in inet_evict_bucket() argument
150 f->frag_expire((unsigned long) fq); in inet_evict_bucket()
159 struct inet_frags *f; in inet_frag_worker() local
161 f = container_of(work, struct inet_frags, frags_work); in inet_frag_worker()
167 for (i = ACCESS_ONCE(f->next_bucket); budget; --budget) { in inet_frag_worker()
168 evicted += inet_evict_bucket(f, &f->hash[i]); in inet_frag_worker()
174 f->next_bucket = i; in inet_frag_worker()
178 if (f->rebuild && inet_frag_may_rebuild(f)) in inet_frag_worker()
179 inet_frag_secret_rebuild(f); in inet_frag_worker()
182 static void inet_frag_schedule_worker(struct inet_frags *f) in inet_frag_schedule_worker() argument
184 if (unlikely(!work_pending(&f->frags_work))) in inet_frag_schedule_worker()
185 schedule_work(&f->frags_work); in inet_frag_schedule_worker()
188 int inet_frags_init(struct inet_frags *f) in inet_frags_init() argument
192 INIT_WORK(&f->frags_work, inet_frag_worker); in inet_frags_init()
195 struct inet_frag_bucket *hb = &f->hash[i]; in inet_frags_init()
201 seqlock_init(&f->rnd_seqlock); in inet_frags_init()
202 f->last_rebuild_jiffies = 0; in inet_frags_init()
203 f->frags_cachep = kmem_cache_create(f->frags_cache_name, f->qsize, 0, 0, in inet_frags_init()
205 if (!f->frags_cachep) in inet_frags_init()
212 void inet_frags_fini(struct inet_frags *f) in inet_frags_fini() argument
214 cancel_work_sync(&f->frags_work); in inet_frags_fini()
215 kmem_cache_destroy(f->frags_cachep); in inet_frags_fini()
219 void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f) in inet_frags_exit_net() argument
228 seq = read_seqbegin(&f->rnd_seqlock); in inet_frags_exit_net()
231 inet_evict_bucket(f, &f->hash[i]); in inet_frags_exit_net()
236 if (read_seqretry(&f->rnd_seqlock, seq) || in inet_frags_exit_net()
245 get_frag_bucket_locked(struct inet_frag_queue *fq, struct inet_frags *f) in get_frag_bucket_locked() argument
252 seq = read_seqbegin(&f->rnd_seqlock); in get_frag_bucket_locked()
254 hash = inet_frag_hashfn(f, fq); in get_frag_bucket_locked()
255 hb = &f->hash[hash]; in get_frag_bucket_locked()
258 if (read_seqretry(&f->rnd_seqlock, seq)) { in get_frag_bucket_locked()
266 static inline void fq_unlink(struct inet_frag_queue *fq, struct inet_frags *f) in fq_unlink() argument
270 hb = get_frag_bucket_locked(fq, f); in fq_unlink()
276 void inet_frag_kill(struct inet_frag_queue *fq, struct inet_frags *f) in inet_frag_kill() argument
282 fq_unlink(fq, f); in inet_frag_kill()
288 static inline void frag_kfree_skb(struct netns_frags *nf, struct inet_frags *f, in frag_kfree_skb() argument
291 if (f->skb_free) in frag_kfree_skb()
292 f->skb_free(skb); in frag_kfree_skb()
296 void inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f) in inet_frag_destroy() argument
312 frag_kfree_skb(nf, f, fp); in inet_frag_destroy()
315 sum = sum_truesize + f->qsize; in inet_frag_destroy()
317 if (f->destructor) in inet_frag_destroy()
318 f->destructor(q); in inet_frag_destroy()
319 kmem_cache_free(f->frags_cachep, q); in inet_frag_destroy()
327 struct inet_frags *f, in inet_frag_intern() argument
330 struct inet_frag_bucket *hb = get_frag_bucket_locked(qp_in, f); in inet_frag_intern()
339 if (qp->net == nf && f->match(qp, arg)) { in inet_frag_intern()
343 inet_frag_put(qp_in, f); in inet_frag_intern()
361 struct inet_frags *f, in inet_frag_alloc() argument
367 inet_frag_schedule_worker(f); in inet_frag_alloc()
371 q = kmem_cache_zalloc(f->frags_cachep, GFP_ATOMIC); in inet_frag_alloc()
376 f->constructor(q, arg); in inet_frag_alloc()
377 add_frag_mem_limit(nf, f->qsize); in inet_frag_alloc()
379 setup_timer(&q->timer, f->frag_expire, (unsigned long)q); in inet_frag_alloc()
387 struct inet_frags *f, in inet_frag_create() argument
392 q = inet_frag_alloc(nf, f, arg); in inet_frag_create()
396 return inet_frag_intern(nf, q, f, arg); in inet_frag_create()
400 struct inet_frags *f, void *key, in inet_frag_find() argument
408 inet_frag_schedule_worker(f); in inet_frag_find()
411 hb = &f->hash[hash]; in inet_frag_find()
415 if (q->net == nf && f->match(q, key)) { in inet_frag_find()
425 return inet_frag_create(nf, f, key); in inet_frag_find()
427 if (inet_frag_may_rebuild(f)) { in inet_frag_find()
428 if (!f->rebuild) in inet_frag_find()
429 f->rebuild = true; in inet_frag_find()
430 inet_frag_schedule_worker(f); in inet_frag_find()