1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */ 3 #include <vmlinux.h> 4 #include <bpf/bpf_helpers.h> 5 6 char _license[] SEC("license") = "GPL"; 7 8 struct { 9 __uint(type, BPF_MAP_TYPE_RHASH); 10 __uint(map_flags, BPF_F_NO_PREALLOC); 11 __uint(max_entries, 64); 12 __type(key, __u32); 13 __type(value, __u64); 14 } rhashmap SEC(".maps"); 15 16 __u32 key_sum = 0; 17 __u64 val_sum = 0; 18 __u32 elem_count = 0; 19 __u32 err = 0; 20 21 SEC("iter/bpf_map_elem") 22 int dump_bpf_rhash_map(struct bpf_iter__bpf_map_elem *ctx) 23 { 24 __u32 *key = ctx->key; 25 __u64 *val = ctx->value; 26 27 if (!key || !val) 28 return 0; 29 30 key_sum += *key; 31 val_sum += *val; 32 elem_count++; 33 return 0; 34 } 35