]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
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 8f49e03d1c68e5a67267f105c859de6d6aa3a416..2875436c6b1f765a46d415d231ff33b0fcdd15b7 100644 (file)
@@ -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,