Skip to content

bpf: Fix backward progress bug in bpf_iter_udp

Martin KaFai Lau bpf netdev 2 versions – Applied

Status from this message: This series was applied to bpf/bpf.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 2 repliesApplied 3/3
  2. v23 patches 4 repliesSuperseded

Changes in v3 from the cover letter

- Fixed the iter_fd check and local_port check in the
patch 3 selftest. (Yonghong)
- Moved jhash2 to test_jhash.h in the patch 3. (Yonghong)
- Added explanation in the bucket selection in the patch 3. (Yonghong)

Patches in v3 All 3 applied

#Subject and filesSizeRepliesApplied
1/3bpf: iter_udp: Retry with a larger batch size without going back to the previous bucketnet/ipv4/udp.c+0 -11 replyApplied
2/3bpf: Avoid iter->offset making backward progress in bpf_iter_udpnet/ipv4/udp.c+10 -111 replyApplied
3/3selftests/bpf: Test udp and tcp iter batchingtools/testing/selftests/bpf/prog_tests/sock_iter_batch.c tools/testing/selftests/bpf/progs/bpf_tracing_net.h tools/testing/selftests/bpf/progs/sock_iter_batch.c +1 more+260 -00 repliesApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchYonghong SongAditi Ghag
1/3A-b R-b
2/3A-b R-b
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 bpf 0/3] bpf: Fix backward progress bug in bpf_iter_udp

From: Martin KaFai Lau <[email protected]>

This patch set fixes an issue in bpf_iter_udp that makes backward progress and prevents the user space process from finishing. There is a test at the end to reproduce the bug.

Please see individual patches for details.

v3:
- Fixed the iter_fd check and local_port check in the
patch 3 selftest. (Yonghong)
- Moved jhash2 to test_jhash.h in the patch 3. (Yonghong)
- Added explanation in the bucket selection in the patch 3. (Yonghong)

v2:
- Added patch 1 to fix another bug that goes back to the previous bucket
- Simplify the fix in patch 2 to always reset iter->offset to 0
- Add a test case to close all udp_sk in a bucket while in the middle of the iteration.

Martin KaFai Lau (3):
bpf: iter_udp: Retry with a larger batch size without going back to
the previous bucket
bpf: Avoid iter->offset making backward progress in bpf_iter_udp selftests/bpf: Test udp and tcp iter batching

 net/ipv4/udp.c                                |  22 ++-
 .../bpf/prog_tests/sock_iter_batch.c          | 135 ++++++++++++++++++
 .../selftests/bpf/progs/bpf_tracing_net.h     |   3 +
 .../selftests/bpf/progs/sock_iter_batch.c     |  91 ++++++++++++
 .../testing/selftests/bpf/progs/test_jhash.h  |  31 ++++
 5 files changed, 270 insertions(+), 12 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/sock_iter_batch.c
 create mode 100644 tools/testing/selftests/bpf/progs/sock_iter_batch.c
Signature · 1 line
2.34.1