Module Name:    src
Committed By:   joerg
Date:           Mon Sep  8 17:40:02 UTC 2014

Modified Files:
        src/sys/netinet: portalgo.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/netinet/portalgo.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/portalgo.c
diff -u src/sys/netinet/portalgo.c:1.5 src/sys/netinet/portalgo.c:1.6
--- src/sys/netinet/portalgo.c:1.5	Sat Jun  1 11:01:48 2013
+++ src/sys/netinet/portalgo.c	Mon Sep  8 17:40:02 2014
@@ -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 @@ algo_bsd(int algo, uint16_t *port, struc
 }
 
 /*
- * 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 @@ algo_doublehash(int algo, uint16_t *port
 	/* 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;

Reply via email to