kernel-netlink: Add a compile-time hook to simulate request message loss

This commit is contained in:
Martin Willi
2014-11-21 10:55:45 +01:00
parent 15dc61757c
commit 553be051b7
@@ -77,6 +77,16 @@ struct private_netlink_socket_t {
u_int retries; u_int retries;
}; };
/**
* #definable hook to simulate request message loss
*/
#ifdef NETLINK_MSG_LOSS_HOOK
bool NETLINK_MSG_LOSS_HOOK(struct nlmsghdr *msg);
#define msg_loss_hook(msg) NETLINK_MSG_LOSS_HOOK(msg)
#else
#define msg_loss_hook(msg) FALSE
#endif
/** /**
* Request entry the answer for a waiting thread is collected in * Request entry the answer for a waiting thread is collected in
*/ */
@@ -109,6 +119,11 @@ static bool write_msg(private_netlink_socket_t *this, struct nlmsghdr *msg)
}; };
int len; int len;
if (msg_loss_hook(msg))
{
return TRUE;
}
while (TRUE) while (TRUE)
{ {
len = sendto(this->socket, msg, msg->nlmsg_len, 0, len = sendto(this->socket, msg, msg->nlmsg_len, 0,