Re: [PATCH v5 bpf-next 3/5] selftests/bpf: Add bloom filter map test cases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 10/22/21 3:02 PM, Joanne Koong wrote:
This patch adds test cases for bpf bloom filter maps. They include tests
checking against invalid operations by userspace, tests for using the
bloom filter map as an inner map, and a bpf program that queries the
bloom filter map for values added by a userspace program.

Signed-off-by: Joanne Koong <joannekoong@xxxxxx>
---
  .../bpf/prog_tests/bloom_filter_map.c         | 204 ++++++++++++++++++
  .../selftests/bpf/progs/bloom_filter_map.c    |  82 +++++++
  2 files changed, 286 insertions(+)
  create mode 100644 tools/testing/selftests/bpf/prog_tests/bloom_filter_map.c
  create mode 100644 tools/testing/selftests/bpf/progs/bloom_filter_map.c


[...]


diff --git a/tools/testing/selftests/bpf/progs/bloom_filter_map.c b/tools/testing/selftests/bpf/progs/bloom_filter_map.c
new file mode 100644
index 000000000000..7f72102ea6a7
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/bloom_filter_map.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2021 Facebook */
+
+#include <linux/bpf.h>
+#include <bpf/bpf_helpers.h>
+
+char _license[] SEC("license") = "GPL";
+
+struct bpf_map;
+
+struct {
+	__uint(type, BPF_MAP_TYPE_ARRAY);
+	__uint(max_entries, 1000);
+	__type(key, __u32);
+	__type(value, __u32);
+} map_random_data SEC(".maps");
+
+struct map_bloom_type {
+	__uint(type, BPF_MAP_TYPE_BLOOM_FILTER);
+	__uint(value_size, sizeof(__u32));


you should be able to use __type(value, __u32); no? let's do that to confirm that kernel accepts it (please check that there are no warnings from libbpf about retrying without BTF)


+	__uint(max_entries, 10000);
+	__uint(map_extra, 5);
+} map_bloom SEC(".maps");
+
+struct {
+	__uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
+	__uint(max_entries, 1);
+	__uint(key_size, sizeof(int));
+	__uint(value_size, sizeof(int));


this should also work with __type(key, int) and __type(value, int), we've added logic to libbpf recently that takes care of this (see a big switch inside bpf_object__create_map()).


+	__array(values, struct map_bloom_type);
+} outer_map SEC(".maps");
+


[...]




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux