diff mbox series

[mptcp-next] mptcp: fix invalid addr occupy 'add_addr_accepted'

Message ID tencent_0FE3ED0442E69C9D86C0AEEE338A49F90305@qq.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [mptcp-next] mptcp: fix invalid addr occupy 'add_addr_accepted' | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch warning WARNING: line length of 88 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-12--00-00 (tests: 795)

Commit Message

Gang Yan Dec. 11, 2024, 9:03 a.m. UTC
From: Gang Yan <yangang@kylinos.cn>

This patch fixes an issue where an invalid address is announce as a
signal, the 'add_addr_accepted' is incorrectly added several times
when 'retransmit ADD_ADDR'. So we need to update this variable
when the connection is removed from conn_list by mptcp_worker. So that
the available address can be added in time.

In fact, the 'add_addr_accepted' is only declined when 'RM_ADDR'
by now, so when subflows are getting closed from the other peer,
the new signal is not accepted as well.

We noticed there have exist some problems related to this.I think
this patch effectively resolves them.

Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/498
Signed-off-by: Gang Yan <yangang@kylinos.cn>
---
 net/mptcp/protocol.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Matthieu Baerts Dec. 12, 2024, 6:23 p.m. UTC | #1
Hi Gang Yan,

Thank you for this patch!

I have a few suggestions below. Do you mind sending the next version(s)
to the MPTCP list only, no need to include the netdev ML and the net
maintainers for the moment I think.

On 11/12/2024 10:03, Gang Yan wrote:
> From: Gang Yan <yangang@kylinos.cn>
> 
> This patch fixes an issue where an invalid address is announce as a
> signal, the 'add_addr_accepted' is incorrectly added several times
> when 'retransmit ADD_ADDR'. So we need to update this variable
> when the connection is removed from conn_list by mptcp_worker. So that
> the available address can be added in time.
> 
> In fact, the 'add_addr_accepted' is only declined when 'RM_ADDR'
> by now, so when subflows are getting closed from the other peer,

Does it mean that in this case, the counter will be decreased twice:
when the RM_ADDR is received, and when the subflow is closed, no?

I guess no because you hooked this in a different path, right?

> the new signal is not accepted as well.
> 
> We noticed there have exist some problems related to this.I think
> this patch effectively resolves them.

Please add new test cases for these problems in the MPTCP selftests: to
better understand what is being fixed, and to avoid regressions later.

> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/498
> Signed-off-by: Gang Yan <yangang@kylinos.cn>
> ---
>  net/mptcp/protocol.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 21bc3586c33e..f99dddca859d 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2569,6 +2569,10 @@ static void __mptcp_close_subflow(struct sock *sk)
>  			continue;
>  
>  		mptcp_close_ssk(sk, ssk, subflow);
> +
> +		if (READ_ONCE(subflow->remote_id) &&
> +		    --msk->pm.add_addr_accepted < mptcp_pm_get_add_addr_accept_max(msk))
> +			WRITE_ONCE(msk->pm.accept_addr, true);

Mmh, I don't think it can be that simple: potentially, an accepted
ADD_ADDR can trigger multiple subflows (i.e. when the fullmesh flag is
used). In this case, the counter has been incremented once, not once for
each created subflow. So before decrementing the counter, it should then
be needed to check if no other subflows connected to the same remote ID
are still alive.

I think it is better not to decrement this counter in "unusual
situations" -- the situation before this patch -- than wrongly
decrementing it, and ended up with an underflow.

Another thing is that subflows might have not been created upon the
reception of an ADD_ADDR: typically if you take the view of a server,
the subflows have been initiated by the client, and not because the
server got an ADD_ADDR. If I'm not mistaken, the counter would be
decremented here as well. We could restrict this by checking
"subflow->request_join" I suppose. Still, I'm wondering if that's
covering all cases, and if we should not track ADD_ADDR that are received:

  https://github.com/multipath-tcp/mptcp_net-next/issues/496

(which is more complex)

Also, because this counter is specific to the in-kernel PM, I think it
would be cleaner f its manipulation is done in pm_netlink.c.

pw-bot: cr

Cheers,
Matt
diff mbox series

Patch

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 21bc3586c33e..f99dddca859d 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2569,6 +2569,10 @@  static void __mptcp_close_subflow(struct sock *sk)
 			continue;
 
 		mptcp_close_ssk(sk, ssk, subflow);
+
+		if (READ_ONCE(subflow->remote_id) &&
+		    --msk->pm.add_addr_accepted < mptcp_pm_get_add_addr_accept_max(msk))
+			WRITE_ONCE(msk->pm.accept_addr, true);
 	}
 
 }