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 v2 1/3] tcp: add tcp_sock_set_maxseg
Date: Tue, 29 Apr 2025 13:17:22 +0200	[thread overview]
Message-ID: <e2c67415-d1e4-4ec5-8e8a-3d2d3daf2250@kernel.org> (raw)
In-Reply-To: <e23dcab208b4fd8208c9d3f43e69dbc091455917.1745401025.git.tanggeliang@kylinos.cn>

Hi Geliang,

On 23/04/2025 11:40, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> Add a helper tcp_sock_set_maxseg() to directly set the TCP_MAXSEG sockopt
> from kernel space.

Probably clearer to add:

  This new helper will be used in the following patch.

> 
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  include/linux/tcp.h |  1 +
>  net/ipv4/tcp.c      | 24 +++++++++++++++---------
>  2 files changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/include/linux/tcp.h b/include/linux/tcp.h
> index 1669d95bb0f9..0041bc0aaee9 100644
> --- a/include/linux/tcp.h
> +++ b/include/linux/tcp.h
> @@ -623,6 +623,7 @@ void tcp_sock_set_nodelay(struct sock *sk);
>  void tcp_sock_set_quickack(struct sock *sk, int val);
>  int tcp_sock_set_syncnt(struct sock *sk, int val);
>  int tcp_sock_set_user_timeout(struct sock *sk, int val);
> +int tcp_sock_set_maxseg(struct sock *sk, int val);
>  
>  static inline bool dst_tcp_usec_ts(const struct dst_entry *dst)
>  {
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 4516f93f6cd2..402f4a9b3fd1 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -3725,6 +3725,20 @@ int tcp_set_window_clamp(struct sock *sk, int val)
>  	return 0;
>  }
>  
> +int tcp_sock_set_maxseg(struct sock *sk, int val)
> +{
> +	/* Values greater than interface MTU won't take effect. However
> +	 * at the point when this call is done we typically don't yet
> +	 * know which interface is going to be used
> +	 */
> +	if (val && (val < TCP_MIN_MSS || val > MAX_TCP_WINDOW))
> +		return -EINVAL;
> +
> +	tcp_sk(sk)->rx_opt.user_mss = val;
> +	return 0;
> +}
> +EXPORT_SYMBOL(tcp_sock_set_maxseg);

This export is not needed: it is only needed when used from a module.

The rest looks OK to me:

Acked-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

> +
>  /*
>   *	Socket option code for TCP.
>   */
> @@ -3857,15 +3871,7 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname,
>  
>  	switch (optname) {
>  	case TCP_MAXSEG:
> -		/* Values greater than interface MTU won't take effect. However
> -		 * at the point when this call is done we typically don't yet
> -		 * know which interface is going to be used
> -		 */
> -		if (val && (val < TCP_MIN_MSS || val > MAX_TCP_WINDOW)) {
> -			err = -EINVAL;
> -			break;
> -		}
> -		tp->rx_opt.user_mss = val;
> +		tcp_sock_set_maxseg(sk, val);
>  		break;
>  
>  	case TCP_NODELAY:

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


  reply	other threads:[~2025-04-29 11:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-23  9:40 [PATCH mptcp-next v2 0/3] Add TCP_MAXSEG socket option support Geliang Tang
2025-04-23  9:40 ` [PATCH mptcp-next v2 1/3] tcp: add tcp_sock_set_maxseg Geliang Tang
2025-04-29 11:17   ` Matthieu Baerts [this message]
2025-04-23  9:40 ` [PATCH mptcp-next v2 2/3] mptcp: add TCP_MAXSEG sockopt support Geliang Tang
2025-04-29 11:17   ` Matthieu Baerts
2025-04-23  9:40 ` [PATCH mptcp-next v2 3/3] selftests: mptcp: sockopt: add TCP_MAXSEG sockopt tests Geliang Tang
2025-04-29 11:17   ` Matthieu Baerts
2025-04-29 11:11 ` [PATCH mptcp-next v2 0/3] Add TCP_MAXSEG socket option support Matthieu Baerts

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=e2c67415-d1e4-4ec5-8e8a-3d2d3daf2250@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