[PATCH mptcp-next v4 07/10] mptcp: copy the subflow's tos/tclass to the msk on accept
Geliang Tang <[email protected]> Thu, 30 Jul 2026 10:54:00 +0800
| Newsgroups | dev.linux.lists.mptcp |
|---|---|
| Message-ID | <eb35da8169f0ff292b1f4c023a9e6c47a44ad77c.1785378180.git.tanggeliang@kylinos.cn> |
From: Geliang Tang <[email protected]> When a new MPTCP socket is accepted, copy the tos (and rcv_tos for IPv4) or tclass (and rcv_flowinfo for IPv6) from the first subflow to the newly-created msk. This mirrors what plain TCP does in tcp_v4_syn_recv_sock() and tcp_v6_syn_recv_sock(), where these values are copied from the incoming skb to the accepted socket. Without this, MP_JOIN subflows created later would inherit tos/tclass=0 from the msk and lose the peer's reflected value, causing inconsistent traffic class behavior. Signed-off-by: Geliang Tang <[email protected]> --- net/mptcp/protocol.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 90dc894cb976..1544a4e411b5 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3706,6 +3706,22 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk, #endif mptcp_copy_ip_options(nsk, sk); + if (ssk->sk_family == AF_INET) { + inet_sk(nsk)->rcv_tos = inet_sk(ssk)->rcv_tos; + __ip_sock_set_tos(nsk, inet_sk(ssk)->tos); + } +#if IS_ENABLED(CONFIG_MPTCP_IPV6) + else if (ssk->sk_family == AF_INET6 && + ipv6_addr_v4mapped(&ssk->sk_v6_daddr)) { + inet_sk(nsk)->rcv_tos = inet_sk(ssk)->rcv_tos; + __ip_sock_set_tos(nsk, inet_sk(ssk)->tos); + } + else if (ssk->sk_family == AF_INET6) { + inet6_sk(nsk)->rcv_flowinfo = inet6_sk(ssk)->rcv_flowinfo; + __ip6_sock_set_tclass(nsk, inet6_sk(ssk)->tclass); + } +#endif + msk = mptcp_sk(nsk); WRITE_ONCE(msk->local_key, subflow_req->local_key); WRITE_ONCE(msk->token, subflow_req->token); -- 2.53.0