[PATCH mptcp-net] mptcp: Do not return EINPROGRESS when subflow creation succeeds

Mat Martineau posted 1 patch 2 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20220715181207.522021-1-mathew.j.martineau@linux.intel.com
There is a newer version of this series
Maintainers: "David S. Miller" <davem@davemloft.net>, Kishen Maloor <kishen.maloor@intel.com>, Peter Krystad <peter.krystad@linux.intel.com>, Matthieu Baerts <matthieu.baerts@tessares.net>, Paolo Abeni <pabeni@redhat.com>, Eric Dumazet <edumazet@google.com>, Florian Westphal <fw@strlen.de>, Jakub Kicinski <kuba@kernel.org>, Mat Martineau <mathew.j.martineau@linux.intel.com>
net/mptcp/subflow.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH mptcp-net] mptcp: Do not return EINPROGRESS when subflow creation succeeds
Posted by Mat Martineau 2 months, 2 weeks ago
New subflows are created within the kernel using O_NONBLOCK, so
EINPROGRESS is the expected return value from kernel_connect().
__mptcp_subflow_connect() has the correct logic to consider EINPROGRESS
to be a successful case, but it has also used that error code as its
return value.

Before v5.19 this was benign: all the callers ignored the return
value. Starting in v5.19 there is a MPTCP_PM_CMD_SUBFLOW_CREATE generic
netlink command that does use the return value, so the EINPROGRESS gets
propagated to userspace.

Make __mptcp_subflow_connect() always return 0 on success instead.

Fixes: ec3edaa7ca6c ("mptcp: Add handling of outgoing MP_JOIN requests")
Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
---
 net/mptcp/subflow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 63e8892ec807..af28f3b60389 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -1533,7 +1533,7 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,
 	mptcp_sock_graft(ssk, sk->sk_socket);
 	iput(SOCK_INODE(sf));
 	WRITE_ONCE(msk->allow_infinite_fallback, false);
-	return err;
+	return 0;
 
 failed_unlink:
 	list_del(&subflow->node);
-- 
2.37.1


Re: [PATCH mptcp-net] mptcp: Do not return EINPROGRESS when subflow creation succeeds
Posted by Mat Martineau 2 months ago
On Fri, 15 Jul 2022, Mat Martineau wrote:

> New subflows are created within the kernel using O_NONBLOCK, so
> EINPROGRESS is the expected return value from kernel_connect().
> __mptcp_subflow_connect() has the correct logic to consider EINPROGRESS
> to be a successful case, but it has also used that error code as its
> return value.
>
> Before v5.19 this was benign: all the callers ignored the return
> value. Starting in v5.19 there is a MPTCP_PM_CMD_SUBFLOW_CREATE generic
> netlink command that does use the return value, so the EINPROGRESS gets
> propagated to userspace.
>
> Make __mptcp_subflow_connect() always return 0 on success instead.
>
> Fixes: ec3edaa7ca6c ("mptcp: Add handling of outgoing MP_JOIN requests")
> Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>

Noting here for the lore.kernel.org records: Paolo acked this patch today 
on IRC (#mptcp / irc.libera.chat).

Given that ack, the simplicity of the change, and the timeline for this 
week's -net pull request, I'm sending this patch to netdev today.

Thanks,

Mat

> ---
> net/mptcp/subflow.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 63e8892ec807..af28f3b60389 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -1533,7 +1533,7 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,
> 	mptcp_sock_graft(ssk, sk->sk_socket);
> 	iput(SOCK_INODE(sf));
> 	WRITE_ONCE(msk->allow_infinite_fallback, false);
> -	return err;
> +	return 0;
>
> failed_unlink:
> 	list_del(&subflow->node);
> -- 
> 2.37.1
>
>

--
Mat Martineau
Intel

Re: [PATCH mptcp-net] mptcp: Do not return EINPROGRESS when subflow creation succeeds
Posted by Matthieu Baerts 2 months ago
Hi Mat,

On 25/07/2022 22:52, Mat Martineau wrote:
> On Fri, 15 Jul 2022, Mat Martineau wrote:
> 
>> New subflows are created within the kernel using O_NONBLOCK, so
>> EINPROGRESS is the expected return value from kernel_connect().
>> __mptcp_subflow_connect() has the correct logic to consider EINPROGRESS
>> to be a successful case, but it has also used that error code as its
>> return value.
>>
>> Before v5.19 this was benign: all the callers ignored the return
>> value. Starting in v5.19 there is a MPTCP_PM_CMD_SUBFLOW_CREATE generic
>> netlink command that does use the return value, so the EINPROGRESS gets
>> propagated to userspace.
>>
>> Make __mptcp_subflow_connect() always return 0 on success instead.
>>
>> Fixes: ec3edaa7ca6c ("mptcp: Add handling of outgoing MP_JOIN requests")
>> Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow
>> establishment")
>> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
> 
> Noting here for the lore.kernel.org records: Paolo acked this patch
> today on IRC (#mptcp / irc.libera.chat).
> 
> Given that ack, the simplicity of the change, and the timeline for this
> week's -net pull request, I'm sending this patch to netdev today.

Thank you for the patch and sorry for the delay.

I also applied this patch in our tree:

New patches for t/upstream-net:
- 75b93cbf0a74: mptcp: Do not return EINPROGRESS when subflow creation
succeeds
- Results: 78784c054bf1..76dabdd1e02b (export-net)

New patches for t/upstream:
- 75b93cbf0a74: mptcp: Do not return EINPROGRESS when subflow creation
succeeds
- Results: 7d1efaa490cf..f6822255c960 (export)

Tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export-net/20220726T082127
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20220726T082127

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

Re: [PATCH mptcp-net] mptcp: Do not return EINPROGRESS when subflow creation succeeds
Posted by Mat Martineau 2 months, 1 week ago
On Fri, 15 Jul 2022, Mat Martineau wrote:

> New subflows are created within the kernel using O_NONBLOCK, so
> EINPROGRESS is the expected return value from kernel_connect().
> __mptcp_subflow_connect() has the correct logic to consider EINPROGRESS
> to be a successful case, but it has also used that error code as its
> return value.
>
> Before v5.19 this was benign: all the callers ignored the return
> value. Starting in v5.19 there is a MPTCP_PM_CMD_SUBFLOW_CREATE generic
> netlink command that does use the return value, so the EINPROGRESS gets
> propagated to userspace.
>
> Make __mptcp_subflow_connect() always return 0 on success instead.
>
> Fixes: ec3edaa7ca6c ("mptcp: Add handling of outgoing MP_JOIN requests")
> Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment")
> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>

Paolo do you have a moment to look at this very short patch? Hoping to get 
it in to -net by early next week.

Thanks!

- Mat


> ---
> net/mptcp/subflow.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index 63e8892ec807..af28f3b60389 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -1533,7 +1533,7 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,
> 	mptcp_sock_graft(ssk, sk->sk_socket);
> 	iput(SOCK_INODE(sf));
> 	WRITE_ONCE(msk->allow_infinite_fallback, false);
> -	return err;
> +	return 0;
>
> failed_unlink:
> 	list_del(&subflow->node);
> -- 
> 2.37.1
>
>

--
Mat Martineau
Intel

Re: mptcp: Do not return EINPROGRESS when subflow creation succeeds: Tests Results
Posted by MPTCP CI 2 months, 2 weeks ago
Hi Mat,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

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

- KVM Validation: debug:
  - Unstable: 1 failed test(s): packetdrill_sockopts 🔴:
  - Task: https://cirrus-ci.com/task/5095643998846976
  - Summary: https://api.cirrus-ci.com/v1/artifact/task/5095643998846976/summary/summary.txt

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


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)