Skip to content

Support direct writes to nf_conn:mark

Daniel Xu bpf lkml netdev netfilter-devel 6 versions – Applied

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

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest6 patches 2 repliesApplied 6/6
  2. v45 patches 4 repliesSuperseded
  3. v35 patches 3 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v2 posting 2/24 patches12 repliesSuperseded
v2 posting 1/20 of 4 patches0 repliesSuperseded
v13 patches8 repliesSuperseded

Changes in v5 from the cover letter

- Use exported function pointer + mutex to handle CONFIG_NF_CONNTRACK=m case

Patches in v5 All 6 applied

#Subject and filesSizeRepliesApplied
1/6bpf: Remove duplicate PTR_TO_BTF_ID RO checkkernel/bpf/verifier.c+0 -30 repliesApplied
2/6bpf: Add stub for btf_struct_access()include/linux/bpf.h+9 -00 repliesApplied
3/6bpf: Use 0 instead of NOT_INIT for btf_struct_access() writesnet/ipv4/bpf_tcp_ca.c+1 -10 repliesApplied
4/6bpf: Export btf_type_by_id() and bpf_log()kernel/bpf/btf.c kernel/bpf/verifier.c+2 -00 repliesApplied
5/6bpf: Add support for writing to nf_conn:markinclude/net/netfilter/nf_conntrack_bpf.h net/core/filter.c net/netfilter/nf_conntrack_bpf.c +1 more+143 -10 repliesApplied
6/6selftests/bpf: Add tests for writing to nf_conn:marktools/testing/selftests/bpf/prog_tests/bpf_nf.c tools/testing/selftests/bpf/progs/test_bpf_nf.c tools/testing/selftests/bpf/progs/test_bpf_nf_fail.c+23 -20 repliesApplied

Reviews trailers per patch

2 of 6 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchKumar Kartikeya Dwivedi
SeriesA-b
1/6A-b
2/6A-b
3/6
4/6
5/6
6/6

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

Read the v5 thread

Cover letter [PATCH bpf-next v5 0/6] Support direct writes to nf_conn:mark

Support direct writes to nf_conn:mark from TC and XDP prog types. This is useful when applications want to store per-connection metadata. This is also particularly useful for applications that run both bpf and iptables/nftables because the latter can trivially access this metadata.

One example use case would be if a bpf prog is responsible for advanced packet classification and iptables/nftables is later used for routing due to pre-existing/legacy code.

Past discussion:
- v4: https://lore.kernel.org/bpf/[email protected]/
- v3: https://lore.kernel.org/bpf/[email protected]/
- v2: https://lore.kernel.org/bpf/CAP01T74Sgn354dXGiFWFryu4vg+o8b9s9La1d9zEbC4LGvH4qg@mail.gmail.com/T/
- v1: https://lore.kernel.org/bpf/[email protected]/

Changes since v4:
- Use exported function pointer + mutex to handle CONFIG_NF_CONNTRACK=m case

Changes since v3:
- Use a mutex to protect module load/unload critical section

Changes since v2:
- Remove use of NOT_INIT for btf_struct_access write path
- Disallow nf_conn writing when nf_conntrack module not loaded
- Support writing to nf_conn___init:mark

Changes since v1:
- Add unimplemented stub for when !CONFIG_BPF_SYSCALL

Daniel Xu (6):
bpf: Remove duplicate PTR_TO_BTF_ID RO check
bpf: Add stub for btf_struct_access()
bpf: Use 0 instead of NOT_INIT for btf_struct_access() writes
bpf: Export btf_type_by_id() and bpf_log()
bpf: Add support for writing to nf_conn:mark selftests/bpf: Add tests for writing to nf_conn:mark

 include/linux/bpf.h                           |  9 +++
 include/net/netfilter/nf_conntrack_bpf.h      | 23 +++++++
 kernel/bpf/btf.c                              |  1 +
 kernel/bpf/verifier.c                         |  4 +-
 net/core/filter.c                             | 54 +++++++++++++++
 net/ipv4/bpf_tcp_ca.c                         |  2 +-
 net/netfilter/nf_conntrack_bpf.c              | 66 ++++++++++++++++++-
 net/netfilter/nf_conntrack_core.c             |  1 +
 .../testing/selftests/bpf/prog_tests/bpf_nf.c |  2 +
 .../testing/selftests/bpf/progs/test_bpf_nf.c |  9 ++-
 .../selftests/bpf/progs/test_bpf_nf_fail.c    | 14 ++++
 11 files changed, 178 insertions(+), 7 deletions(-)
Signature · 1 line
2.37.1