* Number of times to repeat timed out queries
*/
u_int retries;
+
+ /**
+ * Use parallel netlink queries
+ */
+ bool parallel;
};
/**
while (!entry->complete)
{
- if (lib->watcher->get_state(lib->watcher) == WATCHER_RUNNING)
+ if (this->parallel &&
+ lib->watcher->get_state(lib->watcher) == WATCHER_RUNNING)
{
if (this->timeout)
{
{
if (this->socket != -1)
{
- lib->watcher->remove(lib->watcher, this->socket);
+ if (this->parallel)
+ {
+ lib->watcher->remove(lib->watcher, this->socket);
+ }
close(this->socket);
}
this->entries->destroy(this->entries);
/**
* Described in header.
*/
-netlink_socket_t *netlink_socket_create(int protocol, enum_name_t *names)
+netlink_socket_t *netlink_socket_create(int protocol, enum_name_t *names,
+ bool parallel)
{
private_netlink_socket_t *this;
struct sockaddr_nl addr = {
"%s.plugins.kernel-netlink.timeout", 0, lib->ns),
.retries = lib->settings->get_int(lib->settings,
"%s.plugins.kernel-netlink.retries", 0, lib->ns),
+ .parallel = parallel,
);
if (this->socket == -1)
destroy(this);
return NULL;
}
-
- lib->watcher->add(lib->watcher, this->socket, WATCHER_READ, watch, this);
+ if (this->parallel)
+ {
+ lib->watcher->add(lib->watcher, this->socket, WATCHER_READ, watch, this);
+ }
return &this->public;
}
netlink_add_attribute(&request.hdr, RTA_DST,
chunk_from_thing(dst), sizeof(request));
- s = netlink_socket_create(NETLINK_ROUTE, NULL);
+ s = netlink_socket_create(NETLINK_ROUTE, NULL, _i != 0);
ck_assert(s->send(s, &request.hdr, &out, &len) == SUCCESS);
ck_assert_int_eq(out->nlmsg_type, RTM_NEWROUTE);
},
};
- s = netlink_socket_create(NETLINK_ROUTE, NULL);
+ s = netlink_socket_create(NETLINK_ROUTE, NULL, _i != 0);
msg = NLMSG_DATA(&request.hdr);
msg->rtgen_family = AF_UNSPEC;
netlink_socket_t *s;
int i;
- s = netlink_socket_create(NETLINK_ROUTE, NULL);
+ s = netlink_socket_create(NETLINK_ROUTE, NULL, _i != 0);
for (i = 0; i < countof(threads); i++)
{
threads[i] = thread_create(stress, s);
netlink_socket_t *s;
int i;
- s = netlink_socket_create(NETLINK_ROUTE, NULL);
+ s = netlink_socket_create(NETLINK_ROUTE, NULL, _i != 0);
for (i = 0; i < countof(threads); i++)
{
threads[i] = thread_create(stress_dump, s);
lib->settings->set_int(lib->settings,
"%s.plugins.kernel-netlink.retries", 1, lib->ns);
- s = netlink_socket_create(NETLINK_ROUTE, NULL);
+ s = netlink_socket_create(NETLINK_ROUTE, NULL, _i != 0);
msg = NLMSG_DATA(&request.hdr);
msg->rtgen_family = AF_UNSPEC;
lib->settings->set_int(lib->settings,
"%s.plugins.kernel-netlink.retries", 3, lib->ns);
- s = netlink_socket_create(NETLINK_ROUTE, NULL);
+ s = netlink_socket_create(NETLINK_ROUTE, NULL, _i != 0);
msg = NLMSG_DATA(&request.hdr);
msg->rtgen_family = AF_UNSPEC;
s = suite_create("netlink socket");
tc = tcase_create("echo");
- tcase_add_test(tc, test_echo);
- tcase_add_test(tc, test_echo_dump);
+ tcase_add_loop_test(tc, test_echo, 0, 2);
+ tcase_add_loop_test(tc, test_echo_dump, 0, 2);
suite_add_tcase(s, tc);
tc = tcase_create("stress");
- tcase_add_test(tc, test_stress);
- tcase_add_test(tc, test_stress_dump);
+ tcase_add_loop_test(tc, test_stress, 0, 2);
+ tcase_add_loop_test(tc, test_stress_dump, 0, 2);
suite_add_tcase(s, tc);
tc = tcase_create("retransmit");
- tcase_add_test(tc, test_retransmit_success);
- tcase_add_test(tc, test_retransmit_fail);
+ tcase_add_loop_test(tc, test_retransmit_success, 0, 2);
+ tcase_add_loop_test(tc, test_retransmit_fail, 0, 2);
suite_add_tcase(s, tc);
return s;