public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Francois Michel <francois.michel@uclouvain.be>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 2/3] [PATCH 2/3] netem: allow using a seeded PRNG for generating random losses
Date: Mon, 14 Aug 2023 08:49:07 -0700	[thread overview]
Message-ID: <20230814084907.18c339c2@hermes.local> (raw)
In-Reply-To: <20230814023147.1389074-3-francois.michel@uclouvain.be>

On Mon, 14 Aug 2023 04:31:39 +0200
Francois Michel <francois.michel@uclouvain.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.”

  reply	other threads:[~2023-08-14 15:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-14  2:31 [PATCH net-next 0/3] netem: allow using seeded PRNG for loss and corruption events Francois Michel
2023-08-14  2:31 ` [PATCH net-next 1/3] [PATCH 1/3] netem: add prng attribute to netem_sched_data Francois Michel
2023-08-14  2:31 ` [PATCH net-next 2/3] [PATCH 2/3] netem: allow using a seeded PRNG for generating random losses Francois Michel
2023-08-14 15:49   ` Stephen Hemminger [this message]
2023-08-14 20:14     ` François Michel
2023-08-14 21:01       ` Stephen Hemminger
2023-08-14  2:31 ` [PATCH net-next 3/3] [PATCH 3/3] netem: allow using seeded PRNG for correlated loss events Francois Michel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230814084907.18c339c2@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=francois.michel@uclouvain.be \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox