File tree 1 file changed +26
-3
lines changed
1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change 16
16
*
17
17
*/
18
18
#include <assert.h>
19
+ #include <sys/types.h>
20
+ #include <sys/stat.h>
21
+ #include <fcntl.h>
19
22
#include <netinet/ip.h>
20
23
#include <netinet/tcp.h>
21
24
#include <openssl/md5.h>
@@ -117,15 +120,35 @@ static int second_timer_expire(void *priv)
117
120
}
118
121
#endif
119
122
123
+ static int generate_random_key (void * key , unsigned length )
124
+ {
125
+ int fd ;
126
+ int ret ;
127
+
128
+ fd = open ("/dev/urandom" , O_RDONLY );
129
+ if (fd < 0 ) {
130
+ return -1 ;
131
+ }
132
+ ret = read (fd , key , length );
133
+ close (fd );
134
+
135
+ if (ret != (signed )length ) {
136
+ return -1 ;
137
+ }
138
+ return 0 ;
139
+ }
140
+
120
141
int dp_vs_synproxy_init (void )
121
142
{
122
143
int i ;
123
144
char ack_mbufpool_name [32 ];
124
145
struct timeval tv ;
125
146
126
- for (i = 0 ; i < MD5_LBLOCK ; i ++ ) {
127
- g_net_secret [0 ][i ] = (uint32_t )random ();
128
- g_net_secret [1 ][i ] = (uint32_t )random ();
147
+ if (generate_random_key (g_net_secret , sizeof (g_net_secret ))) {
148
+ for (i = 0 ; i < MD5_LBLOCK ; i ++ ) {
149
+ g_net_secret [0 ][i ] = (uint32_t )random ();
150
+ g_net_secret [1 ][i ] = (uint32_t )random ();
151
+ }
129
152
}
130
153
131
154
rte_atomic32_set (& g_minute_count , (uint32_t )random ());
You can’t perform that action at this time.
0 commit comments