Lines Matching refs:dst
55 static void ___dst_free(struct dst_entry *dst);
70 struct dst_entry *dst, *next, head; in dst_gc_task() local
77 while ((dst = next) != NULL) { in dst_gc_task()
78 next = dst->next; in dst_gc_task()
81 if (likely(atomic_read(&dst->__refcnt))) { in dst_gc_task()
82 last->next = dst; in dst_gc_task()
83 last = dst; in dst_gc_task()
89 dst = dst_destroy(dst); in dst_gc_task()
90 if (dst) { in dst_gc_task()
99 if (dst->obsolete > 0) in dst_gc_task()
102 ___dst_free(dst); in dst_gc_task()
103 dst->next = next; in dst_gc_task()
104 next = dst; in dst_gc_task()
163 void dst_init(struct dst_entry *dst, struct dst_ops *ops, in dst_init() argument
167 dst->child = NULL; in dst_init()
168 dst->dev = dev; in dst_init()
171 dst->ops = ops; in dst_init()
172 dst_init_metrics(dst, dst_default_metrics, true); in dst_init()
173 dst->expires = 0UL; in dst_init()
174 dst->path = dst; in dst_init()
175 dst->from = NULL; in dst_init()
177 dst->xfrm = NULL; in dst_init()
179 dst->input = dst_discard; in dst_init()
180 dst->output = dst_discard_out; in dst_init()
181 dst->error = 0; in dst_init()
182 dst->obsolete = initial_obsolete; in dst_init()
183 dst->header_len = 0; in dst_init()
184 dst->trailer_len = 0; in dst_init()
186 dst->tclassid = 0; in dst_init()
188 dst->lwtstate = NULL; in dst_init()
189 atomic_set(&dst->__refcnt, initial_ref); in dst_init()
190 dst->__use = 0; in dst_init()
191 dst->lastuse = jiffies; in dst_init()
192 dst->flags = flags; in dst_init()
193 dst->pending_confirm = 0; in dst_init()
194 dst->next = NULL; in dst_init()
203 struct dst_entry *dst; in dst_alloc() local
210 dst = kmem_cache_alloc(ops->kmem_cachep, GFP_ATOMIC); in dst_alloc()
211 if (!dst) in dst_alloc()
214 dst_init(dst, ops, dev, initial_ref, initial_obsolete, flags); in dst_alloc()
216 return dst; in dst_alloc()
220 static void ___dst_free(struct dst_entry *dst) in ___dst_free() argument
225 if (dst->dev == NULL || !(dst->dev->flags&IFF_UP)) { in ___dst_free()
226 dst->input = dst_discard; in ___dst_free()
227 dst->output = dst_discard_out; in ___dst_free()
229 dst->obsolete = DST_OBSOLETE_DEAD; in ___dst_free()
232 void __dst_free(struct dst_entry *dst) in __dst_free() argument
235 ___dst_free(dst); in __dst_free()
236 dst->next = dst_garbage.list; in __dst_free()
237 dst_garbage.list = dst; in __dst_free()
248 struct dst_entry *dst_destroy(struct dst_entry * dst) in dst_destroy() argument
255 child = dst->child; in dst_destroy()
257 if (!(dst->flags & DST_NOCOUNT)) in dst_destroy()
258 dst_entries_add(dst->ops, -1); in dst_destroy()
260 if (dst->ops->destroy) in dst_destroy()
261 dst->ops->destroy(dst); in dst_destroy()
262 if (dst->dev) in dst_destroy()
263 dev_put(dst->dev); in dst_destroy()
265 lwtstate_put(dst->lwtstate); in dst_destroy()
267 if (dst->flags & DST_METADATA) in dst_destroy()
268 kfree(dst); in dst_destroy()
270 kmem_cache_free(dst->ops->kmem_cachep, dst); in dst_destroy()
272 dst = child; in dst_destroy()
273 if (dst) { in dst_destroy()
274 int nohash = dst->flags & DST_NOHASH; in dst_destroy()
276 if (atomic_dec_and_test(&dst->__refcnt)) { in dst_destroy()
283 return dst; in dst_destroy()
293 struct dst_entry *dst = container_of(head, struct dst_entry, rcu_head); in dst_destroy_rcu() local
295 dst = dst_destroy(dst); in dst_destroy_rcu()
296 if (dst) in dst_destroy_rcu()
297 __dst_free(dst); in dst_destroy_rcu()
300 void dst_release(struct dst_entry *dst) in dst_release() argument
302 if (dst) { in dst_release()
304 unsigned short nocache = dst->flags & DST_NOCACHE; in dst_release()
306 newrefcnt = atomic_dec_return(&dst->__refcnt); in dst_release()
309 __func__, dst, newrefcnt); in dst_release()
311 call_rcu(&dst->rcu_head, dst_destroy_rcu); in dst_release()
316 u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old) in dst_cow_metrics_generic() argument
327 prev = cmpxchg(&dst->_metrics, old, new); in dst_cow_metrics_generic()
341 void __dst_destroy_metrics_generic(struct dst_entry *dst, unsigned long old) in __dst_destroy_metrics_generic() argument
346 prev = cmpxchg(&dst->_metrics, old, new); in __dst_destroy_metrics_generic()
372 struct dst_entry *dst; in __metadata_dst_init() local
374 dst = &md_dst->dst; in __metadata_dst_init()
375 dst_init(dst, &md_dst_ops, NULL, 1, DST_OBSOLETE_NONE, in __metadata_dst_init()
378 dst->input = dst_md_discard; in __metadata_dst_init()
379 dst->output = dst_md_discard_out; in __metadata_dst_init()
381 memset(dst + 1, 0, sizeof(*md_dst) + optslen - sizeof(*dst)); in __metadata_dst_init()
423 static void dst_ifdown(struct dst_entry *dst, struct net_device *dev, in dst_ifdown() argument
426 if (dst->ops->ifdown) in dst_ifdown()
427 dst->ops->ifdown(dst, dev, unregister); in dst_ifdown()
429 if (dev != dst->dev) in dst_ifdown()
433 dst->input = dst_discard; in dst_ifdown()
434 dst->output = dst_discard_out; in dst_ifdown()
436 dst->dev = dev_net(dst->dev)->loopback_dev; in dst_ifdown()
437 dev_hold(dst->dev); in dst_ifdown()
446 struct dst_entry *dst, *last = NULL; in dst_dev_event() local
452 for (dst = dst_busy_list; dst; dst = dst->next) { in dst_dev_event()
453 last = dst; in dst_dev_event()
454 dst_ifdown(dst, dev, event != NETDEV_DOWN); in dst_dev_event()
458 dst = dst_garbage.list; in dst_dev_event()
463 last->next = dst; in dst_dev_event()
465 dst_busy_list = dst; in dst_dev_event()
466 for (; dst; dst = dst->next) in dst_dev_event()
467 dst_ifdown(dst, dev, event != NETDEV_DOWN); in dst_dev_event()