Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[sfrench/cifs-2.6.git] / net / ipv4 / route.c
index fa829f31a3f5874aad09553b0746e677a714f299..b73f540fa19be2ba93ebcc7df30f14ecb0faaf05 100644 (file)
@@ -491,18 +491,16 @@ u32 ip_idents_reserve(u32 hash, int segs)
        atomic_t *p_id = ip_idents + hash % IP_IDENTS_SZ;
        u32 old = READ_ONCE(*p_tstamp);
        u32 now = (u32)jiffies;
-       u32 new, delta = 0;
+       u32 delta = 0;
 
        if (old != now && cmpxchg(p_tstamp, old, now) == old)
                delta = prandom_u32_max(now - old);
 
-       /* Do not use atomic_add_return() as it makes UBSAN unhappy */
-       do {
-               old = (u32)atomic_read(p_id);
-               new = old + delta + segs;
-       } while (atomic_cmpxchg(p_id, old, new) != old);
-
-       return new - segs;
+       /* If UBSAN reports an error there, please make sure your compiler
+        * supports -fno-strict-overflow before reporting it that was a bug
+        * in UBSAN, and it has been fixed in GCC-8.
+        */
+       return atomic_add_return(segs + delta, p_id) - segs;
 }
 EXPORT_SYMBOL(ip_idents_reserve);