Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet Always use cprng_fast32, even during initialisat...



details:   https://anonhg.NetBSD.org/src/rev/56a43c73afc4
branches:  trunk
changeset: 332139:56a43c73afc4
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon Sep 08 17:40:02 2014 +0000

description:
Always use cprng_fast32, even during initialisation. No point in using
random(9).

diffstat:

 sys/netinet/portalgo.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r 96008e295a3b -r 56a43c73afc4 sys/netinet/portalgo.c
--- a/sys/netinet/portalgo.c    Mon Sep 08 17:35:01 2014 +0000
+++ b/sys/netinet/portalgo.c    Mon Sep 08 17:40:02 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: portalgo.c,v 1.5 2013/06/01 11:01:48 pooka Exp $       */
+/*     $NetBSD: portalgo.c,v 1.6 2014/09/08 17:40:02 joerg Exp $       */
 
 /*
  * Copyright 2011 Vlad Balan
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: portalgo.c,v 1.5 2013/06/01 11:01:48 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: portalgo.c,v 1.6 2014/09/08 17:40:02 joerg Exp $");
 
 #include "opt_inet.h"
 
@@ -408,8 +408,8 @@
 }
 
 /*
- * The straightforward algorithm that calls random() in order to
- * compute the increment to the next port number.
+ * The straightforward algorithm that increments the port number
+ * by a random amount.
  */
 static int
 algo_random_start(int algo, uint16_t *port, struct inpcb_hdr *inp_hdr,
@@ -687,7 +687,7 @@
        /* first time initialization */
        if (dhtable[0] == 0)
                for (size_t i = 0; i < __arraycount(dhtable); i++)
-                       dhtable[i] = random() & 0xffff;
+                       dhtable[i] = cprng_fast32() & 0xffff;
 
        /* Ephemeral port selection function */
        num_ephemeral = mymax - mymin + 1;



Home | Main Index | Thread Index | Old Index