Linux随机数nonblocking pool快速初始化

1.问题:

mosquitto broker一直连接不上,直到出现random: nonblocking pool is initialized。

2.分析:

初步分析与nonblocking pool初始化有关。

3.解决:

内核打补丁,实现nonblocking pool快速初始化

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 9cd6968e2f92..514f67a98b88 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -898,7 +898,8 @@  void add_interrupt_randomness(int irq, int irq_flags)
    add_interrupt_bench(cycles);
 
    if ((fast_pool->count < 64) &&
-       !time_after(now, fast_pool->last + HZ))
+       !time_after(now, fast_pool->last + HZ) &&
+       nonblocking_pool.initialized)
        return;
 
    r = nonblocking_pool.initialized ? &input_pool : &nonblocking_pool;