[PATCH v2 mptcp] selftests: mptcp: make sendfile selftest work

Florian Westphal posted 1 patch 1 year, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20220729095550.3040-1-fw@strlen.de
Maintainers: Shuah Khan <shuah@kernel.org>, Florian Westphal <fw@strlen.de>, Mat Martineau <mathew.j.martineau@linux.intel.com>, Christoph Paasch <cpaasch@apple.com>, Matthieu Baerts <matthieu.baerts@tessares.net>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>
.../selftests/net/mptcp/mptcp_connect.c       | 26 ++++++++++++-------
1 file changed, 17 insertions(+), 9 deletions(-)
[PATCH v2 mptcp] selftests: mptcp: make sendfile selftest work
Posted by Florian Westphal 1 year, 9 months ago
When the selftest got added, sendfile() on mptcp sockets returned
-EOPNOTSUPP, so running 'mptcp_connect.sh -m sendfile' failed
immediately.

This is no longer the case, but the script fails anyway due to timeout.
Let the receiver know once the sender has sent all data, just like
with '-m mmap' mode.

v2: need to respect cfg_wait too, as pm_userspace.sh relied
on -m sendfile to keep the connection open (Mat Martineau)

Fixes: 048d19d444be ("mptcp: add basic kselftest for mptcp")
Reported-by: Xiumei Mu <xmu@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 .../selftests/net/mptcp/mptcp_connect.c       | 26 ++++++++++++-------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index e2ea6c126c99..24d4e9cb617e 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -553,6 +553,18 @@ static void set_nonblock(int fd, bool nonblock)
 		fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
 }
 
+static void shut_wr(int fd)
+{
+	/* Close our write side, ev. give some time
+	 * for address notification and/or checking
+	 * the current status
+	 */
+	if (cfg_wait)
+		usleep(cfg_wait);
+
+	shutdown(fd, SHUT_WR);
+}
+
 static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed_after_out)
 {
 	struct pollfd fds = {
@@ -630,14 +642,7 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed_after
 					/* ... and peer also closed already */
 					break;
 
-				/* ... but we still receive.
-				 * Close our write side, ev. give some time
-				 * for address notification and/or checking
-				 * the current status
-				 */
-				if (cfg_wait)
-					usleep(cfg_wait);
-				shutdown(peerfd, SHUT_WR);
+				shut_wr(peerfd);
 			} else {
 				if (errno == EINTR)
 					continue;
@@ -767,7 +772,7 @@ static int copyfd_io_mmap(int infd, int peerfd, int outfd,
 		if (err)
 			return err;
 
-		shutdown(peerfd, SHUT_WR);
+		shut_wr(peerfd);
 
 		err = do_recvfile(peerfd, outfd);
 		*in_closed_after_out = true;
@@ -791,6 +796,9 @@ static int copyfd_io_sendfile(int infd, int peerfd, int outfd,
 		err = do_sendfile(infd, peerfd, size);
 		if (err)
 			return err;
+
+		shut_wr(peerfd);
+
 		err = do_recvfile(peerfd, outfd);
 		*in_closed_after_out = true;
 	}
-- 
2.35.1


Re: [PATCH v2 mptcp] selftests: mptcp: make sendfile selftest work
Posted by Matthieu Baerts 1 year, 8 months ago
Hi Florian, Mat,

On 29/07/2022 11:55, Florian Westphal wrote:
> When the selftest got added, sendfile() on mptcp sockets returned
> -EOPNOTSUPP, so running 'mptcp_connect.sh -m sendfile' failed
> immediately.
> 
> This is no longer the case, but the script fails anyway due to timeout.
> Let the receiver know once the sender has sent all data, just like
> with '-m mmap' mode.
> 
> v2: need to respect cfg_wait too, as pm_userspace.sh relied
> on -m sendfile to keep the connection open (Mat Martineau)

Thank you for the patch and the review!

Now in our tree (fix for -net) with Mat's RvB tag:


New patches for t/upstream-net:
- febacb9a6dd6: selftests: mptcp: make sendfile selftest work
- Results: 17273797344c..06a049f34010 (export-net)

New patches for t/upstream:
- febacb9a6dd6: selftests: mptcp: make sendfile selftest work
- Results: ba0f79895fde..7f8f198f2f9b (export)


Tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export-net/20220803T163309
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20220803T163309


Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

Re: [PATCH v2 mptcp] selftests: mptcp: make sendfile selftest work
Posted by Mat Martineau 1 year, 9 months ago
On Fri, 29 Jul 2022, Florian Westphal wrote:

> When the selftest got added, sendfile() on mptcp sockets returned
> -EOPNOTSUPP, so running 'mptcp_connect.sh -m sendfile' failed
> immediately.
>
> This is no longer the case, but the script fails anyway due to timeout.
> Let the receiver know once the sender has sent all data, just like
> with '-m mmap' mode.
>
> v2: need to respect cfg_wait too, as pm_userspace.sh relied
> on -m sendfile to keep the connection open (Mat Martineau)
>
> Fixes: 048d19d444be ("mptcp: add basic kselftest for mptcp")
> Reported-by: Xiumei Mu <xmu@redhat.com>
> Signed-off-by: Florian Westphal <fw@strlen.de>

Looks good to me, tests run fine on my system. I tried to reproduce the 
failures that CI reported on the non-debug build but so far it doesn't 
look like this change caused those failures.

With the Fixes: tag I assume this is intended for -net?

Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>


> ---
> .../selftests/net/mptcp/mptcp_connect.c       | 26 ++++++++++++-------
> 1 file changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> index e2ea6c126c99..24d4e9cb617e 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
> @@ -553,6 +553,18 @@ static void set_nonblock(int fd, bool nonblock)
> 		fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
> }
>
> +static void shut_wr(int fd)
> +{
> +	/* Close our write side, ev. give some time
> +	 * for address notification and/or checking
> +	 * the current status
> +	 */
> +	if (cfg_wait)
> +		usleep(cfg_wait);
> +
> +	shutdown(fd, SHUT_WR);
> +}
> +
> static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed_after_out)
> {
> 	struct pollfd fds = {
> @@ -630,14 +642,7 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed_after
> 					/* ... and peer also closed already */
> 					break;
>
> -				/* ... but we still receive.
> -				 * Close our write side, ev. give some time
> -				 * for address notification and/or checking
> -				 * the current status
> -				 */
> -				if (cfg_wait)
> -					usleep(cfg_wait);
> -				shutdown(peerfd, SHUT_WR);
> +				shut_wr(peerfd);
> 			} else {
> 				if (errno == EINTR)
> 					continue;
> @@ -767,7 +772,7 @@ static int copyfd_io_mmap(int infd, int peerfd, int outfd,
> 		if (err)
> 			return err;
>
> -		shutdown(peerfd, SHUT_WR);
> +		shut_wr(peerfd);
>
> 		err = do_recvfile(peerfd, outfd);
> 		*in_closed_after_out = true;
> @@ -791,6 +796,9 @@ static int copyfd_io_sendfile(int infd, int peerfd, int outfd,
> 		err = do_sendfile(infd, peerfd, size);
> 		if (err)
> 			return err;
> +
> +		shut_wr(peerfd);
> +
> 		err = do_recvfile(peerfd, outfd);
> 		*in_closed_after_out = true;
> 	}
> -- 
> 2.35.1
>
>

--
Mat Martineau
Intel

Re: [PATCH v2 mptcp] selftests: mptcp: make sendfile selftest work
Posted by Florian Westphal 1 year, 9 months ago
Mat Martineau <mathew.j.martineau@linux.intel.com> wrote:
> Looks good to me, tests run fine on my system. I tried to reproduce the
> failures that CI reported on the non-debug build but so far it doesn't look
> like this change caused those failures.

Thanks for reviewing.

> With the Fixes: tag I assume this is intended for -net?

Yes, its intended for -net.

Re: selftests: mptcp: make sendfile selftest work: Tests Results
Posted by MPTCP CI 1 year, 9 months ago
Hi Florian,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal:
  - Unstable: 2 failed test(s): selftest_mptcp_join selftest_simult_flows 🔴:
  - Task: https://cirrus-ci.com/task/5322407467548672
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5322407467548672/summary/summary.txt

- KVM Validation: debug:
  - Success! ✅:
  - Task: https://cirrus-ci.com/task/6448307374391296
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/6448307374391296/summary/summary.txt

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/1b04f2259a4c


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-debug

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 (Tessares)