* [PATCH net-next v2] mptcp: sockopt: implement IPV6_TCLASS
@ 2026-07-13 13:51 David 'equinox' Lamparter
2026-07-13 14:53 ` MPTCP CI
2026-07-14 2:22 ` Geliang Tang
0 siblings, 2 replies; 5+ messages in thread
From: David 'equinox' Lamparter @ 2026-07-13 13:51 UTC (permalink / raw)
To: Matthieu Baerts, Mat Martineau, Geliang Tang
Cc: netdev, mptcp, David 'equinox' Lamparter
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);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] mptcp: sockopt: implement IPV6_TCLASS
2026-07-13 13:51 [PATCH net-next v2] mptcp: sockopt: implement IPV6_TCLASS David 'equinox' Lamparter
@ 2026-07-13 14:53 ` MPTCP CI
2026-07-14 2:22 ` Geliang Tang
1 sibling, 0 replies; 5+ messages in thread
From: MPTCP CI @ 2026-07-13 14:53 UTC (permalink / raw)
To: David 'equinox' Lamparter; +Cc: mptcp
Hi David,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/29256717852
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/77f3e419dc22
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1126717
If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normal
For more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] mptcp: sockopt: implement IPV6_TCLASS
2026-07-13 13:51 [PATCH net-next v2] mptcp: sockopt: implement IPV6_TCLASS David 'equinox' Lamparter
2026-07-13 14:53 ` MPTCP CI
@ 2026-07-14 2:22 ` Geliang Tang
2026-07-14 9:48 ` David 'equinox' Lamparter
1 sibling, 1 reply; 5+ messages in thread
From: Geliang Tang @ 2026-07-14 2:22 UTC (permalink / raw)
To: David 'equinox' Lamparter, Matthieu Baerts, Mat Martineau
Cc: netdev, mptcp
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);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] mptcp: sockopt: implement IPV6_TCLASS
2026-07-14 2:22 ` Geliang Tang
@ 2026-07-14 9:48 ` David 'equinox' Lamparter
2026-07-14 9:53 ` Matthieu Baerts
0 siblings, 1 reply; 5+ messages in thread
From: David 'equinox' Lamparter @ 2026-07-14 9:48 UTC (permalink / raw)
To: Geliang Tang; +Cc: Matthieu Baerts, Mat Martineau, netdev, mptcp
On Tue, Jul 14, 2026 at 10:22:12AM +0800, Geliang Tang wrote:
> 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).
>
> https://patchwork.kernel.org/project/mptcp/patch/2617b8684039574734b8622936ef126d6a7cd519.1754986785.git.tanggeliang@kylinos.cn/
Darn, I looked for patches for this & didn't find any, but I've also
been carrying this locally for a bit.
Anything I can do to help get your patch moving?
-equi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] mptcp: sockopt: implement IPV6_TCLASS
2026-07-14 9:48 ` David 'equinox' Lamparter
@ 2026-07-14 9:53 ` Matthieu Baerts
0 siblings, 0 replies; 5+ messages in thread
From: Matthieu Baerts @ 2026-07-14 9:53 UTC (permalink / raw)
To: David 'equinox' Lamparter, Geliang Tang
Cc: Mat Martineau, netdev, mptcp
Hi David, Geliang,
On 14/07/2026 11:48, David 'equinox' Lamparter wrote:
> On Tue, Jul 14, 2026 at 10:22:12AM +0800, Geliang Tang wrote:
>> 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).
>>
>> https://patchwork.kernel.org/project/mptcp/patch/2617b8684039574734b8622936ef126d6a7cd519.1754986785.git.tanggeliang@kylinos.cn/
>
> Darn, I looked for patches for this & didn't find any, but I've also
> been carrying this locally for a bit.
>
> Anything I can do to help get your patch moving?
I was hoping to do some refactoring around Geliang's code, but I didn't
manage to do that so far. I will to see if it is fine to apply Geliang's
patch (after netdevconf) and do the refactoring after.
@Geliang: do you mind rebasing this series, please? No hurry, I can also
check later on. (And sorry for the delay on that)
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-14 9:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13 13:51 [PATCH net-next v2] mptcp: sockopt: implement IPV6_TCLASS David 'equinox' Lamparter
2026-07-13 14:53 ` MPTCP CI
2026-07-14 2:22 ` Geliang Tang
2026-07-14 9:48 ` David 'equinox' Lamparter
2026-07-14 9:53 ` Matthieu Baerts
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.