Netdev List
 help / color / mirror / Atom feed
From: Geliang Tang <geliang@kernel.org>
To: David 'equinox' Lamparter <equinox@diac24.net>,
	Matthieu Baerts <matttbe@kernel.org>,
	Mat Martineau <martineau@kernel.org>
Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev
Subject: Re: [PATCH net-next v2] mptcp: sockopt: implement IPV6_TCLASS
Date: Tue, 14 Jul 2026 10:22:12 +0800	[thread overview]
Message-ID: <c3b017e1c96cdafce15012e737389108d7cbf8f6.camel@kernel.org> (raw)
In-Reply-To: <20260713135551.569365-1-equinox@diac24.net>

Hi David,

Thanks for your patch. However there is already a version under review
on the MPTCP mailing list that adds IPV6_TCLASS [1] (as well as IP_TTL
and IPV6_UNICAST_HOPS).

Thanks,
-Geliang

https://patchwork.kernel.org/project/mptcp/patch/2617b8684039574734b8622936ef126d6a7cd519.1754986785.git.tanggeliang@kylinos.cn/

On Mon, 2026-07-13 at 15:51 +0200, David 'equinox' Lamparter wrote:
> The IPV6_TCLASS setsockopt just needs to be forwarded to the
> individual
> TCP sockets, like IP_TOS is already handled for IPv4.  The code here
> is
> pretty much identical, except there's no helper for IPv6 like IPv4's
> __ip_sock_set_tos().
> 
> Coincidentally, ssh uses this sockopt and prints an error in the
> middle
> of your ongoing SSH session when it doesn't work (very annoying when
> doing SCP/SFTP on a multiplexed session.)
> 
> Signed-off-by: David 'equinox' Lamparter <equinox@diac24.net>
> Cc: Matthieu Baerts <matttbe@kernel.org>
> Cc: Mat Martineau <martineau@kernel.org>
> Cc: Geliang Tang <geliang@kernel.org>
> ---
> [v2: added guard for CONFIG_IPV6=n.  I could also add a stub for
> ipv6_setsockopt() in include/net/ipv6.h, that might be prettier?]
> ---
>  net/mptcp/sockopt.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
> index fcf6feb2a9eb..1b83bba0b58e 100644
> --- a/net/mptcp/sockopt.c
> +++ b/net/mptcp/sockopt.c
> @@ -394,6 +394,39 @@ static int mptcp_setsockopt_sol_socket(struct
> mptcp_sock *msk, int optname,
>  	return -EOPNOTSUPP;
>  }
>  
> +static int mptcp_setsockopt_v6_set_tclass(struct mptcp_sock *msk,
> int optname,
> +					  sockptr_t optval, unsigned
> int optlen)
> +{
> +#if !IS_ENABLED(CONFIG_IPV6)
> +	return -EOPNOTSUPP;
> +#else
> +	struct mptcp_subflow_context *subflow;
> +	struct sock *sk = (struct sock *)msk;
> +	int err, val;
> +
> +	err = ipv6_setsockopt(sk, SOL_IPV6, optname, optval,
> optlen);
> +
> +	if (err != 0)
> +		return err;
> +
> +	lock_sock(sk);
> +	sockopt_seq_inc(msk);
> +	val = READ_ONCE(inet6_sk(sk)->tclass);
> +	mptcp_for_each_subflow(msk, subflow) {
> +		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
> +		bool slow;
> +
> +		slow = lock_sock_fast(ssk);
> +		inet6_sk(ssk)->tclass = val;
> +		sk_dst_reset(ssk);
> +		unlock_sock_fast(ssk, slow);
> +	}
> +	release_sock(sk);
> +
> +	return 0;
> +#endif
> +}
> +
>  static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname,
>  			       sockptr_t optval, unsigned int
> optlen)
>  {
> @@ -436,6 +469,8 @@ static int mptcp_setsockopt_v6(struct mptcp_sock
> *msk, int optname,
>  
>  		release_sock(sk);
>  		break;
> +	case IPV6_TCLASS:
> +		return mptcp_setsockopt_v6_set_tclass(msk, optname,
> optval, optlen);
>  	}
>  
>  	return ret;
> @@ -1485,6 +1520,9 @@ static int mptcp_getsockopt_v6(struct
> mptcp_sock *msk, int optname,
>  	struct sock *sk = (void *)msk;
>  
>  	switch (optname) {
> +	case IPV6_TCLASS:
> +		return mptcp_put_int_option(msk, optval, optlen,
> +					    READ_ONCE(inet6_sk(sk)-
> >tclass));
>  	case IPV6_V6ONLY:
>  		return mptcp_put_int_option(msk, optval, optlen,
>  					    sk->sk_ipv6only);

  reply	other threads:[~2026-07-14  2:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 13:51 [PATCH net-next v2] mptcp: sockopt: implement IPV6_TCLASS David 'equinox' Lamparter
2026-07-14  2:22 ` Geliang Tang [this message]
2026-07-14  9:48   ` David 'equinox' Lamparter
2026-07-14  9:53     ` 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=c3b017e1c96cdafce15012e737389108d7cbf8f6.camel@kernel.org \
    --to=geliang@kernel.org \
    --cc=equinox@diac24.net \
    --cc=martineau@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    /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