From: Martin Willi Date: Tue, 15 Jul 2014 13:11:14 +0000 (+0200) Subject: kernel-netlink: Add a compile-time hook to simulate request message loss X-Git-Tag: 5.2.2dr1~35^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=553be051b73755d3171dc38552e2beb2669793b0;p=thirdparty%2Fstrongswan.git kernel-netlink: Add a compile-time hook to simulate request message loss --- diff --git a/src/libhydra/plugins/kernel_netlink/kernel_netlink_shared.c b/src/libhydra/plugins/kernel_netlink/kernel_netlink_shared.c index 8f49e03d1c..2875436c6b 100644 --- a/src/libhydra/plugins/kernel_netlink/kernel_netlink_shared.c +++ b/src/libhydra/plugins/kernel_netlink/kernel_netlink_shared.c @@ -77,6 +77,16 @@ struct private_netlink_socket_t { 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 */ @@ -109,6 +119,11 @@ static bool write_msg(private_netlink_socket_t *this, struct nlmsghdr *msg) }; int len; + if (msg_loss_hook(msg)) + { + return TRUE; + } + while (TRUE) { len = sendto(this->socket, msg, msg->nlmsg_len, 0,