Skip to content

bpf/flow_dissector: support input flags

Stanislav Fomichev bpf netdev 3 versions – Applied

Status from this message: Applied. Thanks

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest7 patches 3 repliesApplied
  2. v27 patches 4 repliesSuperseded
  3. v17 patches 12 repliesSuperseded

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/7bpf/flow_dissector: pass input flags to BPF flow dissector programinclude/linux/skbuff.h include/uapi/linux/bpf.h net/bpf/test_run.c +1 more+17 -40 replies
2/7bpf/flow_dissector: document flagsDocumentation/bpf/prog_flow_dissector.rst+18 -00 replies
3/7bpf/flow_dissector: support flags in BPF_PROG_TEST_RUNnet/bpf/test_run.c+35 -40 replies
4/7tools/bpf: sync bpf_flow_keys flagstools/include/uapi/linux/bpf.h+5 -00 replies
5/7selftests/bpf: support BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAGtools/testing/selftests/bpf/prog_tests/flow_dissector.c tools/testing/selftests/bpf/progs/bpf_flow.c+155 -70 replies
6/7bpf/flow_dissector: support ipv6 flow_label and BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABELinclude/uapi/linux/bpf.h net/core/flow_dissector.c tools/include/uapi/linux/bpf.h +2 more+67 -00 replies
7/7selftests/bpf: support BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAPtools/testing/selftests/bpf/prog_tests/flow_dissector.c tools/testing/selftests/bpf/progs/bpf_flow.c+72 -02 replies

Reviews trailers per patch

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

PatchPetar PenkovWillem de BruijnSong Liu
1/7A-b A-b A-b
2/7A-b A-b A-b
3/7A-b A-b A-b
4/7A-b A-b A-b
5/7A-b A-b A-b
6/7A-b A-b A-b
7/7A-b A-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/7] bpf/flow_dissector: support input flags

C flow dissector supports input flags that tell it to customize parsing by either stopping early or trying to parse as deep as possible. BPF flow dissector always parses as deep as possible which is sub-optimal. Pass input flags to the BPF flow dissector as well so it can make the same decisions.

Series outline:
* remove unused FLOW_DISSECTOR_F_STOP_AT_L3 flag
* export FLOW_DISSECTOR_F_XXX flags as uapi and pass them to BPF flow dissector
* add documentation for the export flags
* support input flags in BPF_PROG_TEST_RUN via ctx_{in,out}
* sync uapi to tools
* support FLOW_DISSECTOR_F_PARSE_1ST_FRAG in selftest
* support FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL in kernel and selftest
* support FLOW_DISSECTOR_F_STOP_AT_ENCAP in selftest

Pros:
* makes BPF flow dissector faster by avoiding burning extra cycles
* existing BPF progs continue to work by ignoring the flags and always parsing as deep as possible

Cons:
* new UAPI which we need to support (OTOH, if we need to deprecate some flags, we can just stop setting them upon calling BPF programs)

Some numbers (with .repeat = 4000000 in test_flow_dissector):
test_flow_dissector:PASS:ipv4-frag 35 nsec test_flow_dissector:PASS:ipv4-frag 35 nsec test_flow_dissector:PASS:ipv4-no-frag 32 nsec test_flow_dissector:PASS:ipv4-no-frag 32 nsec

test_flow_dissector:PASS:ipv6-frag 39 nsec test_flow_dissector:PASS:ipv6-frag 39 nsec test_flow_dissector:PASS:ipv6-no-frag 36 nsec test_flow_dissector:PASS:ipv6-no-frag 36 nsec

test_flow_dissector:PASS:ipv6-flow-label 36 nsec test_flow_dissector:PASS:ipv6-flow-label 36 nsec test_flow_dissector:PASS:ipv6-no-flow-label 33 nsec test_flow_dissector:PASS:ipv6-no-flow-label 33 nsec

test_flow_dissector:PASS:ipip-encap 38 nsec test_flow_dissector:PASS:ipip-encap 38 nsec test_flow_dissector:PASS:ipip-no-encap 32 nsec test_flow_dissector:PASS:ipip-no-encap 32 nsec

The improvement is around 10%, but it's in a tight cache-hot BPF_PROG_TEST_RUN loop.

Cc Song Liu <[email protected]>
Cc Willem de Bruijn <[email protected]>
Cc Petar Penkov <[email protected]>

Stanislav Fomichev (7):
bpf/flow_dissector: pass input flags to BPF flow dissector program bpf/flow_dissector: document flags
bpf/flow_dissector: support flags in BPF_PROG_TEST_RUN tools/bpf: sync bpf_flow_keys flags
selftests/bpf: support BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG bpf/flow_dissector: support ipv6 flow_label and
BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL
selftests/bpf: support BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP

 Documentation/bpf/prog_flow_dissector.rst     |  18 ++
 include/linux/skbuff.h                        |   2 +-
 include/uapi/linux/bpf.h                      |   6 +
 net/bpf/test_run.c                            |  39 ++-
 net/core/flow_dissector.c                     |  21 +-
 tools/include/uapi/linux/bpf.h                |   6 +
 .../selftests/bpf/prog_tests/flow_dissector.c | 243 +++++++++++++++++-
 tools/testing/selftests/bpf/progs/bpf_flow.c  |  47 +++-
 8 files changed, 368 insertions(+), 14 deletions(-)
Signature · 1 line
2.22.0.709.g102302147b-goog