[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f249b2b1-e19f-bbc6-d02e-b256fd369c16@stressinduktion.org>
Date: Mon, 26 Sep 2016 15:53:57 +0200
From: Hannes Frederic Sowa <hannes@...essinduktion.org>
To: Maciej Żenczykowski <zenczykowski@...il.com>,
Maciej Żenczykowski <maze@...gle.com>,
"David S . Miller" <davem@...emloft.net>
Cc: netdev@...r.kernel.org, Erik Kline <ek@...gle.com>,
Lorenzo Colitti <lorenzo@...gle.com>
Subject: Re: [PATCH v4 5/7] ipv6 addrconf: implement RFC7559 router
solicitation backoff
On 25.09.2016 13:03, Maciej Żenczykowski wrote:
> +static inline s32 rfc3315_s14_backoff_init(s32 initial)
> +{
> + u32 r = (9 << 20) / 10 + (prandom_u32() % ((2 << 20) / 10 + 1));
^
> + s32 v = initial * (u64)r >> 20; /* ~ multiply by 0.9 .. 1.1 */
> + return v;
> +}
> +
> +static inline s32 rfc3315_s14_backoff_update(s32 cur, s32 ceiling)
> +{
> + u32 r = (19 << 20) / 10 + (prandom_u32() % ((2 << 20) / 10 + 1));
Please just use do_div here and go back to the first version of the
patch. Variable names could be more aligned with the RFC maybe?
> + s32 v = cur * (u64)r >> 20; /* ~ multiply by 1.9 .. 2.1 */
> + if (v > ceiling) {
> + r -= 1 << 20;
> + v = ceiling * (u64)r >> 20; /* ~ multiply by 0.9 .. 1.1 */
> + }
> + return v;
> +}
Thanks,
Hannes
Powered by blists - more mailing lists