[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2f766fe8-374a-44ff-a912-b43190aee400@kernel.org>
Date: Thu, 23 Oct 2025 16:00:57 +0200
From: Matthieu Baerts <matttbe@...nel.org>
To: Jiayuan Chen <jiayuan.chen@...ux.dev>
Cc: Mat Martineau <martineau@...nel.org>, Geliang Tang <geliang@...nel.org>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>, Davide Caratti <dcaratti@...hat.com>,
netdev@...r.kernel.org, mptcp@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v1] mptcp: fix incorrect IPv4/IPv6 check
Hi Jiayuan,
Thank you for your reply (and sorry for the delay, I was unavailable for
a few days).
On 15/10/2025 16:16, Jiayuan Chen wrote:
> October 14, 2025 at 23:27, "Matthieu Baerts" <matttbe@...nel.org> wrote:
>> On 14/10/2025 14:26, Jiayuan Chen wrote:
>>
>>>
>>> When MPTCP falls back to normal TCP, it needs to reset proto_ops. However,
>>> for sockmap and TLS, they have their own custom proto_ops, so simply
>>> checking sk->sk_prot is insufficient.
>>>
>>> For example, an IPv6 request might incorrectly follow the IPv4 code path,
>>> leading to kernel panic.
>>>
>> Did you experiment issues, or is it a supposition? If yes, do you have
>> traces containing such panics (or just a WARN()?), and ideally the
>> userspace code that was leading to this?
>>
>
>
> Thank you, Matthieu, for your suggestions. I spent some time revisiting the MPTCP logic.
>
>
> Now I need to describe how sockmap/skmsg works to explain its conflict with MPTCP:
OK, so the issue is only with sockmap, not TLS, right?
> 1. skmsg works by replacing sk_data_ready, recvmsg, sendmsg operations and implementing
> fast socket-level forwarding logic
>
> 2. Users can obtain file descriptors through userspace socket()/accept() interfaces, then
> call BPF syscall to perform these replacements.
> 3. Users can also use the bpf_sock_hash_update helper (in sockops programs) to replace
> handlers when TCP connections enter ESTABLISHED state (BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB or BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB)
I appreciate these explanations. I will comment on the v3.
> For MPTCP to work with sockmap, I believe we need to address the following points
> (please correct me if I have any conceptual misunderstandings about MPTCP):
>
> 1. From client perspective: When a user connects to a server via socket(), the kernel
> creates one master sk and at least two subflow sk's. Since the master sk doesn't participate
> in the three-way handshake, in the sockops flow we can only access the subflow sk's.
To be a bit more precise, with MPTCP, you will deal with different
socket types:
- the userspace facing one: it is an MPTCP socket (IPPROTO_MPTCP)
- the in-kernel subflow(s) (= path): they are TCP sockets, but not
exposed to the userspace.
There is no "master sk" (I hope you didn't look at the previous fork
implementation that was using this name, before the upstreaming
process), but yes, you will have the MPTCP socket, and at least one TCP
socket for the subflow.
> In this case, we need to replace the handlers of mptcp_subflow_ctx(sk)->conn rather
> than the subflow sk itself.
>> 2. From server perspective: In BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB,
the sk is the MP_CAPABLE
> subflow sk, so similar to the client perspective, we need to replace the handlers of
> mptcp_subflow_ctx(sk)->conn.
On the userspace side, the socket after the 'accept()' is either an
MPTCP socket (IPPROTO_MPTCP) or a TCP one (IPPROTO_TCP) depending on the
request: if the SYN was containing the MP_CAPABLE option or not. If a
plain TCP socket is returned, it is not an MPTCP subflow any more, it is
a "classic" TCP connection.
To get MPTCP support with sockmap, I guess you will need to act at the
MPTCP level: you should never manipulate the data on the TCP subflows
directly, because you will only get a part of the data when multiple
paths are being used. Instead, you should wait for MPTCP to re-order the
data, etc.
> If the above description is correct, then my current patch is incorrect. I should focus on
> handling the sockmap handler replacement flow properly instead.
It would be really great to add MPTCP support in sockmap, but first, I
guess we need a way to prevent issues like the one you saw.
> Of course, this would require comprehensive selftests to validate.
>
> Returning to the initial issue, the panic occurred on kernel 6.1, but when I tested with the
> latest upstream test environment, it only triggered a WARN().
> I suspect there have been significant changes in MPTCP during this period.
Even if it was only triggering a WARN(), we will still need a fix for
v6.1. Once the series will be ready, do you mind checking what needs to
be done to have the solution working on v6.1? I guess the solution
should be very close to what we will have on v6.18.
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
Powered by blists - more mailing lists