udp: call dst_hold_safe() in udp_sk_rx_set_dst()
[linux-2.6-microblaze.git] / net / ipv4 / udp.c
index 2bc638c..f3450f0 100644 (file)
@@ -1977,9 +1977,10 @@ static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
 {
        struct dst_entry *old;
 
-       dst_hold(dst);
-       old = xchg(&sk->sk_rx_dst, dst);
-       dst_release(old);
+       if (dst_hold_safe(dst)) {
+               old = xchg(&sk->sk_rx_dst, dst);
+               dst_release(old);
+       }
 }
 
 /*
@@ -2303,13 +2304,11 @@ void udp_v4_early_demux(struct sk_buff *skb)
        if (dst)
                dst = dst_check(dst, 0);
        if (dst) {
-               /* DST_NOCACHE can not be used without taking a reference */
-               if (dst->flags & DST_NOCACHE) {
-                       if (likely(atomic_inc_not_zero(&dst->__refcnt)))
-                               skb_dst_set(skb, dst);
-               } else {
-                       skb_dst_set_noref(skb, dst);
-               }
+               /* set noref for now.
+                * any place which wants to hold dst has to call
+                * dst_hold_safe()
+                */
+               skb_dst_set_noref(skb, dst);
        }
 }