kernel-netlink: Add a compile-time hook to simulate request message loss
authorMartin Willi <martin@revosec.ch>
Tue, 15 Jul 2014 13:11:14 +0000 (15:11 +0200)
committerMartin Willi <martin@revosec.ch>
Fri, 21 Nov 2014 09:55:45 +0000 (10:55 +0100)
src/libhydra/plugins/kernel_netlink/kernel_netlink_shared.c

index 8f49e03..2875436 100644 (file)
@@ -78,6 +78,16 @@ struct private_netlink_socket_t {
 };
 
 /**
+ * #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
  */
 typedef struct {
@@ -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,