Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 03 Sep 2019 14:07:44 -0000
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r346601 - head/sys/netinet6
Message-ID:  <201904231718.x3NHIKgS099948@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Tue Apr 23 17:18:20 2019
New Revision: 346601
URL: https://svnweb.freebsd.org/changeset/base/346601

Log:
  ip6_randomflowlabel: Avoid blocking if random(4) is not available
  
  If kern.random.initial_seeding.bypass_before_seeding is disabled, random(4)
  and arc4random(9) will block indefinitely until enough entropy is available
  to initially seed Fortuna.
  
  It seems that zero flowids are perfectly valid, so avoid blocking on random
  until initial seeding takes place.
  
  Discussed with:	bz (earlier revision)
  Reviewed by:	thj
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D20011

Modified:
  head/sys/netinet6/ip6_id.c

Modified: head/sys/netinet6/ip6_id.c
==============================================================================
--- head/sys/netinet6/ip6_id.c	Tue Apr 23 17:11:45 2019	(r346600)
+++ head/sys/netinet6/ip6_id.c	Tue Apr 23 17:18:20 2019	(r346601)
@@ -89,6 +89,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/kernel.h>
+#include <sys/random.h>
 #include <sys/socket.h>
 #include <sys/libkern.h>
 
@@ -257,6 +258,16 @@ ip6_randomid(void)
 u_int32_t
 ip6_randomflowlabel(void)
 {
+
+	/*
+	 * It's ok to emit zero flow labels early, before random is available
+	 * (seeded).  RFC 6437:
+	 *
+	 * "A Flow Label of zero is used to indicate packets that have not been
+	 * labeled."
+	 */
+	if (__predict_false(!is_random_seeded()))
+		return (0);
 
 	return randomid(&randomtab_20) & 0xfffff;
 }





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904231718.x3NHIKgS099948>