diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2003-12-10 07:21:02 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2003-12-10 07:21:02 +0000 |
commit | 519d21e04cd9ed70834f541ccb7586f24cac0e95 (patch) | |
tree | 39728d60867607f979023f16933319769c683ecf /sys/netinet | |
parent | 9b3c0e63410db24dc1cc8431f9634da692fcab4d (diff) |
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)
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/ip_id.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/netinet/ip_id.c b/sys/netinet/ip_id.c index 0534d406e33..67208b89de9 100644 --- a/sys/netinet/ip_id.c +++ b/sys/netinet/ip_id.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_id.c,v 1.7 2003/09/21 04:06:39 itojun Exp $ */ +/* $OpenBSD: ip_id.c,v 1.8 2003/12/10 07:21:00 itojun Exp $ */ /* * Copyright 1998 Niels Provos <provos@citi.umich.edu> @@ -174,10 +174,14 @@ ip_randomid(void) if (!tmp) tmp = arc4random(); +#if 0 /* Skip a random number of ids */ n = tmp & 0x3; tmp = tmp >> 2; if (ru_counter + n >= RU_MAX) ip_initid(); +#else + n = 0; +#endif for (i = 0; i <= n; i++) /* Linear Congruential Generator */ @@ -185,5 +189,5 @@ ip_randomid(void) ru_counter += i; - return (ru_seed ^ pmod(ru_g,ru_seed2 ^ ru_x,RU_N)) | ru_msb; + return (ru_seed ^ pmod(ru_g,ru_seed2 + ru_x, RU_N)) | ru_msb; } |