MPTCP Linux Development
 help / color / mirror / Atom feed
* [MPTCP] Re: [PATCH net 2/2] mptcp: better msk-level shutdown.
@ 2021-01-13 10:21 Eric Dumazet
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2021-01-13 10:21 UTC (permalink / raw)
  To: mptcp 

[-- Attachment #1: Type: text/plain, Size: 1709 bytes --]



On 1/12/21 6:25 PM, Paolo Abeni wrote:
> Instead of re-implementing most of inet_shutdown, re-use
> such helper, and implement the MPTCP-specific bits at the
> 'proto' level.
> 
> The msk-level disconnect() can now be invoked, lets provide a
> suitable implementation.
> 
> As a side effect, this fixes bad state management for listener
> sockets. The latter could lead to division by 0 oops since
> commit ea4ca586b16f ("mptcp: refine MPTCP-level ack scheduling").
> 
> Fixes: 43b54c6ee382 ("mptcp: Use full MPTCP-level disconnect state machine")
> Fixes: ea4ca586b16f ("mptcp: refine MPTCP-level ack scheduling")
> Signed-off-by: Paolo Abeni <pabeni(a)redhat.com>
> ---
>  net/mptcp/protocol.c | 62 ++++++++++++--------------------------------
>  1 file changed, 17 insertions(+), 45 deletions(-)
> 
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 2ff8c7caf74f..81faeff8f3bb 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2642,11 +2642,12 @@ static void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk)
>  
>  static int mptcp_disconnect(struct sock *sk, int flags)
>  {
> -	/* Should never be called.
> -	 * inet_stream_connect() calls ->disconnect, but that
> -	 * refers to the subflow socket, not the mptcp one.
> -	 */
> -	WARN_ON_ONCE(1);
> +	struct mptcp_subflow_context *subflow;
> +	struct mptcp_sock *msk = mptcp_sk(sk);
> +
> +	__mptcp_flush_join_list(msk);
> +	mptcp_for_each_subflow(msk, subflow)
> +		tcp_disconnect(mptcp_subflow_tcp_sock(subflow), flags);

Ouch.

tcp_disconnect() is supposed to be called with socket lock being held.

Really, CONFIG_LOCKDEP=y should have warned you :/


^ permalink raw reply	[flat|nested] 4+ messages in thread
* [MPTCP] Re: [PATCH net 2/2] mptcp: better msk-level shutdown.
@ 2021-01-13 15:26 Paolo Abeni
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Abeni @ 2021-01-13 15:26 UTC (permalink / raw)
  To: mptcp 

[-- Attachment #1: Type: text/plain, Size: 2252 bytes --]

On Wed, 2021-01-13 at 11:26 +0100, Eric Dumazet wrote:
> 
> On 1/13/21 11:21 AM, Eric Dumazet wrote:
> > 
> > On 1/12/21 6:25 PM, Paolo Abeni wrote:
> > > Instead of re-implementing most of inet_shutdown, re-use
> > > such helper, and implement the MPTCP-specific bits at the
> > > 'proto' level.
> > > 
> > > The msk-level disconnect() can now be invoked, lets provide a
> > > suitable implementation.
> > > 
> > > As a side effect, this fixes bad state management for listener
> > > sockets. The latter could lead to division by 0 oops since
> > > commit ea4ca586b16f ("mptcp: refine MPTCP-level ack scheduling").
> > > 
> > > Fixes: 43b54c6ee382 ("mptcp: Use full MPTCP-level disconnect state machine")
> > > Fixes: ea4ca586b16f ("mptcp: refine MPTCP-level ack scheduling")
> > > Signed-off-by: Paolo Abeni <pabeni(a)redhat.com>
> > > ---
> > >  net/mptcp/protocol.c | 62 ++++++++++++--------------------------------
> > >  1 file changed, 17 insertions(+), 45 deletions(-)
> > > 
> > > diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> > > index 2ff8c7caf74f..81faeff8f3bb 100644
> > > --- a/net/mptcp/protocol.c
> > > +++ b/net/mptcp/protocol.c
> > > @@ -2642,11 +2642,12 @@ static void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk)
> > >  
> > >  static int mptcp_disconnect(struct sock *sk, int flags)
> > >  {
> > > -	/* Should never be called.
> > > -	 * inet_stream_connect() calls ->disconnect, but that
> > > -	 * refers to the subflow socket, not the mptcp one.
> > > -	 */
> > > -	WARN_ON_ONCE(1);
> > > +	struct mptcp_subflow_context *subflow;
> > > +	struct mptcp_sock *msk = mptcp_sk(sk);
> > > +
> > > +	__mptcp_flush_join_list(msk);
> > > +	mptcp_for_each_subflow(msk, subflow)
> > > +		tcp_disconnect(mptcp_subflow_tcp_sock(subflow), flags);
> > 
> > Ouch.
> > 
> > tcp_disconnect() is supposed to be called with socket lock being held.
> > 
> > Really, CONFIG_LOCKDEP=y should have warned you :/
> 
> Or maybe CONFIG_PROVE_RCU=y is needed to catch the bug.

Thank you for catching this!

Yep, CONFIG_PROVE_RCU=y triggers a 'suspicious RCU usage' warning. I
should really enable 'panic_on_warn' in batch tests.

I'll send a patch.

Thanks,

Paolo

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [MPTCP] Re: [PATCH net 2/2] mptcp: better msk-level shutdown.
@ 2021-01-13 10:26 Eric Dumazet
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2021-01-13 10:26 UTC (permalink / raw)
  To: mptcp 

[-- Attachment #1: Type: text/plain, Size: 1865 bytes --]



On 1/13/21 11:21 AM, Eric Dumazet wrote:
> 
> 
> On 1/12/21 6:25 PM, Paolo Abeni wrote:
>> Instead of re-implementing most of inet_shutdown, re-use
>> such helper, and implement the MPTCP-specific bits at the
>> 'proto' level.
>>
>> The msk-level disconnect() can now be invoked, lets provide a
>> suitable implementation.
>>
>> As a side effect, this fixes bad state management for listener
>> sockets. The latter could lead to division by 0 oops since
>> commit ea4ca586b16f ("mptcp: refine MPTCP-level ack scheduling").
>>
>> Fixes: 43b54c6ee382 ("mptcp: Use full MPTCP-level disconnect state machine")
>> Fixes: ea4ca586b16f ("mptcp: refine MPTCP-level ack scheduling")
>> Signed-off-by: Paolo Abeni <pabeni(a)redhat.com>
>> ---
>>  net/mptcp/protocol.c | 62 ++++++++++++--------------------------------
>>  1 file changed, 17 insertions(+), 45 deletions(-)
>>
>> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
>> index 2ff8c7caf74f..81faeff8f3bb 100644
>> --- a/net/mptcp/protocol.c
>> +++ b/net/mptcp/protocol.c
>> @@ -2642,11 +2642,12 @@ static void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk)
>>  
>>  static int mptcp_disconnect(struct sock *sk, int flags)
>>  {
>> -	/* Should never be called.
>> -	 * inet_stream_connect() calls ->disconnect, but that
>> -	 * refers to the subflow socket, not the mptcp one.
>> -	 */
>> -	WARN_ON_ONCE(1);
>> +	struct mptcp_subflow_context *subflow;
>> +	struct mptcp_sock *msk = mptcp_sk(sk);
>> +
>> +	__mptcp_flush_join_list(msk);
>> +	mptcp_for_each_subflow(msk, subflow)
>> +		tcp_disconnect(mptcp_subflow_tcp_sock(subflow), flags);
> 
> Ouch.
> 
> tcp_disconnect() is supposed to be called with socket lock being held.
> 
> Really, CONFIG_LOCKDEP=y should have warned you :/

Or maybe CONFIG_PROVE_RCU=y is needed to catch the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread
* [MPTCP] Re: [PATCH net 2/2] mptcp: better msk-level shutdown.
@ 2021-01-12 21:38 Mat Martineau
  0 siblings, 0 replies; 4+ messages in thread
From: Mat Martineau @ 2021-01-12 21:38 UTC (permalink / raw)
  To: mptcp 

[-- Attachment #1: Type: text/plain, Size: 913 bytes --]

On Tue, 12 Jan 2021, Paolo Abeni wrote:

> Instead of re-implementing most of inet_shutdown, re-use
> such helper, and implement the MPTCP-specific bits at the
> 'proto' level.
>
> The msk-level disconnect() can now be invoked, lets provide a
> suitable implementation.
>
> As a side effect, this fixes bad state management for listener
> sockets. The latter could lead to division by 0 oops since
> commit ea4ca586b16f ("mptcp: refine MPTCP-level ack scheduling").
>
> Fixes: 43b54c6ee382 ("mptcp: Use full MPTCP-level disconnect state machine")
> Fixes: ea4ca586b16f ("mptcp: refine MPTCP-level ack scheduling")
> Signed-off-by: Paolo Abeni <pabeni(a)redhat.com>
> ---
> net/mptcp/protocol.c | 62 ++++++++++++--------------------------------
> 1 file changed, 17 insertions(+), 45 deletions(-)
>

Reviewed-by: Mat Martineau <mathew.j.martineau(a)linux.intel.com>

--
Mat Martineau
Intel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-13 15:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-13 10:21 [MPTCP] Re: [PATCH net 2/2] mptcp: better msk-level shutdown Eric Dumazet
  -- strict thread matches above, loose matches on Subject: below --
2021-01-13 15:26 Paolo Abeni
2021-01-13 10:26 Eric Dumazet
2021-01-12 21:38 Mat Martineau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox