xref: /linux/tools/testing/selftests/bpf/progs/update_map_in_htab.c (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2024. Huawei Technologies Co., Ltd */
3 #include <linux/bpf.h>
4 #include <bpf/bpf_helpers.h>
5 
6 struct inner_map_type {
7 	__uint(type, BPF_MAP_TYPE_ARRAY);
8 	__uint(key_size, 4);
9 	__uint(value_size, 4);
10 	__uint(max_entries, 1);
11 } inner_map SEC(".maps");
12 
13 struct {
14 	__uint(type, BPF_MAP_TYPE_HASH_OF_MAPS);
15 	__type(key, int);
16 	__type(value, int);
17 	__uint(max_entries, 2);
18 	__array(values, struct inner_map_type);
19 } outer_htab_map SEC(".maps");
20 
21 struct {
22 	__uint(type, BPF_MAP_TYPE_HASH_OF_MAPS);
23 	__uint(map_flags, BPF_F_NO_PREALLOC);
24 	__type(key, int);
25 	__type(value, int);
26 	__uint(max_entries, 2);
27 	__array(values, struct inner_map_type);
28 } outer_alloc_htab_map SEC(".maps");
29 
30 char _license[] SEC("license") = "GPL";
31