[PATCH mptcp-net] mptcp: sockopt: check timestamping ret value

Matthieu Baerts (NGI0) posted 1 patch 1 week, 5 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20260527-mptcp-sockopt-timestamping-ret-v1-1-8eda97e24562@kernel.org
net/mptcp/sockopt.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
[PATCH mptcp-net] mptcp: sockopt: check timestamping ret value
Posted by Matthieu Baerts (NGI0) 1 week, 5 days ago
sock_set_timestamping() can fail for different reasons. The returned
value should then be checked.

If sock_set_timestamping() fails for at least one subflow, the first
error is now reported to the userspace, similar to what is done with
other socket options.

Fixes: 9061f24bf82e ("mptcp: sockopt: propagate timestamp request to subflows")
Reported-by: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Closes: https://lore.kernel.org/willemdebruijn.kernel.178a41a53d041@gmail.com
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/sockopt.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index 87b5796d0135..91aa57f1d0fd 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -241,15 +241,19 @@ static int mptcp_setsockopt_sol_socket_timestamping(struct mptcp_sock *msk,
 
 	mptcp_for_each_subflow(msk, subflow) {
 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+		int err;
 
 		lock_sock(ssk);
-		sock_set_timestamping(ssk, optname, timestamping);
+		err = sock_set_timestamping(ssk, optname, timestamping);
 		release_sock(ssk);
+
+		if (err < 0 && ret == 0)
+			ret = err;
 	}
 
 	release_sock(sk);
 
-	return 0;
+	return ret;
 }
 
 static int mptcp_setsockopt_sol_socket_linger(struct mptcp_sock *msk, sockptr_t optval,

---
base-commit: 599cb099e01efc713c7c120654ebd9fb49ac2782
change-id: 20260527-mptcp-sockopt-timestamping-ret-e2029bf0f24a

Best regards,
--  
Matthieu Baerts (NGI0) <matttbe@kernel.org>
Re: [PATCH mptcp-net] mptcp: sockopt: check timestamping ret value
Posted by Mat Martineau 1 week, 3 days ago
On Wed, 27 May 2026, Matthieu Baerts (NGI0) wrote:

> sock_set_timestamping() can fail for different reasons. The returned
> value should then be checked.
>
> If sock_set_timestamping() fails for at least one subflow, the first
> error is now reported to the userspace, similar to what is done with
> other socket options.
>
> Fixes: 9061f24bf82e ("mptcp: sockopt: propagate timestamp request to subflows")
> Reported-by: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
> Closes: https://lore.kernel.org/willemdebruijn.kernel.178a41a53d041@gmail.com
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> ---
> net/mptcp/sockopt.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
> index 87b5796d0135..91aa57f1d0fd 100644
> --- a/net/mptcp/sockopt.c
> +++ b/net/mptcp/sockopt.c
> @@ -241,15 +241,19 @@ static int mptcp_setsockopt_sol_socket_timestamping(struct mptcp_sock *msk,
>
> 	mptcp_for_each_subflow(msk, subflow) {
> 		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
> +		int err;
>
> 		lock_sock(ssk);
> -		sock_set_timestamping(ssk, optname, timestamping);
> +		err = sock_set_timestamping(ssk, optname, timestamping);
> 		release_sock(ssk);
> +
> +		if (err < 0 && ret == 0)
> +			ret = err;
> 	}
>
> 	release_sock(sk);
>
> -	return 0;
> +	return ret;
> }
>
> static int mptcp_setsockopt_sol_socket_linger(struct mptcp_sock *msk, sockptr_t optval,
>
> ---
> base-commit: 599cb099e01efc713c7c120654ebd9fb49ac2782
> change-id: 20260527-mptcp-sockopt-timestamping-ret-e2029bf0f24a
>

Looks good to me, thanks Matthieu

Reviewed-by: Mat Martineau <martineau@kernel.org>
Re: [PATCH mptcp-net] mptcp: sockopt: check timestamping ret value
Posted by Matthieu Baerts 1 week, 3 days ago
Hi Mat,

On 29/05/2026 11:35, Mat Martineau wrote:
> On Wed, 27 May 2026, Matthieu Baerts (NGI0) wrote:
> 
>> sock_set_timestamping() can fail for different reasons. The returned
>> value should then be checked.
>>
>> If sock_set_timestamping() fails for at least one subflow, the first
>> error is now reported to the userspace, similar to what is done with
>> other socket options.

(...)

> Looks good to me, thanks Matthieu
Thank you for the review!

This patch and "mptcp: sockopt: set sockopt on all subflows" are now in
our tree:

New patches for t/upstream-net and t/upstream:
- 791012465bed: mptcp: sockopt: check timestamping ret value
- ad61cc3c3388: mptcp: sockopt: set sockopt on all subflows
- Results: 54d30f4ed501..ba5ea3e35898 (export-net)
- Results: 830f9e3412a9..4d6bda29d05f (export)

Tests are now in progress:

- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/fbc7aa504c6a29aba0c3e5b563fb76de6ce7464a/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/64a0f10e355310447acda9767d4fde746159172f/checks

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Re: [PATCH mptcp-net] mptcp: sockopt: check timestamping ret value
Posted by MPTCP CI 1 week, 5 days ago
Hi Matthieu,

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): Unstable: 1 failed test(s): packetdrill_dss ⚠️ 
- 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/26484035820

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/a87ee7f555a6
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1101306


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)