netstress: new option and some enhancements
Subsystems (2)
cover netstress: new option and some enhancements
Mainly, for UDP protocol.
Alexey Kodanev (4):
netstress: support SO_REUSEPORT with new 'P' flag
netstress: allow setting MSG_ZEROCOPY for other protocols
netstress: handle zero length message for datagram sockets
netstress: increase timeout errors counter
testcases/network/netstress/netstress.c | 39 ++++++++++++++++++++++-------- 1 files changed, 28 insertions(+), 11 deletions(-)
PATCH 1/4 netstress: support SO_REUSEPORT with new 'P' flag
netstress tool can be used manually by setting -P flag for a server. There is no test-case yet that specifically auto tests this functionality or uses it, but it should be easy to create one. For example, starting multiple netstress instances on the same port.
--- testcases/network/netstress/netstress.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
testcases/network/netstress/netstress.c +6 -0
@@ -147,6 +147,7 @@ struct sock_info {static char *zcopy;static int send_flags =MSG_NOSIGNAL ; +static char *reuse_port;static void init_socket_opts (int sd) {
@@ -308,6 +309,8 @@ static void bind_before_connect(int sd)if (bind_no_port)SAFE_SETSOCKOPT_INT (sd,SOL_IP ,IP_BIND_ADDRESS_NO_PORT ,1 ); +if (reuse_port) +SAFE_SETSOCKOPT_INT (sd,SOL_SOCKET ,SO_REUSEPORT ,1 );SAFE_BIND (sd, local_addrinfo->ai_addr, local_addrinfo->ai_addrlen);
@@ -674,6 +677,8 @@ static void server_init(void)/* IPv6 socket is also able to access IPv4 protocol stack */ sfd =SAFE_SOCKET (family, sock_type, protocol);SAFE_SETSOCKOPT_INT (sfd,SOL_SOCKET ,SO_REUSEADDR ,1 ); +if (reuse_port) +SAFE_SETSOCKOPT_INT (sfd,SOL_SOCKET ,SO_REUSEPORT ,1 );tst_res (TINFO ,"assigning a name to the server socket..." );SAFE_BIND (sfd, local_addrinfo->ai_addr, local_addrinfo->ai_addrlen);
@@ -996,6 +1001,7 @@ static struct tst_option options[] = { {"b:", &barg, "-b x x - low latency busy poll timeout"}, {"T:", &type, "-T x tcp (default), udp, udp_lite, dccp, sctp"}, {"z", &zcopy, "-z enable SO_ZEROCOPY"}, + {"P:", &reuse_port, "-P enable SO_REUSEPORT"}, {"D:", &dev, "-d x bind to device x\n"}, {"H:", &server_addr, "Client:\n-H x Server name or IP address"},
Signature · 1 line
1.7.1
PATCH 1/4 netstress: support SO_REUSEPORT with new 'P' flag
Hi Alexey,
Quoted 7 lines
netstress tool can be used manually by setting -P flag for a server. There is no test-case yet that specifically auto tests this functionality or uses it, but it should be easy to create one. For example, starting multiple netstress instances on the same port.
Signed-off-by Alexey Kodanev <[email protected]>
Kind regards,
Petr
PATCH 1/4 netstress: support SO_REUSEPORT with new 'P' flag
Quoted 10 lines · Petr Vorel
Hi Alexey,
Quoted 7 lines
netstress tool can be used manually by setting -P flag for a server. There is no test-case yet that specifically auto tests this functionality or uses it, but it should be easy to create one. For example, starting multiple netstress instances on the same port.
Signed-off-by Alexey Kodanev <[email protected]>Reviewed-by Petr Vorel <[email protected]>
Patch-set applied, thanks for review Petr!
PATCH 2/4 netstress: allow setting MSG_ZEROCOPY for other protocols
In reply to Alexey Kodanev--- testcases/network/netstress/netstress.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
testcases/network/netstress/netstress.c +3 -2
@@ -942,13 +942,14 @@ static void setup(void) } } +if (zcopy) + send_flags |=MSG_ZEROCOPY ; +switch (proto_type) {case TYPE_TCP :tst_res (TINFO ,"TCP %s is using %s TCP API." , (client_mode) ?"client" :"server" , (fastopen_api) ?"Fastopen" :"old" ); -if (zcopy) - send_flags |=MSG_ZEROCOPY ;check_tfo_value ();break ;case TYPE_UDP :
Signature · 1 line
1.7.1
PATCH 2/4 netstress: allow setting MSG_ZEROCOPY for other protocols
Hi Alexey,
Quoted 1 line
Signed-off-by Alexey Kodanev <[email protected]>
Quoted 15 lines
--- testcases/network/netstress/netstress.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)testcases/network/netstress/netstress.c +3
-0@@ -942,13 +942,14 @@ static void setup(void) } } +if (zcopy) + send_flags |=MSG_ZEROCOPY ; +
testcases/network/netstress/netstress.c static void setup(void) · line 955
Quoted 10 lines
testcases/network/netstress/netstress.c +0
-2switch (proto_type) {case TYPE_TCP :tst_res (TINFO ,"TCP %s is using %s TCP API." , (client_mode) ?"client" :"server" , (fastopen_api) ?"Fastopen" :"old" ); -if (zcopy) - send_flags |=MSG_ZEROCOPY ;check_tfo_value ();break ;case TYPE_UDP :
BTW MSG_ZEROCOPY is enabled only for TCP and UDP, but we allow it to be set on all, which leads to BROK:
./netstress -z -T sctp
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
netstress.c:938: INFO: max requests '3'
netstress.c:990: INFO: SCTP server
netstress.c:693: INFO: assigning a name to the server socket... netstress.c:700: INFO: bind to port 37196
safe_net.c:186: BROK: netstress.c:717: setsockopt(3, 1, 60, 0x7fff155701a4, 4) failed: ???
Kind regards,
Petr
PATCH 2/4 netstress: allow setting MSG_ZEROCOPY for other protocols
Hi Petr,
Quoted 4 lines · Petr Vorel
Hi Alexey,
Quoted 1 line
Signed-off-by Alexey Kodanev <[email protected]>Reviewed-by Petr Vorel <[email protected]>
Thanks for review!
Quoted 28 lines
Quoted 16 lines
--- testcases/network/netstress/netstress.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)testcases/network/netstress/netstress.c +3
-0@@ -942,13 +942,14 @@ static void setup(void) } } +if (zcopy) + send_flags |=MSG_ZEROCOPY ; +testcases/network/netstress/netstress.c static void setup(void) · line 955
Quoted 10 lines
testcases/network/netstress/netstress.c +0
-2switch (proto_type) {case TYPE_TCP :tst_res (TINFO ,"TCP %s is using %s TCP API." , (client_mode) ?"client" :"server" , (fastopen_api) ?"Fastopen" :"old" ); -if (zcopy) - send_flags |=MSG_ZEROCOPY ;check_tfo_value ();break ;case TYPE_UDP :BTW
MSG_ZEROCOPYis enabled only for TCP and UDP, but we allow it to be set on
Quoted 9 lines
all, which leads to BROK:
./netstress -z -T sctp
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
netstress.c:938: INFO: max requests '3'
netstress.c:990: INFO: SCTP server
netstress.c:693: INFO: assigning a name to the server socket... netstress.c:700: INFO: bind to port 37196
safe_net.c:186: BROK: netstress.c:717:setsockopt(3, 1, 60, 0x7fff155701a4, 4)failed: ???
This is expected fail, I would keep it.
Hmm, there is no error description. I've checked the errno returned and the kernel sources, found that it is actually returning ENOTSUPP(524). I think it should rather be EOPNOTSUPP(95), since the error is returned to user-space [1]:
net/core/sock.c +2 -2
@@ -1023,9 +1023,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname, sk->sk_protocol == IPPROTO_TCP) || (sk->sk_type ==SOCK_DGRAM && sk->sk_protocol == IPPROTO_UDP))) - ret = -ENOTSUPP; + ret = -EOPNOTSUPP; }else if (sk->sk_family !=PF_RDS ) { - ret = -ENOTSUPP ; + ret = -EOPNOTSUPP ; }if (!ret) {if (val <0 || val >1 )
For LTP library: may be we need to return the actual errno if strerror() returns nothing?
[1] https://lists.gt.net/linux/kernel/2207071
Quoted 4 lines
Kind regards,
Petr
PATCH 2/4 netstress: allow setting MSG_ZEROCOPY for other protocols
Hi Alexey,
Quoted 11 lines
Quoted 9 lines
BTW
MSG_ZEROCOPYis enabled only for TCP and UDP, but we allow it to be set on all, which leads to BROK:
./netstress -z -T sctp
tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s
netstress.c:938: INFO: max requests '3'
netstress.c:990: INFO: SCTP server
netstress.c:693: INFO: assigning a name to the server socket... netstress.c:700: INFO: bind to port 37196
safe_net.c:186: BROK: netstress.c:717:setsockopt(3, 1, 60, 0x7fff155701a4, 4)failed: ???This is expected fail, I would keep it.
Agree, other protocols might gain the support one day.
Quoted 10 lines
Hmm, there is no error description. I've checked the errno returned and the kernel sources, found that it is actually returning ENOTSUPP(524). I think it should rather be EOPNOTSUPP(95), since the error is returned to user-space [1]:
net/core/sock.c +0
-0@@ -1023,9 +1023,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname, sk->sk_protocol == IPPROTO_TCP) ||
net/core/sock.c int sock_setsockopt(struct socket *sock, int level, int optname, · line 1031
Quoted 10 lines
net/core/sock.c +2
-2(sk->sk_type == SOCK_DGRAM && sk->sk_protocol == IPPROTO_UDP))) - ret = -ENOTSUPP ; + ret = -EOPNOTSUPP ; }else if (sk->sk_family !=PF_RDS ) { - ret = -ENOTSUPP ; + ret = -EOPNOTSUPP ; }if (!ret) {if (val <0 || val >1 )
Interesting. IMHO it'd make sense to fix it.
Quoted 2 lines
For LTP library: may be we need to return the actual errno if
strerror()returns nothing?
yes, that'd be useful. Assume you send a patch.
Quoted 1 line
Kind regards,
Petr
PATCH 3/4 netstress: handle zero length message for datagram sockets
In reply to Alexey KodanevDon't treat them as errors unless there are too many of them.
--- testcases/network/netstress/netstress.c | 26 ++++++++++++++++++-------- 1 files changed, 18 insertions(+), 8 deletions(-)
testcases/network/netstress/netstress.c +18 -8
@@ -89,6 +89,7 @@ static char *source_addr;static char *server_bg;static int busy_poll =-1 ;static int max_etime_cnt =12 ;/* ~30 sec max timeout if no connection */ +static int max_eshutdown_cnt =10 ;static int max_pmtu_err =10 ;enum {
@@ -142,6 +143,7 @@ struct sock_info {socklen_t raddr_len;int etime_cnt;int pmtu_err_cnt; +int eshutdown_cnt;int timeout; };
@@ -287,14 +289,22 @@ static int client_recv(char *buf, int srv_msg_len, struct sock_info *i)return 0 ; } -if (errno ==ETIME && sock_type !=SOCK_STREAM ) { -if (++(i->etime_cnt) > max_etime_cnt) -tst_brk (TFAIL ,"client requests timeout %d times, last timeout %dms" , - i->etime_cnt, i->timeout); -/* Increase timeout in poll up to 3.2 sec */ -if (i->timeout <3000 ) - i->timeout <<=1 ; -return 0 ; +if (sock_type !=SOCK_STREAM ) { +if (errno ==ETIME ) { +if (++(i->etime_cnt) > max_etime_cnt) +tst_brk (TFAIL ,"client requests timeout %d times, last timeout %dms" , + i->etime_cnt, i->timeout); +/* Increase timeout in poll up to 3.2 sec */ +if (i->timeout <3000 ) + i->timeout <<=1 ; +return 0 ; + } +if (errno ==ESHUTDOWN ) { +if (++(i->eshutdown_cnt) > max_eshutdown_cnt) +tst_brk (TFAIL ,"too many zero-length msgs" ); +tst_res (TINFO ,"%d-length msg on sock %d" , len, i->fd); +return 0 ; + } }SAFE_CLOSE (i->fd);
Signature · 1 line
1.7.1
PATCH 4/4 netstress: increase timeout errors counter
In reply to Alexey KodanevMake sure we avoid false-positives with stress test scenarious.
--- testcases/network/netstress/netstress.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
testcases/network/netstress/netstress.c +1 -1
@@ -88,7 +88,7 @@ static char *server_addr = "localhost";static char *source_addr;static char *server_bg;static int busy_poll =-1 ; -static int max_etime_cnt =12 ;/* ~30 sec max timeout if no connection */ +static int max_etime_cnt =21 ;/* ~60 sec max timeout if no connection */ static int max_eshutdown_cnt =10 ;static int max_pmtu_err =10 ;
Signature · 1 line
1.7.1