All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geliang Tang <geliang@kernel.org>
To: Matthieu Baerts <matttbe@kernel.org>, mptcp@lists.linux.dev
Cc: Geliang Tang <tanggeliang@kylinos.cn>
Subject: Re: [PATCH mptcp-next v2 2/2] mptcp: setsockopt support for TCP_MD5SIG
Date: Fri, 01 Aug 2025 11:00:14 +0800	[thread overview]
Message-ID: <34edc365d26db1b51671f34d85e9ca2d7bd72dde.camel@kernel.org> (raw)
In-Reply-To: <9f6237d3-a8eb-4dce-bea1-baefbd6ef59c@kernel.org>

Hi Matt,

On Thu, 2025-07-31 at 11:59 +0200, Matthieu Baerts wrote:
> Hi Geliang,
> 
> Thank you for the new version.
> 
> On 31/07/2025 09:27, Geliang Tang wrote:
> > From: Geliang Tang <tanggeliang@kylinos.cn>
> > 
> > This adds setsockopt support for TCP_MD5SIG and TCP_MD5SIG_EXT
> > options.
> > The implementation:
> > - Allows setting these options (getsockopt remains unsupported)
> > - Applies them only to the first subflow
> > - Forces fallback to TCP (since MD5 isn't compatible with MPTCP)
> > 
> > Setting these options triggers fallback to TCP to maintain MD5
> > compatibility.
> > 
> > Note that TCP_MD5SIG and TCP_MD5SIG_EXT are unsupported for TCP
> > too.
> > 
> > Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/575
> > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> > ---
> >  net/mptcp/sockopt.c | 12 ++++++++++--
> >  1 file changed, 10 insertions(+), 2 deletions(-)
> > 
> > diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
> > index b264185b810d..3ffdeca694be 100644
> > --- a/net/mptcp/sockopt.c
> > +++ b/net/mptcp/sockopt.c
> > @@ -13,6 +13,7 @@
> >  #include <net/tcp.h>
> >  #include <net/mptcp.h>
> >  #include "protocol.h"
> > +#include "mib.h"
> >  
> >  #define MIN_INFO_OPTLEN_SIZE		16
> >  #define MIN_FULL_INFO_OPTLEN_SIZE	40
> > @@ -567,11 +568,12 @@ static bool mptcp_supported_sockopt(int
> > level, int optname)
> >  		case TCP_FASTOPEN_CONNECT:
> >  		case TCP_FASTOPEN_KEY:
> >  		case TCP_FASTOPEN_NO_COOKIE:
> > +		/* MD5 will force a fallback to TCP: OK to set
> > while not connected */
> > +		case TCP_MD5SIG:
> > +		case TCP_MD5SIG_EXT:
> >  			return true;
> >  		}
> >  
> > -		/* TCP_MD5SIG, TCP_MD5SIG_EXT are not supported,
> > MD5 is not compatible with MPTCP */
> > -
> >  		/* TCP_REPAIR, TCP_REPAIR_QUEUE, TCP_QUEUE_SEQ,
> > TCP_REPAIR_OPTIONS,
> >  		 * TCP_REPAIR_WINDOW are not supported, better
> > avoid this mess
> >  		 */
> > @@ -830,6 +832,12 @@ static int mptcp_setsockopt_sol_tcp(struct
> > mptcp_sock *msk, int optname,
> >  		/* See tcp.c: TCP_DEFER_ACCEPT does not fail */
> >  		mptcp_setsockopt_first_sf_only(msk, SOL_TCP,
> > optname, optval, optlen);
> >  		return 0;
> > +#ifdef CONFIG_TCP_MD5SIG
> > +	case TCP_MD5SIG:
> > +	case TCP_MD5SIG_EXT:
> > +		__mptcp_try_fallback(msk,
> > MPTCP_MIB_MD5SIGFALLBACK);
> 
> I don't think that's a good idea to do just that: here, you will do a
> fallback even if the options are not correct. Please this helper can
> return false if a fallback is not possible, and a reset will be
> needed.

Yes, here the return value of __mptcp_try_fallback() needs to be
checked:

 if (!__mptcp_try_fallback(msk, MPTCP_MIB_MD5SIGFALLBACK))
	 return 0;

> 
> I think it would be easier to simply limit the use of this option for
> listened and closed state: 

Yes, the state of sk needs to be checked too:

 if (!((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) ||
     !__mptcp_try_fallback(msk, MPTCP_MIB_MD5SIGFALLBACK))
 	return 0;

Do you think this will work?

> a fallback will be done in mptcp_connect()
> and subflow_check_req().

When running the selftests of patch 3 in v1, no fallback is done in
mptcp_connect() and subflow_check_req(). Since both
rcu_access_pointer(tcp_sk(ssk)->md5sig_info) and
rcu_access_pointer(tcp_sk(sk_listener)->md5sig_info) are NULL. So we do
need to fallback in mptcp_setsockopt_sol_tcp().

Thanks,
-Geliang

> 
> If I'm not mistaken, mptcp_setsockopt_first_sf_only() will limit to
> the
> first subflow, before the establishment of the connection
> (__mptcp_nmpc_sk() is explicitly checking the state), no?
> 
> Then all you require is to add the two 'case', no? If yes, please add
> a
> Fixes tag:
> 
> Fixes: d9e4c1291810 ("mptcp: only admit explicitly supported
> sockopt")
> 
> And add something like this in the commit message:
> 
>   Supporting TCP_MD5 socket option is required when MPTCP is used by
>   default when creating a socket, to keep the same behaviour as with
>   TCP. TCP_MD5 is not compatible with MPTCP, and it will cause a
>   fallback to TCP at the connection request, if MPTCP was requested.
>   This then fixes a "regression" compared to TCP.
> 
> 
> One last thing, please also send the new packetdrill test on GitHub
> when
> sending a next version.
> 
> Cheers,
> Matt

  reply	other threads:[~2025-08-01  3:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-31  7:27 [PATCH mptcp-next v2 0/2] mptcp: TCP_MD5SIG support Geliang Tang
2025-07-31  7:27 ` [PATCH mptcp-next v2 1/2] mptcp: Handle TCP_MAXSEG getsockopt in common case Geliang Tang
2025-07-31  7:27 ` [PATCH mptcp-next v2 2/2] mptcp: setsockopt support for TCP_MD5SIG Geliang Tang
2025-07-31  9:59   ` Matthieu Baerts
2025-08-01  3:00     ` Geliang Tang [this message]
2025-07-31 19:18   ` Christoph Paasch
2025-08-01  3:01     ` Geliang Tang
2025-07-31  9:23 ` [PATCH mptcp-next v2 0/2] mptcp: TCP_MD5SIG support MPTCP CI

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34edc365d26db1b51671f34d85e9ca2d7bd72dde.camel@kernel.org \
    --to=geliang@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=tanggeliang@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.