Skip to content
Snippets Groups Projects
Commit 68f64866 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

xdp: replace rand() with dnssec_random_uint32_t() for TCP sequence number generation

parent b405654a
No related branches found
No related tags found
1 merge request!1236XDP refactoring
......@@ -20,6 +20,7 @@
#include <string.h>
#include "libknot/xdp/msg.h"
#include "libdnssec/random.h"
inline static bool empty_msg(const knot_xdp_msg_t *msg)
{
......@@ -29,15 +30,6 @@ inline static bool empty_msg(const knot_xdp_msg_t *msg)
return (msg->payload.iov_len == 0 && !(msg->flags & tcp_flags));
}
// FIXME do we care for better random?
inline static uint32_t rnd_uint32(void)
{
uint32_t res = rand() & 0xffff;
res <<= 16;
res |= rand() & 0xffff;
return res;
}
inline static void msg_init_base(knot_xdp_msg_t *msg, knot_xdp_msg_flag_t flags)
{
memset(msg, 0, sizeof(*msg));
......@@ -51,7 +43,7 @@ inline static void msg_init(knot_xdp_msg_t *msg, knot_xdp_msg_flag_t flags)
if (flags & KNOT_XDP_MSG_TCP) {
msg->ackno = 0;
msg->seqno = rnd_uint32();
msg->seqno = dnssec_random_uint32_t();
}
}
......@@ -73,7 +65,7 @@ inline static void msg_init_reply(knot_xdp_msg_t *msg, const knot_xdp_msg_t *que
}
msg->seqno = query->ackno;
if (msg->seqno == 0) {
msg->seqno = rnd_uint32();
msg->seqno = dnssec_random_uint32_t();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment