[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230814084907.18c339c2@hermes.local>
Date: Mon, 14 Aug 2023 08:49:07 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: Francois Michel <francois.michel@...ouvain.be>
Cc: Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>,
Jiri Pirko <jiri@...nulli.us>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 2/3] [PATCH 2/3] netem: allow using a seeded
PRNG for generating random losses
On Mon, 14 Aug 2023 04:31:39 +0200
Francois Michel <francois.michel@...ouvain.be> wrote:
> +/* netem_get_random_u32 - polls a new random 32-bits integer from
> + * the prng.
> + * Uses a deterministic seeded prng if p->deterministic_rng is true.
> + * Uses get_random_u32() underneath if p is NULL or if p->deterministic_rng
> + * is false.
> + */
> +static u32 netem_get_random_u32(struct prng *p)
Overall I am fine with this patch, but the function name is getting excessively
long. It is a local function, so no need for netem_ prefix.
Checking for p == NULL is redundant, all callers are passing a valid pointer.
For logical consistency, put the new wrapper before init_crandom() and after netem_skb_cb().
Since this is not security related, the change could also be simplified to just
always prandom_u32_state() and initialize the state on first use with either
get_random or provided seed. This would also simplify the code around storing
original seed and boolean.
Reminds me of the quote attributed to Mark Twain:
“I apologize for such a long letter - I didn't have time to write a short one.”
Powered by blists - more mailing lists