bpf: Add batched ops support for percpu array
authorPedro Tammela <pctammela@gmail.com>
Sat, 24 Apr 2021 21:45:09 +0000 (18:45 -0300)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 27 Apr 2021 23:17:45 +0000 (01:17 +0200)
Uses the already in-place infrastructure provided by the
'generic_map_*_batch' functions.

No tweak was needed as it transparently handles the percpu variant.

As arrays don't have delete operations, let it return a error to
user space (default behaviour).

Suggested-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210424214510.806627-2-pctammela@mojatatu.com
kernel/bpf/arraymap.c

index 463d25e..3c41056 100644 (file)
@@ -698,6 +698,8 @@ const struct bpf_map_ops percpu_array_map_ops = {
        .map_delete_elem = array_map_delete_elem,
        .map_seq_show_elem = percpu_array_map_seq_show_elem,
        .map_check_btf = array_map_check_btf,
+       .map_lookup_batch = generic_map_lookup_batch,
+       .map_update_batch = generic_map_update_batch,
        .map_set_for_each_callback_args = map_set_for_each_callback_args,
        .map_for_each_callback = bpf_for_each_array_elem,
        .map_btf_name = "bpf_array",