Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.13-rc4 34 lines 677 B view raw
1/* SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) */ 2#include <linux/bpf.h> 3#include <bpf/bpf_helpers.h> 4 5struct { 6 __uint(type, BPF_MAP_TYPE_HASH); 7 __type(key, __u32); 8 __type(value, long); 9 __uint(max_entries, 2); 10} htab SEC(".maps"); 11 12struct { 13 __uint(type, BPF_MAP_TYPE_ARRAY); 14 __type(key, __u32); 15 __type(value, long); 16 __uint(max_entries, 2); 17} array SEC(".maps"); 18 19/* Sample program which should always load for testing control paths. */ 20SEC("xdp") int func() 21{ 22 __u64 key64 = 0; 23 __u32 key = 0; 24 long *value; 25 26 value = bpf_map_lookup_elem(&htab, &key); 27 if (!value) 28 return 1; 29 value = bpf_map_lookup_elem(&array, &key64); 30 if (!value) 31 return 1; 32 33 return 0; 34}