Skip to content

RFC bpf: add longest prefix match map

Daniel Mack netdev 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: add a longest prefix match trie map implementationinclude/uapi/linux/bpf.h kernel/bpf/Makefile kernel/bpf/lpm_trie.c+499 -10 replies
2/2bpf: Add tests for the lpm trie maptools/testing/selftests/bpf/.gitignore tools/testing/selftests/bpf/Makefile tools/testing/selftests/bpf/test_lpm_map.c+351 -20 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchDavid Herrmann
1/2R-b
2/2

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

Read the v1 thread

Cover letter [PATCH RFC 0/2] bpf: add longest prefix match map

This patch set adds longest prefix match algorithm that can be used to match IP addresses to a stored set of ranges. It is exposed as a bpf map type.

Internally, data is stored in an unbalanced tree of nodes that has a maximum height of n, where n is the prefixlen the trie was created with.

Not that this has nothing to do with fib or fib6 and is in no way meant to replace or share code with it. It's rather a much simpler implementation that is specifically written with bpf maps in mind.

Patch 1/2 adds the implementation, and 2/2 an extensive test suite.

Feedback is much appreciated.

Thanks,
Daniel

Daniel Mack (1):
bpf: add a longest prefix match trie map implementation

David Herrmann (1):
bpf: Add tests for the lpm trie map

 include/uapi/linux/bpf.h                   |   7 +
 kernel/bpf/Makefile                        |   2 +-
 kernel/bpf/lpm_trie.c                      | 491 +++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/.gitignore     |   1 +
 tools/testing/selftests/bpf/Makefile       |   4 +-
 tools/testing/selftests/bpf/test_lpm_map.c | 348 ++++++++++++++++++++
 6 files changed, 850 insertions(+), 3 deletions(-)
 create mode 100644 kernel/bpf/lpm_trie.c
 create mode 100644 tools/testing/selftests/bpf/test_lpm_map.c
Signature · 1 line
2.9.3