* [LTP] [PATCH 1/3] netstress: allow to resend requests for udp and dccp
@ 2017-10-12 13:03 Alexey Kodanev
2017-10-12 13:03 ` [LTP] [PATCH 2/3] netstress: remove verbose output Alexey Kodanev
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Alexey Kodanev @ 2017-10-12 13:03 UTC (permalink / raw)
To: ltp
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
testcases/network/netstress/netstress.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index 4b211aa..78ef270 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -105,6 +105,7 @@ static int clients_num;
static char *tcp_port = "61000";
static char *server_addr = "localhost";
static int busy_poll = -1;
+static int max_etime_cnt, etime_cnt;
enum {
TYPE_TCP = 0,
@@ -216,6 +217,9 @@ static int sock_recv_poll(int fd, char *buf, int buf_size, int offset)
if (len == -1 && errno == EINTR)
continue;
+ if (len == 0)
+ errno = ESHUTDOWN;
+
break;
}
@@ -252,6 +256,12 @@ static int client_recv(int *fd, char *buf)
return 0;
}
+ if (errno == ETIME && sock_type != SOCK_STREAM) {
+ if (tst_atomic_inc(&etime_cnt) > max_etime_cnt)
+ tst_brk(TFAIL, "protocol timeout");
+ return 0;
+ }
+
SAFE_CLOSE(*fd);
return (errno) ? -1 : 0;
}
@@ -436,6 +446,9 @@ static void client_run(void)
/* the script tcp_fastopen_run.sh will remove it */
SAFE_FILE_PRINTF(rpath, "%ld", clnt_time);
+ if (sock_type != SOCK_STREAM && etime_cnt > 0)
+ tst_res(TWARN, "timeout requests %d", etime_cnt);
+
tst_res(TPASS, "test completed");
}
@@ -756,6 +769,13 @@ static void setup(void)
net.run = client_run;
net.cleanup = client_cleanup;
+ if (proto_type == TYPE_DCCP || proto_type == TYPE_UDP) {
+ max_etime_cnt = client_max_requests / 1000 *
+ clients_num + 3; /* ~0.1% */
+ tst_res(TINFO, "max timeout errors %d", max_etime_cnt);
+ wait_timeout = 100000L;
+ }
+
check_tw_reuse();
} else {
tst_res(TINFO, "max requests '%d'",
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 2/3] netstress: remove verbose output
2017-10-12 13:03 [LTP] [PATCH 1/3] netstress: allow to resend requests for udp and dccp Alexey Kodanev
@ 2017-10-12 13:03 ` Alexey Kodanev
2017-10-31 12:14 ` Petr Vorel
2017-10-12 13:03 ` [LTP] [PATCH 3/3] netstress: randomize payload length Alexey Kodanev
2017-10-31 10:51 ` [LTP] [PATCH 1/3] netstress: allow to resend requests for udp and dccp Petr Vorel
2 siblings, 1 reply; 8+ messages in thread
From: Alexey Kodanev @ 2017-10-12 13:03 UTC (permalink / raw)
To: ltp
It's not really helpful, can be done with tcpdump.
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
testcases/network/netstress/netstress.c | 25 -------------------------
1 files changed, 0 insertions(+), 25 deletions(-)
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index 78ef270..463e2b0 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -130,8 +130,6 @@ static long wait_timeout = 60000000L;
/* in the end test will save time result in this file */
static char *rpath = "tfo_result";
-static char *verbose;
-
static char *narg, *Narg, *qarg, *rarg, *Rarg, *aarg, *Targ, *barg, *targ;
/* common structure for TCP/UDP server and TCP/UDP client */
@@ -245,11 +243,6 @@ static int client_recv(int *fd, char *buf)
if (buf[offset - 1] != end_byte)
continue;
- if (verbose) {
- tst_res_hexd(TINFO, buf, offset,
- "msg recv from sock %d:", *fd);
- }
-
/* recv last msg, close socket */
if (buf[0] == start_fin_byte)
break;
@@ -323,11 +316,6 @@ void *client_fn(LTP_ATTRIBUTE_UNUSED void *arg)
}
send:
- if (verbose) {
- tst_res_hexd(TINFO, client_msg, client_msg_size,
- "try to send msg[%d]", i);
- }
-
SAFE_SEND(1, cfd, client_msg, client_msg_size, MSG_NOSIGNAL);
if (client_recv(&cfd, buf)) {
@@ -506,11 +494,6 @@ void *server_fn(void *cfd)
if (recv_msg[0] == start_fin_byte)
goto out;
- if (verbose) {
- tst_res_hexd(TINFO, recv_msg, offset,
- "msg recv from sock %d:", client_fd);
- }
-
/* if we send reply for the first time, construct it here */
if (send_msg[0] != start_byte) {
send_msg_size = parse_client_request(recv_msg);
@@ -642,13 +625,6 @@ static void server_run(void)
if (client_fd == -1)
tst_brk(TBROK, "Can't create client socket");
- if (verbose) {
- char addr_buf[INET6_ADDRSTRLEN];
- tst_res(TINFO, "conn: port '%d', addr '%s'",
- addr6.sin6_port, inet_ntop(AF_INET6,
- &addr6.sin6_addr, addr_buf, INET6_ADDRSTRLEN));
- }
-
server_thread_add(client_fd);
}
}
@@ -832,7 +808,6 @@ static void do_test(void)
}
static struct tst_option options[] = {
- {"v", &verbose, "-v Verbose"},
{"f", &fastopen_api, "-f Use TFO API, default is old API"},
{"t:", &targ, "-t x Set tcp_fastopen value"},
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 3/3] netstress: randomize payload length
2017-10-12 13:03 [LTP] [PATCH 1/3] netstress: allow to resend requests for udp and dccp Alexey Kodanev
2017-10-12 13:03 ` [LTP] [PATCH 2/3] netstress: remove verbose output Alexey Kodanev
@ 2017-10-12 13:03 ` Alexey Kodanev
2017-10-31 12:27 ` Petr Vorel
2017-10-31 10:51 ` [LTP] [PATCH 1/3] netstress: allow to resend requests for udp and dccp Petr Vorel
2 siblings, 1 reply; 8+ messages in thread
From: Alexey Kodanev @ 2017-10-12 13:03 UTC (permalink / raw)
To: ltp
Not default, needs '-A x' option, where x is the upper limit
of the random payload.
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
testcases/network/netstress/netstress.c | 141 ++++++++++++++++++-------------
1 files changed, 82 insertions(+), 59 deletions(-)
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index 463e2b0..484278d 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -37,6 +37,7 @@
#include "tst_test.h"
static const int max_msg_len = (1 << 16) - 1;
+static const int min_msg_len = 5;
#ifndef SOCK_DCCP
#define SOCK_DCCP 6
@@ -90,10 +91,9 @@ static const int server_byte = 0x53;
static const int start_byte = 0x24;
static const int start_fin_byte = 0x25;
static const int end_byte = 0x0a;
-static int client_msg_size = 32;
-static int server_msg_size = 128;
-static char *client_msg;
-static char *server_msg;
+static int init_cln_msg_len = 32;
+static int init_srv_msg_len = 128;
+static int max_rand_msg_len;
/*
* The number of requests from client after
@@ -130,7 +130,8 @@ static long wait_timeout = 60000000L;
/* in the end test will save time result in this file */
static char *rpath = "tfo_result";
-static char *narg, *Narg, *qarg, *rarg, *Rarg, *aarg, *Targ, *barg, *targ;
+static char *narg, *Narg, *qarg, *rarg, *Rarg, *aarg, *Targ, *barg, *targ,
+ *Aarg;
/* common structure for TCP/UDP server and TCP/UDP client */
struct net_func {
@@ -164,9 +165,6 @@ static void init_socket_opts(int sd)
static void do_cleanup(void)
{
- free(client_msg);
- free(server_msg);
-
if (net.cleanup)
net.cleanup();
@@ -224,16 +222,16 @@ static int sock_recv_poll(int fd, char *buf, int buf_size, int offset)
return len;
}
-static int client_recv(int *fd, char *buf)
+static int client_recv(int *fd, char *buf, int srv_msg_len)
{
int len, offset = 0;
while (1) {
errno = 0;
- len = sock_recv_poll(*fd, buf, server_msg_size, offset);
+ len = sock_recv_poll(*fd, buf, srv_msg_len, offset);
/* socket closed or msg is not valid */
- if (len < 1 || (offset + len) > server_msg_size ||
+ if (len < 1 || (offset + len) > srv_msg_len ||
(buf[0] != start_byte && buf[0] != start_fin_byte)) {
if (!errno)
errno = ENOMSG;
@@ -279,20 +277,48 @@ static int client_connect_send(const char *msg, int size)
return cfd;
}
+union net_size_field {
+ char bytes[2];
+ uint16_t value;
+};
+
+static void make_client_request(char client_msg[], int *cln_len, int *srv_len)
+{
+ if (max_rand_msg_len)
+ *cln_len = *srv_len = min_msg_len + rand() % max_rand_msg_len;
+
+ memset(client_msg, client_byte, *cln_len);
+ client_msg[0] = start_byte;
+
+ /* set size for reply */
+ union net_size_field net_size;
+
+ net_size.value = htons(*srv_len);
+ client_msg[1] = net_size.bytes[0];
+ client_msg[2] = net_size.bytes[1];
+
+ client_msg[*cln_len - 1] = end_byte;
+}
+
void *client_fn(LTP_ATTRIBUTE_UNUSED void *arg)
{
- char buf[server_msg_size];
+ int cln_len = init_cln_msg_len,
+ srv_len = init_srv_msg_len;
+ char buf[max_msg_len];
+ char client_msg[max_msg_len];
int cfd, i = 0;
intptr_t err = 0;
+ make_client_request(client_msg, &cln_len, &srv_len);
+
/* connect & send requests */
- cfd = client_connect_send(client_msg, client_msg_size);
+ cfd = client_connect_send(client_msg, cln_len);
if (cfd == -1) {
err = errno;
goto out;
}
- if (client_recv(&cfd, buf)) {
+ if (client_recv(&cfd, buf, srv_len)) {
err = errno;
goto out;
}
@@ -302,13 +328,13 @@ void *client_fn(LTP_ATTRIBUTE_UNUSED void *arg)
goto send;
if (cfd == -1) {
- cfd = client_connect_send(client_msg, client_msg_size);
+ cfd = client_connect_send(client_msg, cln_len);
if (cfd == -1) {
err = errno;
goto out;
}
- if (client_recv(&cfd, buf)) {
+ if (client_recv(&cfd, buf, srv_len)) {
err = errno;
break;
}
@@ -316,9 +342,12 @@ void *client_fn(LTP_ATTRIBUTE_UNUSED void *arg)
}
send:
- SAFE_SEND(1, cfd, client_msg, client_msg_size, MSG_NOSIGNAL);
+ if (max_rand_msg_len)
+ make_client_request(client_msg, &cln_len, &srv_len);
+
+ SAFE_SEND(1, cfd, client_msg, cln_len, MSG_NOSIGNAL);
- if (client_recv(&cfd, buf)) {
+ if (client_recv(&cfd, buf, srv_len)) {
err = errno;
break;
}
@@ -334,24 +363,6 @@ out:
return (void *) err;
}
-union net_size_field {
- char bytes[2];
- uint16_t value;
-};
-
-static void make_client_request(void)
-{
- client_msg[0] = start_byte;
-
- /* set size for reply */
- union net_size_field net_size;
- net_size.value = htons(server_msg_size);
- client_msg[1] = net_size.bytes[0];
- client_msg[2] = net_size.bytes[1];
-
- client_msg[client_msg_size - 1] = end_byte;
-}
-
static int parse_client_request(const char *msg)
{
union net_size_field net_size;
@@ -376,11 +387,6 @@ static void client_init(void)
thread_ids = SAFE_MALLOC(sizeof(pthread_t) * clients_num);
- client_msg = SAFE_MALLOC(client_msg_size);
- memset(client_msg, client_byte, client_msg_size);
-
- make_client_request();
-
struct addrinfo hints;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
@@ -424,9 +430,13 @@ static void client_run(void)
tst_res(TINFO, "total time '%ld' ms", clnt_time);
+ char client_msg[min_msg_len];
+ int msg_len = min_msg_len;
+ max_rand_msg_len = 0;
+ make_client_request(client_msg, &msg_len, &msg_len);
/* ask server to terminate */
client_msg[0] = start_fin_byte;
- int cfd = client_connect_send(client_msg, client_msg_size);
+ int cfd = client_connect_send(client_msg, msg_len);
if (cfd != -1) {
shutdown(cfd, SHUT_WR);
SAFE_CLOSE(cfd);
@@ -461,7 +471,7 @@ void *server_fn(void *cfd)
int num_requests = 0, offset = 0;
/* Reply will be constructed from first client request */
char send_msg[max_msg_len];
- int send_msg_size = 0;
+ int send_msg_len = 0;
char recv_msg[max_msg_len];
ssize_t recv_len;
@@ -494,16 +504,13 @@ void *server_fn(void *cfd)
if (recv_msg[0] == start_fin_byte)
goto out;
- /* if we send reply for the first time, construct it here */
- if (send_msg[0] != start_byte) {
- send_msg_size = parse_client_request(recv_msg);
- if (send_msg_size < 0) {
- tst_res(TFAIL, "wrong msg size '%d'",
- send_msg_size);
- goto out;
- }
- make_server_reply(send_msg, send_msg_size);
+ send_msg_len = parse_client_request(recv_msg);
+ if (send_msg_len < 0) {
+ tst_res(TFAIL, "wrong msg size '%d'",
+ send_msg_len);
+ goto out;
}
+ make_server_reply(send_msg, send_msg_len);
offset = 0;
@@ -517,11 +524,11 @@ void *server_fn(void *cfd)
switch (proto_type) {
case TYPE_SCTP:
- SAFE_SEND(1, client_fd, send_msg, send_msg_size,
+ SAFE_SEND(1, client_fd, send_msg, send_msg_len,
MSG_NOSIGNAL);
break;
default:
- SAFE_SENDTO(1, client_fd, send_msg, send_msg_size,
+ SAFE_SENDTO(1, client_fd, send_msg, send_msg_len,
MSG_NOSIGNAL, (struct sockaddr *)&remote_addr,
remote_addr_len);
}
@@ -709,9 +716,9 @@ static void setup(void)
tst_brk(TBROK, "Invalid client max requests '%s'", rarg);
if (tst_parse_int(Rarg, &server_max_requests, 1, INT_MAX))
tst_brk(TBROK, "Invalid server max requests '%s'", Rarg);
- if (tst_parse_int(narg, &client_msg_size, 3, max_msg_len))
+ if (tst_parse_int(narg, &init_cln_msg_len, min_msg_len, max_msg_len))
tst_brk(TBROK, "Invalid client msg size '%s'", narg);
- if (tst_parse_int(Narg, &server_msg_size, 3, max_msg_len))
+ if (tst_parse_int(Narg, &init_srv_msg_len, min_msg_len, max_msg_len))
tst_brk(TBROK, "Invalid server msg size '%s'", Narg);
if (tst_parse_int(qarg, &tfo_queue_size, 1, INT_MAX))
tst_brk(TBROK, "Invalid TFO queue size '%s'", qarg);
@@ -721,6 +728,16 @@ static void setup(void)
tst_brk(TBROK, "Invalid busy poll timeout'%s'", barg);
if (tst_parse_int(targ, &tfo_value, 0, INT_MAX))
tst_brk(TBROK, "Invalid net.ipv4.tcp_fastopen '%s'", targ);
+ if (tst_parse_int(Aarg, &max_rand_msg_len, 10, max_msg_len))
+ tst_brk(TBROK, "Invalid max randome payload size '%s'", Aarg);
+
+ if (max_rand_msg_len) {
+ max_rand_msg_len -= min_msg_len;
+ unsigned int seed = max_rand_msg_len ^ client_max_requests;
+
+ srand(seed);
+ tst_res(TINFO, "srand() seed 0x%x", seed);
+ }
/* if client_num is not set, use num of processors */
if (!clients_num)
@@ -739,8 +756,13 @@ static void setup(void)
server_addr, tcp_port);
tst_res(TINFO, "client max req: %d", client_max_requests);
tst_res(TINFO, "clients num: %d", clients_num);
- tst_res(TINFO, "client msg size: %d", client_msg_size);
- tst_res(TINFO, "server msg size: %d", server_msg_size);
+ if (max_rand_msg_len) {
+ tst_res(TINFO, "random msg size [%d %d]",
+ min_msg_len, max_rand_msg_len);
+ } else {
+ tst_res(TINFO, "client msg size: %d", init_cln_msg_len);
+ tst_res(TINFO, "server msg size: %d", init_srv_msg_len);
+ }
net.init = client_init;
net.run = client_run;
net.cleanup = client_cleanup;
@@ -822,7 +844,8 @@ static struct tst_option options[] = {
{"n:", &narg, "-n x Client message size"},
{"N:", &Narg, "-N x Server message size"},
{"m:", &Targ, "-m x Reply timeout in microsec."},
- {"d:", &rpath, "-d x x is a path to file where result is saved\n"},
+ {"d:", &rpath, "-d x x is a path to file where result is saved"},
+ {"A:", &Aarg, "-A x x max payload length (generated randomly)\n"},
{"R:", &Rarg, "Server:\n-R x x requests after which conn.closed"},
{"q:", &qarg, "-q x x - TFO queue"},
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 1/3] netstress: allow to resend requests for udp and dccp
2017-10-12 13:03 [LTP] [PATCH 1/3] netstress: allow to resend requests for udp and dccp Alexey Kodanev
2017-10-12 13:03 ` [LTP] [PATCH 2/3] netstress: remove verbose output Alexey Kodanev
2017-10-12 13:03 ` [LTP] [PATCH 3/3] netstress: randomize payload length Alexey Kodanev
@ 2017-10-31 10:51 ` Petr Vorel
2017-11-15 11:56 ` Alexey Kodanev
2 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2017-10-31 10:51 UTC (permalink / raw)
To: ltp
> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> ---
> testcases/network/netstress/netstress.c | 20 ++++++++++++++++++++
> 1 files changed, 20 insertions(+), 0 deletions(-)
LGTM.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 2/3] netstress: remove verbose output
2017-10-12 13:03 ` [LTP] [PATCH 2/3] netstress: remove verbose output Alexey Kodanev
@ 2017-10-31 12:14 ` Petr Vorel
0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2017-10-31 12:14 UTC (permalink / raw)
To: ltp
> It's not really helpful, can be done with tcpdump.
> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> ---
> testcases/network/netstress/netstress.c | 25 -------------------------
> 1 files changed, 0 insertions(+), 25 deletions(-)
LGTM.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 3/3] netstress: randomize payload length
2017-10-12 13:03 ` [LTP] [PATCH 3/3] netstress: randomize payload length Alexey Kodanev
@ 2017-10-31 12:27 ` Petr Vorel
2017-11-15 11:57 ` Alexey Kodanev
0 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2017-10-31 12:27 UTC (permalink / raw)
To: ltp
Hi,
> Not default, needs '-A x' option, where x is the upper limit
> of the random payload.
> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
<snip>
> + if (tst_parse_int(Aarg, &max_rand_msg_len, 10, max_msg_len))
> + tst_brk(TBROK, "Invalid max randome payload size '%s'", Aarg);
^ typo?
Otherwise looks good to me.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 1/3] netstress: allow to resend requests for udp and dccp
2017-10-31 10:51 ` [LTP] [PATCH 1/3] netstress: allow to resend requests for udp and dccp Petr Vorel
@ 2017-11-15 11:56 ` Alexey Kodanev
0 siblings, 0 replies; 8+ messages in thread
From: Alexey Kodanev @ 2017-11-15 11:56 UTC (permalink / raw)
To: ltp
On 10/31/2017 01:51 PM, Petr Vorel wrote:
>> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
>> ---
>> testcases/network/netstress/netstress.c | 20 ++++++++++++++++++++
>> 1 files changed, 20 insertions(+), 0 deletions(-)
I've pushed slightly modified version where timeout variable is
thread-local, also there are fixed number of retries and timeout
doubles with each failed requests up to 3 sec, so when there is
no connection, test will fail after ~30 seconds with "protocol
timeout" error.
Thanks,
Alexey
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 3/3] netstress: randomize payload length
2017-10-31 12:27 ` Petr Vorel
@ 2017-11-15 11:57 ` Alexey Kodanev
0 siblings, 0 replies; 8+ messages in thread
From: Alexey Kodanev @ 2017-11-15 11:57 UTC (permalink / raw)
To: ltp
On 10/31/2017 03:27 PM, Petr Vorel wrote:
> Hi,
>
>> Not default, needs '-A x' option, where x is the upper limit
>> of the random payload.
>> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> <snip>
>
>> + if (tst_parse_int(Aarg, &max_rand_msg_len, 10, max_msg_len))
>> + tst_brk(TBROK, "Invalid max randome payload size '%s'", Aarg);
> ^ typo?
>
> Otherwise looks good to me.
Fixed and applied.
Thanks,
Alexey
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-11-15 11:57 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-12 13:03 [LTP] [PATCH 1/3] netstress: allow to resend requests for udp and dccp Alexey Kodanev
2017-10-12 13:03 ` [LTP] [PATCH 2/3] netstress: remove verbose output Alexey Kodanev
2017-10-31 12:14 ` Petr Vorel
2017-10-12 13:03 ` [LTP] [PATCH 3/3] netstress: randomize payload length Alexey Kodanev
2017-10-31 12:27 ` Petr Vorel
2017-11-15 11:57 ` Alexey Kodanev
2017-10-31 10:51 ` [LTP] [PATCH 1/3] netstress: allow to resend requests for udp and dccp Petr Vorel
2017-11-15 11:56 ` Alexey Kodanev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.