aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet6/ip6_id.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet6/ip6_id.c')
-rw-r--r--sys/netinet6/ip6_id.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/netinet6/ip6_id.c b/sys/netinet6/ip6_id.c
index f41df2a2e5a9..1d6c2c7d9668 100644
--- a/sys/netinet6/ip6_id.c
+++ b/sys/netinet6/ip6_id.c
@@ -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>
@@ -258,5 +259,15 @@ 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;
}