aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dst.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/dst.c')
-rw-r--r--net/core/dst.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/net/core/dst.c b/net/core/dst.c
index d9e33ebe170..069d51d2941 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -258,15 +258,6 @@ again:
258} 258}
259EXPORT_SYMBOL(dst_destroy); 259EXPORT_SYMBOL(dst_destroy);
260 260
261static void dst_rcu_destroy(struct rcu_head *head)
262{
263 struct dst_entry *dst = container_of(head, struct dst_entry, rcu_head);
264
265 dst = dst_destroy(dst);
266 if (dst)
267 __dst_free(dst);
268}
269
270void dst_release(struct dst_entry *dst) 261void dst_release(struct dst_entry *dst)
271{ 262{
272 if (dst) { 263 if (dst) {
@@ -274,14 +265,10 @@ void dst_release(struct dst_entry *dst)
274 265
275 newrefcnt = atomic_dec_return(&dst->__refcnt); 266 newrefcnt = atomic_dec_return(&dst->__refcnt);
276 WARN_ON(newrefcnt < 0); 267 WARN_ON(newrefcnt < 0);
277 if (unlikely(dst->flags & (DST_NOCACHE | DST_RCU_FREE)) && !newrefcnt) { 268 if (unlikely(dst->flags & DST_NOCACHE) && !newrefcnt) {
278 if (dst->flags & DST_RCU_FREE) { 269 dst = dst_destroy(dst);
279 call_rcu_bh(&dst->rcu_head, dst_rcu_destroy); 270 if (dst)
280 } else { 271 __dst_free(dst);
281 dst = dst_destroy(dst);
282 if (dst)
283 __dst_free(dst);
284 }
285 } 272 }
286 } 273 }
287} 274}
@@ -333,14 +320,11 @@ EXPORT_SYMBOL(__dst_destroy_metrics_generic);
333 */ 320 */
334void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst) 321void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst)
335{ 322{
336 bool hold;
337
338 WARN_ON(!rcu_read_lock_held() && !rcu_read_lock_bh_held()); 323 WARN_ON(!rcu_read_lock_held() && !rcu_read_lock_bh_held());
339 /* If dst not in cache, we must take a reference, because 324 /* If dst not in cache, we must take a reference, because
340 * dst_release() will destroy dst as soon as its refcount becomes zero 325 * dst_release() will destroy dst as soon as its refcount becomes zero
341 */ 326 */
342 hold = (dst->flags & (DST_NOCACHE | DST_RCU_FREE)) == DST_NOCACHE; 327 if (unlikely(dst->flags & DST_NOCACHE)) {
343 if (unlikely(hold)) {
344 dst_hold(dst); 328 dst_hold(dst);
345 skb_dst_set(skb, dst); 329 skb_dst_set(skb, dst);
346 } else { 330 } else {