FreeBSD Bugzilla – Attachment 249283 Details for
Bug 277655
random() scheduled to be removed for 15.0-RELEASE
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
sys/netinet/cc switch from random() to prng32()
netinet-cc-random-to-prng32.patch (text/plain), 3.03 KB, created by
Henrich Hartzer
on 2024-03-18 21:20:07 UTC
(
hide
)
Description:
sys/netinet/cc switch from random() to prng32()
Filename:
MIME Type:
Creator:
Henrich Hartzer
Created:
2024-03-18 21:20:07 UTC
Size:
3.03 KB
patch
obsolete
>diff --git a/sys/netinet/cc/cc_cdg.c b/sys/netinet/cc/cc_cdg.c >index f6507a7a1490..5053f3bd5c5a 100644 >--- a/sys/netinet/cc/cc_cdg.c >+++ b/sys/netinet/cc/cc_cdg.c >@@ -58,6 +58,7 @@ > #include <sys/malloc.h> > #include <sys/module.h> > #include <sys/queue.h> >+#include <sys/prng.h> > #include <sys/socket.h> > #include <sys/socketvar.h> > #include <sys/sysctl.h> >@@ -309,7 +310,7 @@ cdg_cb_init(struct cc_var *ccv, void *ptr) > cdg_data->queue_state = CDG_Q_UNKNOWN; > cdg_data->maxrtt_in_rtt = 0; > cdg_data->maxrtt_in_prevrtt = 0; >- cdg_data->minrtt_in_rtt = INT_MAX; >+ cdg_data->minrtt_in_rtt = UINT_MAX; > cdg_data->minrtt_in_prevrtt = 0; > cdg_data->window_incr = 0; > cdg_data->rtt_count = 0; >@@ -520,8 +521,8 @@ prob_backoff(long qtrend) > idx = qtrend; > > /* Backoff probability proportional to rate of queue growth. */ >- p = (INT_MAX / (1 << EXP_PREC)) * probexp[idx]; >- backoff = (random() < p); >+ p = (UINT_MAX / (1 << EXP_PREC)) * probexp[idx]; >+ backoff = (prng32() < p); > } > > return (backoff); >@@ -638,7 +639,7 @@ cdg_ack_received(struct cc_var *ccv, uint16_t ack_type) > } > > cdg_data->minrtt_in_prevrtt = cdg_data->minrtt_in_rtt; >- cdg_data->minrtt_in_rtt = INT_MAX; >+ cdg_data->minrtt_in_rtt = UINT_MAX; > cdg_data->maxrtt_in_prevrtt = cdg_data->maxrtt_in_rtt; > cdg_data->maxrtt_in_rtt = 0; > e_t->flags &= ~ERTT_NEW_MEASUREMENT; >diff --git a/sys/netinet/cc/cc_chd.c b/sys/netinet/cc/cc_chd.c >index a16d0606b5ef..783ddb5f9cb8 100644 >--- a/sys/netinet/cc/cc_chd.c >+++ b/sys/netinet/cc/cc_chd.c >@@ -59,6 +59,7 @@ > #include <sys/limits.h> > #include <sys/malloc.h> > #include <sys/module.h> >+#include <sys/prng.h> > #include <sys/queue.h> > #include <sys/socket.h> > #include <sys/socketvar.h> >@@ -86,8 +87,8 @@ > */ > #define CC_CHD_DELAY 0x02000000 > >-/* Largest possible number returned by random(). */ >-#define RANDOM_MAX INT_MAX >+/* Largest possible number returned by prng32(). */ >+#define RANDOM_MAX UINT_MAX > > static void chd_ack_received(struct cc_var *ccv, uint16_t ack_type); > static void chd_cb_destroy(struct cc_var *ccv); >@@ -162,7 +163,7 @@ should_backoff(int qdly, int maxqdly, struct chd *chd_data) > { > unsigned long p, rand; > >- rand = random(); >+ rand = prng32(); > > if (qdly < V_chd_qthresh) { > chd_data->loss_compete = 0; >diff --git a/sys/netinet/cc/cc_hd.c b/sys/netinet/cc/cc_hd.c >index db23d10ccc3d..8434c17b5424 100644 >--- a/sys/netinet/cc/cc_hd.c >+++ b/sys/netinet/cc/cc_hd.c >@@ -60,6 +60,7 @@ > #include <sys/limits.h> > #include <sys/malloc.h> > #include <sys/module.h> >+#include <sys/prng.h> > #include <sys/queue.h> > #include <sys/socket.h> > #include <sys/socketvar.h> >@@ -78,8 +79,8 @@ > > #include <netinet/khelp/h_ertt.h> > >-/* Largest possible number returned by random(). */ >-#define RANDOM_MAX INT_MAX >+/* Largest possible number returned by prng32(). */ >+#define RANDOM_MAX UINT_MAX > > static void hd_ack_received(struct cc_var *ccv, uint16_t ack_type); > static int hd_mod_init(void); >@@ -129,7 +130,7 @@ should_backoff(int qdly, int maxqdly) > p = (RANDOM_MAX / 100) * V_hd_pmax; > } > >- return (random() < p); >+ return (prng32() < p); > } > > /*
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 277655
: 249283