Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jan 2018 15:57:49 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r327550 - stable/10/sys/netinet6
Message-ID:  <201801041557.w04FvnW9042058@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Thu Jan  4 15:57:49 2018
New Revision: 327550
URL: https://svnweb.freebsd.org/changeset/base/327550

Log:
  MFC r327295:
  Start syncing changes from OpenBSD's ip6_id.c instead of ip_id.c.
  
  correct non-repetitive ID code, based on comments from niels provos.
  - seed2 is necessary, but use it as "seed2 + x" not "seed2 ^ x".
  - skipping number is not needed, so disable it for 16bit generator (makes
    the repetition period to 30000)
  
  Obtained from:	OpenBSD (CVS rev. 1.2)

Modified:
  stable/10/sys/netinet6/ip6_id.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet6/ip6_id.c
==============================================================================
--- stable/10/sys/netinet6/ip6_id.c	Thu Jan  4 15:55:27 2018	(r327549)
+++ stable/10/sys/netinet6/ip6_id.c	Thu Jan  4 15:57:49 2018	(r327550)
@@ -63,7 +63,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $
+ * $OpenBSD: ip6_id.c,v 1.2 2003/12/10 07:21:01 itojun Exp $
  */
 
 #include <sys/cdefs.h>
@@ -229,15 +229,12 @@ static u_int32_t
 randomid(struct randomtab *p)
 {
 	int i, n;
-	u_int32_t tmp;
 
 	if (p->ru_counter >= p->ru_max || time_uptime > p->ru_reseed)
 		initid(p);
 
-	tmp = arc4random();
-
 	/* Skip a random number of ids */
-	n = tmp & 0x3; tmp = tmp >> 2;
+	n = arc4random() & 0x3;
 	if (p->ru_counter + n >= p->ru_max)
 		initid(p);
 
@@ -248,7 +245,7 @@ randomid(struct randomtab *p)
 
 	p->ru_counter += i;
 
-	return (p->ru_seed ^ pmod(p->ru_g, p->ru_seed2 ^ p->ru_x, p->ru_n)) |
+	return (p->ru_seed ^ pmod(p->ru_g, p->ru_seed2 + p->ru_x, p->ru_n)) |
 	    p->ru_msb;
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801041557.w04FvnW9042058>