Skip to content

mptcp: convert to sockopt_lock_sock

Gang Yan mptcp 3 versions – In review

Get series with b4
b4 am [email protected] change-id 20260506-sockopt_lock-c46837d6d9d7

Versions newest first

  1. v5 Latest6 patches 6 repliesIn review
  2. v42 patches 5 repliesSuperseded
  3. v32 patches 1 replySuperseded

Changes in v5 from the cover letter

- Split patch 1 into two patches, one is to replace lock_sock_fast with lock_sock to avoid 'sleeping in atomic context' issue in regular path, and another one is using 'sockopt_lock_sock' for mptcp socket like TCP does.
- Patch 3 prevents the sleeping issue from requiring ssks' lock in BPF context, It will return -EOPNOTSUPP when application/BPF programs trip on this.
- Patch 4 and 5 are temporary patches used to verify the validity of the above functions.

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6mptcp: replace lock_sock_fast with lock_sock in sockoptnet/mptcp/sockopt.c+8 -102 replies
2/6mptcp: use sockopt_lock/release_sock in sockoptnet/mptcp/sockopt.c+42 -420 replies
3/6mptcp: use sockopt_ns_capable in congestion controlnet/mptcp/sockopt.c+2 -20 replies
4/6mptcp: reject sockopt requiring ssks' lock in BPF contextnet/mptcp/sockopt.c+27 -03 replies
5/6DO-NOT-MERGE: mptcp: allow set some sockopt in BPF contextnet/core/filter.c+6 -00 replies
6/6DO-NOT-MERGE: selftest: bpf: set mptcp sockopt in BPF contexttools/testing/selftests/bpf/prog_tests/mptcp.c tools/testing/selftests/bpf/progs/mptcp_setsockopt.c+135 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH mptcp-next v5 0/6] mptcp: convert to sockopt_lock_sock

Hi Maintainers,

This patch series fixes locking issues in the sockopt path and adds support for setting MPTCP sockopts in BPF context.

Patch 1 can avoid accidentally introducing sleeping operations inside the lock_sock_fast() critical section like b5c52908d5("mptcp: fix scheduling with atomic in timestamp sockopt") does.

Although patches 4 and 5 are marked DO-NOT-MERGE, I think they are ready for upstream submission, reviews are welcome.

Thanks
Gang

---
Changelog:
v5:
- Split patch 1 into two patches, one is to replace lock_sock_fast with lock_sock to avoid 'sleeping in atomic context' issue in regular path, and another one is using 'sockopt_lock_sock' for mptcp socket like TCP does.
- Patch 3 prevents the sleeping issue from requiring ssks' lock in BPF context, It will return -EOPNOTSUPP when application/BPF programs trip on this.
- Patch 4 and 5 are temporary patches used to verify the validity of the above functions.
v4:
- As sashiko said, when processing BPF setsockopt requests, the msk is already locked, but we need to use lock_sock() to protect ssk. If we use sockopt_lock_sock(ssk), it will return without acquiring the lock.
- In 'mptcp_setsockopt_sol_tcp_congestion', the load of 'tcp_set_congestion_control' is changed from 'true' to '!has_current_bpf_ctx()' like tcp does. This determines whether tcp_ca_find() or tcp_ca_find_autoload() is called. I agree we should keep consistent with the TCP implementation.

v3:
- Remove the special symbols in v2.
- Use sockopt_ns_capable to replace ns_capable.

v2:

---
Gang Yan (6):
mptcp: replace lock_sock_fast with lock_sock in sockopt
mptcp: use sockopt_lock/release_sock in sockopt
mptcp: use sockopt_ns_capable in congestion control
mptcp: reject sockopt requiring ssks' lock in BPF context
DO-NOT-MERGE: mptcp: allow set some sockopt in BPF context
DO-NOT-MERGE: selftest: bpf: set mptcp sockopt in BPF context

 net/core/filter.c                                  |   6 +
 net/mptcp/sockopt.c                                | 133 ++++++++++++---------
 tools/testing/selftests/bpf/prog_tests/mptcp.c     |  64 ++++++++++
 .../testing/selftests/bpf/progs/mptcp_setsockopt.c |  71 +++++++++++
 4 files changed, 220 insertions(+), 54 deletions(-)

---
base-commit: aa15c271d79edde595fb6f4eedb52fbc16325a83
change-id: 20260506-sockopt_lock-c46837d6d9d7

Best regards,

Signature · 1 line
Gang Yan <[email protected]>