MPTCP Linux Development
 help / color / mirror / Atom feed
From: Matthieu Baerts <matttbe@kernel.org>
To: Geliang Tang <geliang@kernel.org>, mptcp@lists.linux.dev
Cc: Geliang Tang <tanggeliang@kylinos.cn>
Subject: Re: [PATCH mptcp-next v1 1/2] mptcp: add TCP_MAXSEG sockopt support
Date: Tue, 22 Apr 2025 13:18:34 +0200	[thread overview]
Message-ID: <4f396f53-aed8-4d59-a9b7-56827e1f0139@kernel.org> (raw)
In-Reply-To: <73d0d8594eaee83d2902ca23c3972ec5e6d628f4.1745314165.git.tanggeliang@kylinos.cn>

Hi Geliang,

On 22/04/2025 11:30, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> The TCP_MAXSEG socket option is currently not supported by MPTCP, mainly
> because it has never been requested before. But there are still valid
> use-cases, e.g. with HAProxy.
> 
> This patch adds its support in MPTCP by propagating the value to all
> subflows.

Thank you for looking at that.

> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/515
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  net/mptcp/sockopt.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
> index 3caa0a9d3b38..3014713b037c 100644
> --- a/net/mptcp/sockopt.c
> +++ b/net/mptcp/sockopt.c
> @@ -798,6 +798,24 @@ static int mptcp_setsockopt_first_sf_only(struct mptcp_sock *msk, int level, int
>  	return ret;
>  }
>  
> +static int mptcp_setsockopt_sol_tcp_maxseg(struct mptcp_sock *msk,
> +					   sockptr_t optval,
> +					   unsigned int optlen)

Might be good to have a generic helper, similar to
mptcp_setsockopt_first_sf_only(), no?

  mptcp_setsockopt_all_subflows()

> +{
> +	struct mptcp_subflow_context *subflow;
> +
> +	mptcp_for_each_subflow(msk, subflow) {

If there is no subflows (listening sockets?), you might need to call
mptcp_setsockopt_first_sf_only(), no?

> +		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
> +		int ret;
> +
> +		ret = tcp_setsockopt(ssk, SOL_TCP, TCP_MAXSEG, optval, optlen);

No need to lock around this call?

> +		if (ret)
> +			return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname,
>  				    sockptr_t optval, unsigned int optlen)
>  {
> @@ -819,6 +837,8 @@ static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname,
>  	case TCP_FASTOPEN_NO_COOKIE:
>  		return mptcp_setsockopt_first_sf_only(msk, SOL_TCP, optname,
>  						      optval, optlen);
> +	case TCP_MAXSEG:
> +		return mptcp_setsockopt_sol_tcp_maxseg(msk, optval, optlen);
>  	}
>  
>  	ret = mptcp_get_int_option(msk, optval, optlen, &val);
> @@ -1368,6 +1388,13 @@ static int mptcp_put_int_option(struct mptcp_sock *msk, char __user *optval,
>  	return 0;
>  }
>  
> +static int mptcp_getsockopt_sol_tcp_maxseg(struct mptcp_sock *msk,
> +					   char __user *optval,
> +					   int __user *optlen)
> +{
> +	return tcp_getsockopt(msk->first, SOL_TCP, TCP_MAXSEG, optval, optlen);

Same here: no need to lock? Also, msk->first can be NULL for listening
sockets, no?

Anyway, I think it is best not to change the way the socket options are
handled today: the socket option is propagated to existing and future
subflows. Look how "msk->keepalive_intvl" is handled in sockopt.c for
example.

- setsockopt: store the value (in case of success) in the msk.
- getsockopt: return this value (mptcp_put_int_option())

WDYT?

> +}
> +
>  static int mptcp_getsockopt_sol_tcp(struct mptcp_sock *msk, int optname,
>  				    char __user *optval, int __user *optlen)
>  {
> @@ -1407,6 +1434,8 @@ static int mptcp_getsockopt_sol_tcp(struct mptcp_sock *msk, int optname,
>  		return mptcp_put_int_option(msk, optval, optlen, msk->notsent_lowat);
>  	case TCP_IS_MPTCP:
>  		return mptcp_put_int_option(msk, optval, optlen, 1);
> +	case TCP_MAXSEG:
> +		return mptcp_getsockopt_sol_tcp_maxseg(msk, optval, optlen);
>  	}
>  	return -EOPNOTSUPP;
>  }

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


  reply	other threads:[~2025-04-22 11:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-22  9:30 [PATCH mptcp-next v1 0/2] Add TCP_MAXSEG socket option support Geliang Tang
2025-04-22  9:30 ` [PATCH mptcp-next v1 1/2] mptcp: add TCP_MAXSEG sockopt support Geliang Tang
2025-04-22 11:18   ` Matthieu Baerts [this message]
2025-04-22  9:30 ` [PATCH mptcp-next v1 2/2] selftests: mptcp: sockopt: add TCP_MAXSEG sockopt tests Geliang Tang
2025-04-22 11:20   ` Matthieu Baerts
2025-04-23  9:46     ` Geliang Tang
2025-04-22 10:52 ` [PATCH mptcp-next v1 0/2] Add TCP_MAXSEG socket option 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=4f396f53-aed8-4d59-a9b7-56827e1f0139@kernel.org \
    --to=matttbe@kernel.org \
    --cc=geliang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox