Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0
2/* Copyright (c) 2025 Intel Corporation */
3#include "vmlinux.h"
4#include <bpf/bpf_helpers.h>
5
6char _license[] SEC("license") = "GPL";
7
8struct {
9 __uint(type, BPF_MAP_TYPE_HASH);
10 __uint(max_entries, 128);
11 __type(key, __u64);
12 __type(value, __u64);
13} hashmap SEC(".maps");
14
15static int cb(struct bpf_map *map, __u64 *key, __u64 *val, void *arg)
16{
17 bpf_map_delete_elem(map, key);
18 bpf_map_update_elem(map, key, val, 0);
19 return 0;
20}
21
22SEC("tc")
23int test_pkt_access(struct __sk_buff *skb)
24{
25 (void)skb;
26
27 bpf_for_each_map_elem(&hashmap, cb, NULL, 0);
28
29 return 0;
30}