[PATCH mptcp-next v6 6/6] mptcp: copy subflow's tos/tclass to msk on accept
Geliang Tang <[email protected]>
| Newsgroups | dev.linux.lists.mptcp |
|---|---|
| Message-ID | <0ae5cedc96502c3a89a573b386ce21c017c9bd6c.1786938892.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 c2762d74f29d..f18af725e8e2 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3756,6 +3756,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); + inet6_sk(nsk)->rcv_flowinfo = 0; + } 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