Date: Thu, 4 Jan 2018 15:55:27 +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-11@freebsd.org Subject: svn commit: r327549 - stable/11/sys/netinet6 Message-ID: <201801041555.w04FtRTN041947@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801041555.w04FtRTN041947>