syscalls/sendmmsg: add new test
RFC PATCH v2 1/1 syscalls/sendmmsg: add new test
Test basic functionality of sendmmsg and recvmmsg.
---
Known issues/questions:
- This test occasionally gets stuck when the two messages get sent by separate sendmmsg calls. The two sendmmsg calls complete successfully but recvmmsg blocks indefinitely. I am not yet sure what would cause this.
- I have not used tst_get_unused_port() because I'm unsure of how that function should be made available for both the new and old test API? I can just create a duplicate function but is there a cleaner way?
Changes since v1:
- rebased on recent autotools cleanup for libc func checks
- used test_variant to test direct syscalls and libc syscalls
- use tst_syscall instead of ltp_syscall
- check that both messages have been sent, retry sending messages if necessary
- use tst_brk(TBROK... if sendmmsg fails so recv thread is not kept waiting
configure.ac | 3 + include/lapi/socket.h | 8 + runtest/syscalls | 2 + testcases/kernel/syscalls/sendmmsg/.gitignore | 1 + testcases/kernel/syscalls/sendmmsg/Makefile | 9 ++ .../kernel/syscalls/sendmmsg/sendmmsg01.c | 147 ++++++++++++++++++ .../kernel/syscalls/sendmmsg/sendmmsg_var.h | 60 +++++++ 7 files changed, 230 insertions(+) create mode 100644 testcases/kernel/syscalls/sendmmsg/.gitignore create mode 100644 testcases/kernel/syscalls/sendmmsg/Makefile create mode 100644 testcases/kernel/syscalls/sendmmsg/sendmmsg01.c create mode 100644 testcases/kernel/syscalls/sendmmsg/sendmmsg_var.h
configure.ac +3 -0
@@ -75,8 +75,10 @@ AC_CHECK_FUNCS([ \ pwritev \ pwritev2 \ readlinkat \ + recvmmsg \ renameat \ renameat2 \ + sendmmsg \ sigpending \ splice \ stime \
@@ -243,6 +245,7 @@ LTP_CHECK_TIME LTP_CHECK_TIMERFD test "x$with_tirpc" = xyes && LTP_CHECK_TIRPC LTP_CHECK_TPACKET_V3 +LTP_CHECK_MMSGHDR LTP_CHECK_UNAME_DOMAINNAME LTP_CHECK_XFS_QUOTACTL LTP_CHECK_X_TABLES
include/lapi/socket.h +8 -0
@@ -19,6 +19,7 @@#ifndef __LAPI_SOCKET_H__#define __LAPI_SOCKET_H__ +#include "config.h" #include <sys/socket.h> #ifndef MSG_ZEROCOPY
@@ -69,4 +70,11 @@# define SOL_ALG 279#endif +#ifndef HAVE_STRUCT_MMSGHDR +struct mmsghdr { +struct msghdr msg_hdr; +unsigned int msg_len; +}; +#endif +#endif /* __LAPI_SOCKET_H__ */
runtest/syscalls +2 -0
@@ -1109,6 +1109,8 @@ sendfile09_64 sendfile09_64 sendmsg01 sendmsg01 sendmsg02 sendmsg02 +sendmmsg01 sendmmsg01 + sendto01 sendto01 sendto02 sendto02
testcases/kernel/syscalls/sendmmsg/.gitignore new file +1 -0
@@ -0,0 +1 @@ +sendmmsg01
testcases/kernel/syscalls/sendmmsg/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +sendmmsg01: CFLAGS+=-pthread + +include $(top_srcdir)/include/mk/testcases.mk + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/sendmmsg/sendmmsg01.c new file +147 -0
147 lines not on this page · raw message
testcases/kernel/syscalls/sendmmsg/sendmmsg_var.h new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.21.0.593.g511ec345e18-goog
RFC PATCH v2 1/1 syscalls/sendmmsg: add new test
Hi Steve,
Quoted 9 lines
Known issues/questions:
- This test occasionally gets stuck when the two messages get sent by separate sendmmsg calls. The two sendmmsg calls complete successfully but recvmmsg blocks indefinitely. I am not yet sure what would cause this.- I have not used
tst_get_unused_port()because I'm unsure of how that function should be made available for both the new and old test API? I can just create a duplicate function but is there a cleaner way?
As I need tst_get_unused_port() as well, I've sent a patch to port it to new API and available for both new and legacy API via TST_GET_UNUSED_PORT() macro [1].
Kind regards,
Petr
RFC PATCH v2 1/1 syscalls/sendmmsg: add new test
In reply to Steve MuckleHi!
Quoted 5 lines
Known issues/questions:
- This test occasionally gets stuck when the two messages get sent by separate sendmmsg calls. The two sendmmsg calls complete successfully but recvmmsg blocks indefinitely. I am not yet sure what would cause this.
There is a race between the sender and receiver thread, if the sender thread finishes before the receiver thread binds the socket the packets are simply dropped since this is SOCK_DGRAM and nobody is listening at the other side of the socket yet.
You have to synchronize the threads with checkpoints so that the sender thread does not send anything until the receiver binds the socket.
Quoted 3 lines
- I have not used
tst_get_unused_port()because I'm unsure of how that function should be made available for both the new and old test API? I can just create a duplicate function but is there a cleaner way?
Peter just merged patch that adds this functionality to new library.
You are also missing the SPDX licence identifier and other than this there are minor coding style violation (hint use checkpatch.pl).
Apart from these the code looks good.
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH v2 1/1 syscalls/sendmmsg: add new test
Hi!
Ping. Are you going to work on this test or should I take over?
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH v2 1/1 syscalls/sendmmsg: add new test
Quoted 2 lines · Cyril Hrubis
Hi!
Ping. Are you going to work on this test or should I take over?
Hi sorry for the delay, yes I'm just getting back to this now.