|
|
Log in / Subscribe / Register

Support direct writes to nf_conn:mark

From:  Daniel Xu <dxu-AT-dxuuu.xyz>
To:  bpf-AT-vger.kernel.org, ast-AT-kernel.org, daniel-AT-iogearbox.net, andrii-AT-kernel.org, memxor-AT-gmail.com
Subject:  [PATCH bpf-next v3 0/5] Support direct writes to nf_conn:mark
Date:  Fri, 19 Aug 2022 17:23:29 -0600
Message-ID:  <cover.1660951028.git.dxu@dxuuu.xyz>
Cc:  Daniel Xu <dxu-AT-dxuuu.xyz>, pablo-AT-netfilter.org, fw-AT-strlen.de, toke-AT-kernel.org, martin.lau-AT-linux.dev, netfilter-devel-AT-vger.kernel.org, netdev-AT-vger.kernel.org, linux-kernel-AT-vger.kernel.org
Archive-link:  Article

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:
- v2: https://lore.kernel.org/bpf/CAP01T74Sgn354dXGiFWFryu4vg+o...
- v1: https://lore.kernel.org/bpf/cover.1660592020.git.dxu@dxuu...

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 (5):
  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: 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      | 13 ++++
 kernel/bpf/verifier.c                         |  3 -
 net/core/filter.c                             | 50 +++++++++++++++
 net/ipv4/bpf_tcp_ca.c                         |  2 +-
 net/netfilter/nf_conntrack_bpf.c              | 64 ++++++++++++++++++-
 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 ++++
 10 files changed, 160 insertions(+), 7 deletions(-)

-- 
2.37.1



Copyright © 2022, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds