dst.c (87492c06e68d802852c7ba76b4d3fde50807d72a) dst.c (94151f5aa9667c562281abeaaa5e89b9d5c17729)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * net/core/dst.c Protocol independent destination cache.
4 *
5 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
6 *
7 */
8

--- 160 unchanged lines hidden (view full) ---

169 if (dst) {
170 int newrefcnt;
171
172 newrefcnt = atomic_dec_return(&dst->__refcnt);
173 if (WARN_ONCE(newrefcnt < 0, "dst_release underflow"))
174 net_warn_ratelimited("%s: dst:%p refcnt:%d\n",
175 __func__, dst, newrefcnt);
176 if (!newrefcnt)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * net/core/dst.c Protocol independent destination cache.
4 *
5 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
6 *
7 */
8

--- 160 unchanged lines hidden (view full) ---

169 if (dst) {
170 int newrefcnt;
171
172 newrefcnt = atomic_dec_return(&dst->__refcnt);
173 if (WARN_ONCE(newrefcnt < 0, "dst_release underflow"))
174 net_warn_ratelimited("%s: dst:%p refcnt:%d\n",
175 __func__, dst, newrefcnt);
176 if (!newrefcnt)
177 call_rcu_hurry(&dst->rcu_head, dst_destroy_rcu);
177 call_rcu(&dst->rcu_head, dst_destroy_rcu);
178 }
179}
180EXPORT_SYMBOL(dst_release);
181
182void dst_release_immediate(struct dst_entry *dst)
183{
184 if (dst) {
185 int newrefcnt;

--- 125 unchanged lines hidden (view full) ---

311EXPORT_SYMBOL_GPL(metadata_dst_alloc);
312
313void metadata_dst_free(struct metadata_dst *md_dst)
314{
315#ifdef CONFIG_DST_CACHE
316 if (md_dst->type == METADATA_IP_TUNNEL)
317 dst_cache_destroy(&md_dst->u.tun_info.dst_cache);
318#endif
178 }
179}
180EXPORT_SYMBOL(dst_release);
181
182void dst_release_immediate(struct dst_entry *dst)
183{
184 if (dst) {
185 int newrefcnt;

--- 125 unchanged lines hidden (view full) ---

311EXPORT_SYMBOL_GPL(metadata_dst_alloc);
312
313void metadata_dst_free(struct metadata_dst *md_dst)
314{
315#ifdef CONFIG_DST_CACHE
316 if (md_dst->type == METADATA_IP_TUNNEL)
317 dst_cache_destroy(&md_dst->u.tun_info.dst_cache);
318#endif
319 if (md_dst->type == METADATA_XFRM)
320 dst_release(md_dst->u.xfrm_info.dst_orig);
319 kfree(md_dst);
320}
321EXPORT_SYMBOL_GPL(metadata_dst_free);
322
323struct metadata_dst __percpu *
324metadata_dst_alloc_percpu(u8 optslen, enum metadata_type type, gfp_t flags)
325{
326 int cpu;

--- 8 unchanged lines hidden (view full) ---

335 __metadata_dst_init(per_cpu_ptr(md_dst, cpu), type, optslen);
336
337 return md_dst;
338}
339EXPORT_SYMBOL_GPL(metadata_dst_alloc_percpu);
340
341void metadata_dst_free_percpu(struct metadata_dst __percpu *md_dst)
342{
321 kfree(md_dst);
322}
323EXPORT_SYMBOL_GPL(metadata_dst_free);
324
325struct metadata_dst __percpu *
326metadata_dst_alloc_percpu(u8 optslen, enum metadata_type type, gfp_t flags)
327{
328 int cpu;

--- 8 unchanged lines hidden (view full) ---

337 __metadata_dst_init(per_cpu_ptr(md_dst, cpu), type, optslen);
338
339 return md_dst;
340}
341EXPORT_SYMBOL_GPL(metadata_dst_alloc_percpu);
342
343void metadata_dst_free_percpu(struct metadata_dst __percpu *md_dst)
344{
343#ifdef CONFIG_DST_CACHE
344 int cpu;
345
346 for_each_possible_cpu(cpu) {
347 struct metadata_dst *one_md_dst = per_cpu_ptr(md_dst, cpu);
348
345 int cpu;
346
347 for_each_possible_cpu(cpu) {
348 struct metadata_dst *one_md_dst = per_cpu_ptr(md_dst, cpu);
349
350#ifdef CONFIG_DST_CACHE
349 if (one_md_dst->type == METADATA_IP_TUNNEL)
350 dst_cache_destroy(&one_md_dst->u.tun_info.dst_cache);
351 if (one_md_dst->type == METADATA_IP_TUNNEL)
352 dst_cache_destroy(&one_md_dst->u.tun_info.dst_cache);
351 }
352#endif
353#endif
354 if (one_md_dst->type == METADATA_XFRM)
355 dst_release(one_md_dst->u.xfrm_info.dst_orig);
356 }
353 free_percpu(md_dst);
354}
355EXPORT_SYMBOL_GPL(metadata_dst_free_percpu);
357 free_percpu(md_dst);
358}
359EXPORT_SYMBOL_GPL(metadata_dst_free_percpu);