From owner-svn-src-stable@freebsd.org Thu Jan 4 15:57:51 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 01AFCEBF1A3; Thu, 4 Jan 2018 15:57:51 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A7C7E6FF27; Thu, 4 Jan 2018 15:57:50 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w04FvnTq042059; Thu, 4 Jan 2018 15:57:49 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w04FvnW9042058; Thu, 4 Jan 2018 15:57:49 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201801041557.w04FvnW9042058@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Thu, 4 Jan 2018 15:57:49 +0000 (UTC) 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 X-SVN-Group: stable-10 X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: stable/10/sys/netinet6 X-SVN-Commit-Revision: 327550 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2018 15:57:51 -0000 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 @@ -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; }