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; } _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"