Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 fix IPv6 fragment ID initialization - random() ...



details:   https://anonhg.NetBSD.org/src/rev/31b51f23c69e
branches:  trunk
changeset: 475814:31b51f23c69e
user:      itojun <itojun%NetBSD.org@localhost>
date:      Thu Aug 26 11:10:49 1999 +0000

description:
fix IPv6 fragment ID initialization - random() does not return
random value when frag6_init() is called, so use microtime() to stir
the value better.

diffstat:

 sys/netinet6/frag6.c |  15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diffs (30 lines):

diff -r 4c75686cdb6a -r 31b51f23c69e sys/netinet6/frag6.c
--- a/sys/netinet6/frag6.c      Thu Aug 26 09:28:17 1999 +0000
+++ b/sys/netinet6/frag6.c      Thu Aug 26 11:10:49 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: frag6.c,v 1.5 1999/07/30 10:35:35 itojun Exp $ */
+/*     $NetBSD: frag6.c,v 1.6 1999/08/26 11:10:49 itojun Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -69,12 +69,15 @@
 void
 frag6_init()
 {
+       struct timeval tv;
+
+       /*
+        * in many cases, random() here does NOT return random number
+        * as initialization during bootstrap time occur in fixed order.
+        */
+       microtime(&tv);
        ip6q.ip6q_next = ip6q.ip6q_prev = &ip6q;
-#if !defined(__FreeBSD__) || __FreeBSD__ < 3
-       ip6_id = time.tv_sec & 0xffff;
-#else
-       ip6_id = time_second & 0xffff;
-#endif
+       ip6_id = random() ^ tv.tv_usec;
 }
 
 /*



Home | Main Index | Thread Index | Old Index