Lines Matching full:dst
3 * net/core/dst.c Protocol independent destination cache.
27 #include <net/dst.h>
47 void dst_init(struct dst_entry *dst, struct dst_ops *ops, in dst_init() argument
51 dst->dev = dev; in dst_init()
52 netdev_hold(dev, &dst->dev_tracker, GFP_ATOMIC); in dst_init()
53 dst->ops = ops; in dst_init()
54 dst_init_metrics(dst, dst_default_metrics.metrics, true); in dst_init()
55 dst->expires = 0UL; in dst_init()
57 dst->xfrm = NULL; in dst_init()
59 dst->input = dst_discard; in dst_init()
60 dst->output = dst_discard_out; in dst_init()
61 dst->error = 0; in dst_init()
62 dst->obsolete = initial_obsolete; in dst_init()
63 dst->header_len = 0; in dst_init()
64 dst->trailer_len = 0; in dst_init()
66 dst->tclassid = 0; in dst_init()
68 dst->lwtstate = NULL; in dst_init()
69 rcuref_init(&dst->__rcuref, 1); in dst_init()
70 INIT_LIST_HEAD(&dst->rt_uncached); in dst_init()
71 dst->rt_uncached_list = NULL; in dst_init()
72 dst->__use = 0; in dst_init()
73 dst->lastuse = jiffies; in dst_init()
74 dst->flags = flags; in dst_init()
83 struct dst_entry *dst; in dst_alloc() local
90 dst = kmem_cache_alloc(ops->kmem_cachep, GFP_ATOMIC); in dst_alloc()
91 if (!dst) in dst_alloc()
94 dst_init(dst, ops, dev, initial_obsolete, flags); in dst_alloc()
96 return dst; in dst_alloc()
100 static void dst_destroy(struct dst_entry *dst) in dst_destroy() argument
107 if (dst->xfrm) { in dst_destroy()
108 struct xfrm_dst *xdst = (struct xfrm_dst *) dst; in dst_destroy()
113 if (dst->ops->destroy) in dst_destroy()
114 dst->ops->destroy(dst); in dst_destroy()
115 netdev_put(dst->dev, &dst->dev_tracker); in dst_destroy()
117 lwtstate_put(dst->lwtstate); in dst_destroy()
119 if (dst->flags & DST_METADATA) in dst_destroy()
120 metadata_dst_free((struct metadata_dst *)dst); in dst_destroy()
122 kmem_cache_free(dst->ops->kmem_cachep, dst); in dst_destroy()
124 dst = child; in dst_destroy()
125 if (dst) in dst_destroy()
126 dst_release_immediate(dst); in dst_destroy()
131 struct dst_entry *dst = container_of(head, struct dst_entry, rcu_head); in dst_destroy_rcu() local
133 dst_destroy(dst); in dst_destroy_rcu()
136 /* Operations to mark dst as DEAD and clean up the net device referenced
137 * by dst:
138 * 1. put the dst under blackhole interface and discard all tx/rx packets
145 void dst_dev_put(struct dst_entry *dst) in dst_dev_put() argument
147 struct net_device *dev = dst->dev; in dst_dev_put()
149 WRITE_ONCE(dst->obsolete, DST_OBSOLETE_DEAD); in dst_dev_put()
150 if (dst->ops->ifdown) in dst_dev_put()
151 dst->ops->ifdown(dst, dev); in dst_dev_put()
152 WRITE_ONCE(dst->input, dst_discard); in dst_dev_put()
153 WRITE_ONCE(dst->output, dst_discard_out); in dst_dev_put()
154 rcu_assign_pointer(dst->dev_rcu, blackhole_netdev); in dst_dev_put()
155 netdev_ref_replace(dev, blackhole_netdev, &dst->dev_tracker, in dst_dev_put()
160 static void dst_count_dec(struct dst_entry *dst) in dst_count_dec() argument
162 if (!(dst->flags & DST_NOCOUNT)) in dst_count_dec()
163 dst_entries_add(dst->ops, -1); in dst_count_dec()
166 void dst_release(struct dst_entry *dst) in dst_release() argument
168 if (dst && rcuref_put(&dst->__rcuref)) { in dst_release()
170 if (dst->flags & DST_METADATA) { in dst_release()
171 struct metadata_dst *md_dst = (struct metadata_dst *)dst; in dst_release()
177 dst_count_dec(dst); in dst_release()
178 call_rcu_hurry(&dst->rcu_head, dst_destroy_rcu); in dst_release()
183 void dst_release_immediate(struct dst_entry *dst) in dst_release_immediate() argument
185 if (dst && rcuref_put(&dst->__rcuref)) { in dst_release_immediate()
186 dst_count_dec(dst); in dst_release_immediate()
187 dst_destroy(dst); in dst_release_immediate()
192 u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old) in dst_cow_metrics_generic() argument
204 prev = cmpxchg(&dst->_metrics, old, new); in dst_cow_metrics_generic()
221 /* Caller asserts that dst_metrics_read_only(dst) is false. */
222 void __dst_destroy_metrics_generic(struct dst_entry *dst, unsigned long old) in __dst_destroy_metrics_generic() argument
227 prev = cmpxchg(&dst->_metrics, old, new); in __dst_destroy_metrics_generic()
233 struct dst_entry *dst_blackhole_check(struct dst_entry *dst, u32 cookie) in dst_blackhole_check() argument
238 u32 *dst_blackhole_cow_metrics(struct dst_entry *dst, unsigned long old) in dst_blackhole_cow_metrics() argument
243 struct neighbour *dst_blackhole_neigh_lookup(const struct dst_entry *dst, in dst_blackhole_neigh_lookup() argument
250 void dst_blackhole_update_pmtu(struct dst_entry *dst, struct sock *sk, in dst_blackhole_update_pmtu() argument
257 void dst_blackhole_redirect(struct dst_entry *dst, struct sock *sk, in dst_blackhole_redirect() argument
263 unsigned int dst_blackhole_mtu(const struct dst_entry *dst) in dst_blackhole_mtu() argument
265 unsigned int mtu = dst_metric_raw(dst, RTAX_MTU); in dst_blackhole_mtu()
267 return mtu ? : dst_dev(dst)->mtu; in dst_blackhole_mtu()
284 struct dst_entry *dst; in __metadata_dst_init() local
286 dst = &md_dst->dst; in __metadata_dst_init()
287 dst_init(dst, &dst_blackhole_ops, NULL, DST_OBSOLETE_NONE, in __metadata_dst_init()
289 memset(dst + 1, 0, sizeof(*md_dst) + optslen - sizeof(*dst)); in __metadata_dst_init()