Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright (c) 2020 Facebook */
0003 #include "bpf_iter.h"
0004 #include <bpf/bpf_helpers.h>
0005 
0006 char _license[] SEC("license") = "GPL";
0007 
0008 __u32 value_sum = 0;
0009 
0010 SEC("iter/bpf_map_elem")
0011 int dump_bpf_hash_map(struct bpf_iter__bpf_map_elem *ctx)
0012 {
0013     void *value = ctx->value;
0014 
0015     if (value == (void *)0)
0016         return 0;
0017 
0018     /* negative offset, verifier failure. */
0019     value_sum += *(__u32 *)(value - 4);
0020     return 0;
0021 }