From nobody Wed Apr 24 13:17:10 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VPffG44wrz5HL00; Wed, 24 Apr 2024 13:17:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VPffG1qDwz4LNN; Wed, 24 Apr 2024 13:17:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713964630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=d1BNERdWaeDsoKR2DutVKVED6BTgIdvpZOLVOcxdsNc=; b=TyCUmwi4/abXyT1PS3KrVRlfqZAkk5qCuijqDryHvK8gvG68ZarK9tKMsFqukukGmg2miD CDjIKmbeBx1eMcN5F3mIfDPuds0y49gqGnmMRqUou+vFtl4WxpBXolZigwaCsRin0L1Npm wdscADziGIulZ+WrVyEuQtaK6hLF2akFUl/z1V+1KkRZ8SX5eQ/cqoE96uyILFsEifNqBS 8e2EolBOMvKHaHO5bPbFqoGbKbuEhZE11tCbhtGz/PaIJndMCQ4cL4O9+QNt35s7bg4dgv l29g+yX5li87NzXkc7GFAt4OpggJ+rVXLwV3WJW7GE3laYHD7ND9zf4gk7/fqQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713964630; a=rsa-sha256; cv=none; b=wAk2QWtTDPJ2AUmmIoqnJGTlbWvtshF+aLefDgmHJJcKq9dYSiz/UoutsWWzHQIJrc3eJr qEKE6j9Z09KAn3ApxgAfTN3gEGZ/MatNuYYJgvZRtubzPzPwVXEAjEbzcN9mxJjlrEaFe3 PwfN4iK71lik6uSL3YaWT2SPRwIvP66lIDrLVaZIBEN3ZoEO4f4U98F5SG0FXmOuBTBqYB D/oSqzIrCYgi6Pa2Km5Hysjzv+W2Vve1zNc3wePMBk2vuzivfpAeaUamDvmBI3aA7ZDKIz M322TG9HjizDYhSXrks6HFzyUMdN6sJFU5ZbIVnURCs9etYd09JcSWKrb0iAeA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713964630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=d1BNERdWaeDsoKR2DutVKVED6BTgIdvpZOLVOcxdsNc=; b=C+KPPRgKzeXRkqFKXymAePNYy5wGHE21C5hBSnAsEhO0ljl6WJr0mmE2s8CJ9+QRRXooPQ GlMm0hYSKHo2i2spsPqKB3dIEAfUS3H7HDM9iFCykX2xJ6XuQML+6GaFZRbauEugVHGJcU d60gh+DL41obotASKF4a2Gonnyny4a2n64fUa/Pvi97t7yyqS9TJoOCtMqOzPi4O6Hb8PR lOOg+eR5QVJ4qph1BOO5jsX5/5C6KWCD0oR3I/nJUJ6goIJEbL/CorbE/K6t4gCMjggndA rDKSd7pIABY4Y8ugR23cd4rH9Umi6ROYneLhq8nMZcCFEL99IU/e9DovaQioVQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VPffG1QJNzGqF; Wed, 24 Apr 2024 13:17:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43ODHAq3053281; Wed, 24 Apr 2024 13:17:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43ODHAMQ053278; Wed, 24 Apr 2024 13:17:10 GMT (envelope-from git) Date: Wed, 24 Apr 2024 13:17:10 GMT Message-Id: <202404241317.43ODHAMQ053278@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: a3ecf8c78636 - main - ng_pipe: Replace deprecated random() with prng32_bounded() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a3ecf8c7863683e53c77a17f96ab7012352265b9 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a3ecf8c7863683e53c77a17f96ab7012352265b9 commit a3ecf8c7863683e53c77a17f96ab7012352265b9 Author: Martin Vahlensieck AuthorDate: 2024-04-17 18:59:22 +0000 Commit: Mark Johnston CommitDate: 2024-04-24 12:44:50 +0000 ng_pipe: Replace deprecated random() with prng32_bounded() Signed-off-by: Martin Vahlensieck MFC after: 2 weeks Reviewed by: markj Pull Request: https://github.com/freebsd/freebsd-src/pull/1181 --- sys/netgraph/ng_pipe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/netgraph/ng_pipe.c b/sys/netgraph/ng_pipe.c index 7afaf24f5914..d368c142b1ab 100644 --- a/sys/netgraph/ng_pipe.c +++ b/sys/netgraph/ng_pipe.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -771,7 +772,7 @@ pipe_dequeue(struct hookinfo *hinfo, struct timeval *now) { * the original packet... */ if (hinfo->cfg.duplicate && - random() % 100 <= hinfo->cfg.duplicate) { + prng32_bounded(100) <= hinfo->cfg.duplicate) { ngp_h = uma_zalloc(ngp_zone, M_NOWAIT); KASSERT(ngp_h != NULL, ("ngp_h zalloc failed (3)")); m = m_dup(m, M_NOWAIT); @@ -814,7 +815,7 @@ pipe_dequeue(struct hookinfo *hinfo, struct timeval *now) { /* Randomly discard the frame, according to BER setting */ if (hinfo->cfg.ber) { oldrand = rand; - rand = random(); + rand = prng32_bounded(1U << 31); if (((oldrand ^ rand) << 17) >= hinfo->ber_p[priv->overhead + m->m_pkthdr.len]) { hinfo->stats.out_disc_frames++;