svn commit: r327549 - stable/11/sys/netinet6
Pedro F. Giffuni
pfg at FreeBSD.org
Thu Jan 4 15:55:29 UTC 2018
Author: pfg
Date: Thu Jan 4 15:55:27 2018
New Revision: 327549
URL: https://svnweb.freebsd.org/changeset/base/327549
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/11/sys/netinet6/ip6_id.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/netinet6/ip6_id.c
==============================================================================
--- stable/11/sys/netinet6/ip6_id.c Thu Jan 4 11:51:02 2018 (r327548)
+++ stable/11/sys/netinet6/ip6_id.c Thu Jan 4 15:55:27 2018 (r327549)
@@ -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>
@@ -230,15 +230,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);
@@ -249,7 +246,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;
}
More information about the svn-src-all
mailing list