tools/testing/selftests/net/tls.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
From: Gang Yan <yangang@kylinos.cn>
When running TLS tests in a virtual machine/container environment, they
fail:
# tls.c:1479:mutliproc_even: Expected fd (-1) >= 0 (0)
# mutliproc_even: Test terminated by assertion
# FAIL tls.12_aes_gcm.mutliproc_even
not ok 59 tls.12_aes_gcm.mutliproc_even
# RUN tls.12_aes_gcm.mutliproc_readers ...
# tls.c:1479:mutliproc_readers: Expected fd (-1) >= 0 (0)
# mutliproc_readers: Test terminated by assertion
# FAIL tls.12_aes_gcm.mutliproc_readers
not ok 60 tls.12_aes_gcm.mutliproc_readers
# RUN tls.12_aes_gcm.mutliproc_writers ...
# tls.c:1479:mutliproc_writers: Expected fd (-1) >= 0 (0)
# mutliproc_writers: Test terminated by assertion
# FAIL tls.12_aes_gcm.mutliproc_writers
not ok 61 tls.12_aes_gcm.mutliproc_writers
This is because the /tmp directory uses the virtiofs filesystem, which does
not support the O_TMPFILE feature.
This patch uses mkstemp() to create temporary files, thereby eliminating
the dependency on the O_TMPFILE feature. And closes the file descriptor
(fd) and deletes the temfile after the test ends.
Co-developed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
---
tools/testing/selftests/net/tls.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
index 9e2ccea13d70..f4b8dd99d501 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -1456,6 +1456,7 @@ test_mutliproc(struct __test_metadata *_metadata, struct _test_data_tls *self,
bool sendpg, unsigned int n_readers, unsigned int n_writers)
{
const unsigned int n_children = n_readers + n_writers;
+ char tmpfile[] = "/tmp/tls_test_tmpfile_XXXXXX";
const size_t data = 6 * 1000 * 1000;
const size_t file_sz = data / 100;
size_t read_bias, write_bias;
@@ -1469,7 +1470,7 @@ test_mutliproc(struct __test_metadata *_metadata, struct _test_data_tls *self,
write_bias = n_readers / n_writers ?: 1;
/* prep a file to send */
- fd = open("/tmp/", O_TMPFILE | O_RDWR, 0600);
+ fd = mkstemp(tmpfile);
ASSERT_GE(fd, 0);
memset(buf, 0xac, file_sz);
@@ -1527,6 +1528,8 @@ test_mutliproc(struct __test_metadata *_metadata, struct _test_data_tls *self,
left -= res;
}
}
+ close(fd);
+ unlink(tmpfile);
}
TEST_F(tls, mutliproc_even)
--
2.51.0
On Wed, 2026-01-14 at 10:12 +0800, Geliang Tang wrote:
> From: Gang Yan <yangang@kylinos.cn>
>
> When running TLS tests in a virtual machine/container environment,
> they
> fail:
>
> # tls.c:1479:mutliproc_even: Expected fd (-1) >= 0 (0)
> # mutliproc_even: Test terminated by assertion
> # FAIL tls.12_aes_gcm.mutliproc_even
> not ok 59 tls.12_aes_gcm.mutliproc_even
> # RUN tls.12_aes_gcm.mutliproc_readers ...
> # tls.c:1479:mutliproc_readers: Expected fd (-1) >= 0 (0)
> # mutliproc_readers: Test terminated by assertion
> # FAIL tls.12_aes_gcm.mutliproc_readers
> not ok 60 tls.12_aes_gcm.mutliproc_readers
> # RUN tls.12_aes_gcm.mutliproc_writers ...
> # tls.c:1479:mutliproc_writers: Expected fd (-1) >= 0 (0)
> # mutliproc_writers: Test terminated by assertion
> # FAIL tls.12_aes_gcm.mutliproc_writers
> not ok 61 tls.12_aes_gcm.mutliproc_writers
>
> This is because the /tmp directory uses the virtiofs filesystem,
> which does
> not support the O_TMPFILE feature.
>
> This patch uses mkstemp() to create temporary files, thereby
> eliminating
> the dependency on the O_TMPFILE feature. And closes the file
> descriptor
> (fd) and deletes the temfile after the test ends.
>
> Co-developed-by: Geliang Tang <geliang@kernel.org>
> Signed-off-by: Geliang Tang <geliang@kernel.org>
> Signed-off-by: Gang Yan <yangang@kylinos.cn>
> ---
> tools/testing/selftests/net/tls.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/net/tls.c
> b/tools/testing/selftests/net/tls.c
> index 9e2ccea13d70..f4b8dd99d501 100644
> --- a/tools/testing/selftests/net/tls.c
> +++ b/tools/testing/selftests/net/tls.c
> @@ -1456,6 +1456,7 @@ test_mutliproc(struct __test_metadata
> *_metadata, struct _test_data_tls *self,
> bool sendpg, unsigned int n_readers, unsigned int
> n_writers)
> {
> const unsigned int n_children = n_readers + n_writers;
> + char tmpfile[] = "/tmp/tls_test_tmpfile_XXXXXX";
> const size_t data = 6 * 1000 * 1000;
> const size_t file_sz = data / 100;
> size_t read_bias, write_bias;
> @@ -1469,7 +1470,7 @@ test_mutliproc(struct __test_metadata
> *_metadata, struct _test_data_tls *self,
> write_bias = n_readers / n_writers ?: 1;
>
> /* prep a file to send */
> - fd = open("/tmp/", O_TMPFILE | O_RDWR, 0600);
> + fd = mkstemp(tmpfile);
Superseded.
I noticed that this mkstemp approach was already implemented in
chunked_sendfile(). To eliminate duplication, in v2 I just submitted, I
extracted this logic into a new helper create_temp_file(), which is now
shared by both chunked_sendfile() and test_mutliproc().
Thanks,
-Geliang
> ASSERT_GE(fd, 0);
>
> memset(buf, 0xac, file_sz);
> @@ -1527,6 +1528,8 @@ test_mutliproc(struct __test_metadata
> *_metadata, struct _test_data_tls *self,
> left -= res;
> }
> }
> + close(fd);
> + unlink(tmpfile);
> }
>
> TEST_F(tls, mutliproc_even)
Hi Gang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Unstable: 1 failed test(s): packetdrill_add_addr 🔴
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Unstable: 1 failed test(s): packetdrill_add_addr 🔴
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/20980210139
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/e5ae1296bfd1
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1042080
If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normal
For more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
© 2016 - 2026 Red Hat, Inc.