[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANP3RGean6M7PuTMXKJrXSdU+2RgzqsoEvnQK5C0RFoXGfFwBA@mail.gmail.com>
Date: Sat, 28 Mar 2020 09:56:58 -0700
From: Maciej Żenczykowski <maze@...gle.com>
To: George Spelvin <lkml@....org>
Cc: Kernel hackers <linux-kernel@...r.kernel.org>,
"David S. Miller" <davem@...emloft.net>,
Alexey Kuznetsov <kuznet@....inr.ac.ru>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
Linux NetDev <netdev@...r.kernel.org>
Subject: Re: [RFC PATCH v1 18/50] net/ipv6/addrconf.c: Use prandom_u32_max for
rfc3315 backoff time computation
> /* multiply 'initial retransmission time' by 0.9 .. 1.1 */
> - u64 tmp = (900000 + prandom_u32() % 200001) * (u64)irt;
> - do_div(tmp, 1000000);
> - return (s32)tmp;
> + s32 range = irt / 5;
> + return irt - (s32)(range/2) + (s32)prandom_u32_max(range);
The cast on range/2 looks entirely spurious
> /* multiply 'retransmission timeout' by 1.9 .. 2.1 */
> - u64 tmp = (1900000 + prandom_u32() % 200001) * (u64)rt;
> - do_div(tmp, 1000000);
> - if ((s32)tmp > mrt) {
> + s32 range = rt / 5;
> + s32 tmp = 2*rt - (s32)(range/2) + (s32)prandom_u32_max(range);
Here as well. Honestly the cast on prandom might also not be
necessary, but that at least has a reason.
> + if (tmp > mrt) {
> /* multiply 'maximum retransmission time' by 0.9 .. 1.1 */
> - tmp = (900000 + prandom_u32() % 200001) * (u64)mrt;
> - do_div(tmp, 1000000);
> + range = mrt / 5;
> + tmp = mrt - (s32)(range/2) + (s32)prandom_u32_max(range);
Ditto.
> }
> return (s32)tmp;
> }
- Maciej
Powered by blists - more mailing lists