diff --git a/net/ipv4/route.c b/net/ipv4/route.c index e4df1319b59ea8613d5c7cff22285be82bb3e0de..dd6e46c748304d5db6f43b017c2c46027bbe4d91 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -483,18 +483,12 @@ 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; + return atomic_add_return(segs + delta, p_id) - segs; } EXPORT_SYMBOL(ip_idents_reserve);