DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Devendra Singh Rawat <dsinghrawat@marvell.com>,
	Alok Prasad <palok@marvell.com>
Subject: [PATCH 4/6] net/qede: replace use of rand()
Date: Fri,  1 Mar 2024 09:57:09 -0800	[thread overview]
Message-ID: <20240301175842.159967-5-stephen@networkplumber.org> (raw)
In-Reply-To: <20240301175842.159967-1-stephen@networkplumber.org>

The function of rand() is a weak random number generator.
Use the DPDK rte_rand() instead.

Note: this doesn't matter for real security, since most drivers
use a fixed RSS default key.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/qede/qede_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index 254548d40638..bee9fa4f60a1 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -7,6 +7,7 @@
 #include "qede_ethdev.h"
 #include <rte_string_fns.h>
 #include <rte_alarm.h>
+#include <rte_random.h>
 #include <rte_kvargs.h>
 
 static const struct qed_eth_ops *qed_ops;
@@ -1040,9 +1041,8 @@ static void qede_prandom_bytes(uint32_t *buff)
 {
 	uint8_t i;
 
-	srand((unsigned int)time(NULL));
 	for (i = 0; i < ECORE_RSS_KEY_SIZE; i++)
-		buff[i] = rand();
+		buff[i] = rte_rand();
 }
 
 int qede_config_rss(struct rte_eth_dev *eth_dev)
-- 
2.43.0


  parent reply	other threads:[~2024-03-01 17:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01 17:57 [PATCH 0/6] Coverity related fixes Stephen Hemminger
2024-03-01 17:57 ` [PATCH 1/6] test/bpf: make sure mbuf is initialized Stephen Hemminger
2024-03-01 18:09   ` Tyler Retzlaff
2024-03-01 17:57 ` [PATCH 2/6] net/tap: log if netlink ext ack not possible Stephen Hemminger
2024-03-01 17:57 ` [PATCH 3/6] examples/l2fwd-keepalive: use rte_drand_max Stephen Hemminger
2024-03-01 17:57 ` Stephen Hemminger [this message]
2024-03-01 18:10   ` [PATCH 4/6] net/qede: replace use of rand() Tyler Retzlaff
2024-03-01 17:57 ` [PATCH 5/6] pipeline: " Stephen Hemminger
2024-03-01 18:11   ` Tyler Retzlaff
2024-03-01 17:57 ` [PATCH 6/6] baseband/fpga_5gnr: don't use rand() Stephen Hemminger
2024-03-01 18:11   ` Tyler Retzlaff
2024-03-02  1:07   ` Chautru, Nicolas
2024-03-06 20:08 ` [PATCH 0/6] Coverity related fixes David Marchand

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=20240301175842.159967-5-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=dsinghrawat@marvell.com \
    --cc=palok@marvell.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;
as well as URLs for NNTP newsgroup(s).