From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25B65C001DB for ; Mon, 14 Aug 2023 15:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230290AbjHNPtY (ORCPT ); Mon, 14 Aug 2023 11:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbjHNPtL (ORCPT ); Mon, 14 Aug 2023 11:49:11 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA46DDD for ; Mon, 14 Aug 2023 08:49:10 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-686daaa5f1fso3001933b3a.3 for ; Mon, 14 Aug 2023 08:49:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1692028150; x=1692632950; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=MYiTF3LUp//kvce+GMZR6GgGsS/cIG7u9YAsbVgnE+s=; b=FoBT58iuObS+7FtaiTCVYKf0gb58OCOL9TQyNx59olDICau3OkAaiZU3R11DH8AgqS WY5Z38rWUcf6/SrYBiQiDZ61rdcYGQwl3hJSHu//WPlfKoq4w8iJJbdMElqGbrG3CTmv ZwdTCCcv30/xj3GL5qzO6V50yEhhPKbmVI7jmOtqDUEnDtWvRY1I1F6WI2S2TdJTDPdb ijBLvH1T3EysM8lHMQknd56GY02j9mJo0At4XDe6rI76hAMhKldgwwcSzL/XKKlvcLhR LaYBbrftKSEkz9EsS2FCgItLbXecNjouDuYzTtVEUSIQqQIbJUdgeHZHB39x/6g7u58q xXWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692028150; x=1692632950; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MYiTF3LUp//kvce+GMZR6GgGsS/cIG7u9YAsbVgnE+s=; b=Br0HJ+kXPOSsiKFJNJtWHK9LYllyfqzv+fHIh9xthf1LZCERg/n/sVCU0Z1TEshXlo FHiTvw2J7GC1+XX4HbXXjy7NOn1oP4c+wB0hbnIC4oAd1LNIak9nT+XrIJnqDvotscCx /lJ7L3BNdcAdstTXJQAqiNKlLdkpJ53tMYWwY8/1mnm1gBR59ww2/pZllW4QEhyewUHP UmRrImwhSbyphBuHZij72R4t7X/ItpJ1YAfkLL2cZX+0l6sXWX+N8qqLQy+0rGWhScwT GSWrdhGdynRjoBhVmhTr+mO+IaP0ZFK6ZnAIdt04AdQR76MS9stftQ+x9tACnh6w6g2e szGA== X-Gm-Message-State: AOJu0YwUe7nT+C2v+jrh6q1JIuhV/Y4nh80KV9OdDkD2DG4FlBmmGXkZ FdfPQ57P+KH01qvo9+VAOsiXQw== X-Google-Smtp-Source: AGHT+IHDRkUwKePnso/znzWYdzs8w4Ckkub/nNx11D5ZuAZF7ZXCNDr91URmH2E26oA10zI+aZPFCQ== X-Received: by 2002:a05:6a20:8406:b0:140:ef2a:9b75 with SMTP id c6-20020a056a20840600b00140ef2a9b75mr11090240pzd.61.1692028150113; Mon, 14 Aug 2023 08:49:10 -0700 (PDT) Received: from hermes.local (204-195-127-207.wavecable.com. [204.195.127.207]) by smtp.gmail.com with ESMTPSA id l4-20020a639844000000b00565b8e0798csm2462389pgo.57.2023.08.14.08.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 08:49:09 -0700 (PDT) Date: Mon, 14 Aug 2023 08:49:07 -0700 From: Stephen Hemminger To: Francois Michel Cc: Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , 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 Message-ID: <20230814084907.18c339c2@hermes.local> In-Reply-To: <20230814023147.1389074-3-francois.michel@uclouvain.be> References: <20230814023147.1389074-1-francois.michel@uclouvain.be> <20230814023147.1389074-3-francois.michel@uclouvain.be> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 14 Aug 2023 04:31:39 +0200 Francois Michel 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 excessi= vely long. It is a local function, so no need for netem_ prefix. Checking for p =3D=3D NULL is redundant, all callers are passing a valid po= inter. For logical consistency, put the new wrapper before init_crandom() and afte= r 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 eithe= r=20 get_random or provided seed. This would also simplify the code around stor= ing original seed and boolean. Reminds me of the quote attributed to Mark Twain: =E2=80=9CI apologize for such a long letter - I didn't have time to write a= short one.=E2=80=9D