MPTCP Linux Development
 help / color / mirror / Atom feed
From: gang.yan@linux.dev
To: "Geliang Tang" <geliang@kernel.org>, mptcp@lists.linux.dev
Cc: "Gang Yan" <yangang@kylinos.cn>
Subject: Re: [PATCH mptcp-next v3 1/7] mptcp: drop unused @max arg of __mptcp_setsockopt_set_val
Date: Tue, 28 Jul 2026 01:54:18 +0000	[thread overview]
Message-ID: <b1a6b022b19d0f127964501acb1a7f1a3e9071d4@linux.dev> (raw)
In-Reply-To: <13793643d394a86e9f16ca02c1f18cc75adf7a28.camel@kernel.org>

July 27, 2026 at 2:37 PM, "Geliang Tang" <geliang@kernel.org mailto:geliang@kernel.org?to=%22Geliang%20Tang%22%20%3Cgeliang%40kernel.org%3E > wrote:


> 
> On Mon, 2026-07-27 at 10:28 +0800, Gang Yan wrote:
> 
> > 
> > From: Gang Yan <yangang@kylinos.cn>
> >  
> >  The @max argument is never read in the function body. Remove it and
> >  the
> >  MAX_TCP_KEEP* values passed by the TCP_KEEPIDLE/INTVL/KEEPCNT
> >  callers.
> > 
> No, we shouldn't drop this "max" argument. Instead, we need to add some
> code to check the "val" argument against the "max" argument in
> __mptcp_setsockopt_set_val(), something like:
> 
>  if (val < 1 || val > max) 
>  return -EINVAL;
> 

Hi Geliang

Thank you for the review and the suggestion to add a range check inside __mptcp_setsockopt_set_val().

But, I noticed that the underlying TCP helper functions already perform their
own parameter validation internally. 

Given that these helpers already enforce the same bounds, I would like to ask
for your opinion: Is it still necessary to add an extra check in the MPTCP layer?

Thanks
Gang


> > 
> > Signed-off-by: Gang Yan <yangang@kylinos.cn>
> >  ---
> >   net/mptcp/sockopt.c | 11 ++++-------
> >   1 file changed, 4 insertions(+), 7 deletions(-)
> >  
> >  diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
> >  index fcf6feb2a9eb..9c4faa0d82ef 100644
> >  --- a/net/mptcp/sockopt.c
> >  +++ b/net/mptcp/sockopt.c
> >  @@ -632,7 +632,7 @@ static int
> >  mptcp_setsockopt_sol_tcp_congestion(struct mptcp_sock *msk, sockptr_t
> >    return ret;
> >   }
> >   
> >  -static int __mptcp_setsockopt_set_val(struct mptcp_sock *msk, int
> >  max,
> >  +static int __mptcp_setsockopt_set_val(struct mptcp_sock *msk,
> >          int (*set_val)(struct sock *,
> >  int),
> >          int *msk_val, int val)
> >   {
> >  @@ -876,18 +876,15 @@ static int mptcp_setsockopt_sol_tcp(struct
> >  mptcp_sock *msk, int optname,
> >    ret = __mptcp_setsockopt_sol_tcp_nodelay(msk, val);
> >    break;
> >    case TCP_KEEPIDLE:
> >  - ret = __mptcp_setsockopt_set_val(msk,
> >  MAX_TCP_KEEPIDLE,
> >  - 
> >  &tcp_sock_set_keepidle_locked,
> >  + ret = __mptcp_setsockopt_set_val(msk,
> >  &tcp_sock_set_keepidle_locked,
> >    &msk-
> > keepalive_idle, val);
> >    break;
> >    case TCP_KEEPINTVL:
> >  - ret = __mptcp_setsockopt_set_val(msk,
> >  MAX_TCP_KEEPINTVL,
> >  - 
> >  &tcp_sock_set_keepintvl,
> >  + ret = __mptcp_setsockopt_set_val(msk,
> >  &tcp_sock_set_keepintvl,
> >    &msk-
> > keepalive_intvl, val);
> >    break;
> >    case TCP_KEEPCNT:
> >  - ret = __mptcp_setsockopt_set_val(msk,
> >  MAX_TCP_KEEPCNT,
> >  - 
> >  &tcp_sock_set_keepcnt,
> >  + ret = __mptcp_setsockopt_set_val(msk,
> >  &tcp_sock_set_keepcnt,
> >    &msk-
> > keepalive_cnt,
> >    val);
> >    break;
> >
>

  reply	other threads:[~2026-07-28  1:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27  2:28 [PATCH mptcp-next v3 0/7] mptcp: add bpf_setsockopt support Gang Yan
2026-07-27  2:28 ` [PATCH mptcp-next v3 1/7] mptcp: drop unused @max arg of __mptcp_setsockopt_set_val Gang Yan
2026-07-27  6:37   ` Geliang Tang
2026-07-28  1:54     ` gang.yan [this message]
2026-07-27  2:28 ` [PATCH mptcp-next v3 2/7] mptcp: take TCP_MAXSEG handling into __mptcp_setsockopt_set_val Gang Yan
2026-07-27  6:39   ` Geliang Tang
2026-07-27  2:28 ` [PATCH mptcp-next v3 3/7] mptcp: use sockopt_lock/release_sock in sockopt Gang Yan
2026-07-27  2:28 ` [PATCH mptcp-next v3 4/7] mptcp: reject sockopt requiring ssks' lock in BPF context Gang Yan
2026-07-27  2:28 ` [PATCH mptcp-next v3 5/7] mptcp: enable bpf_setsockopt on the master socket Gang Yan
2026-07-27  2:28 ` [PATCH mptcp-next v3 6/7] mptcp: add TCP_CONNECT_CB sock_ops hook Gang Yan
2026-07-27  2:28 ` [PATCH mptcp-next v3 7/7] selftests: bpf: verify mptcp bpf_setsockopt from TCP_CONNECT_CB Gang Yan
2026-07-27  3:12 ` [PATCH mptcp-next v3 0/7] mptcp: add bpf_setsockopt support MPTCP CI
2026-07-27  6:04 ` Geliang Tang
2026-07-27  6:20   ` gang.yan

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=b1a6b022b19d0f127964501acb1a7f1a3e9071d4@linux.dev \
    --to=gang.yan@linux.dev \
    --cc=geliang@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=yangang@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