1 // SPDX-License-Identifier: GPL-2.0 2 3 #include <linux/bpf.h> 4 #include <bpf/bpf_helpers.h> 5 6 char _license[] SEC("license") = "GPL"; 7 8 struct { 9 __uint(type, BPF_MAP_TYPE_HASH); 10 __uint(max_entries, 2); 11 __type(key, struct bigelement); 12 __type(value, __u32); 13 } hash_map SEC(".maps"); 14 15 struct { 16 __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); 17 __uint(max_entries, 1); 18 __type(key, __u32); 19 __type(value, struct bigelement); 20 } key_map SEC(".maps"); 21 22 struct bigelement { 23 int a; 24 char b[4096]; 25 long long c; 26 }; 27 28 SEC("raw_tracepoint/sys_enter") 29 int bpf_hash_large_key_test(void *ctx) 30 { 31 int zero = 0, err = 1, value = 42; 32 struct bigelement *key; 33 34 key = bpf_map_lookup_elem(&key_map, &zero); 35 if (!key) 36 return 0; 37 38 key->c = 1; 39 if (bpf_map_update_elem(&hash_map, key, &value, BPF_ANY)) 40 return 0; 41 42 return 0; 43 } 44 45