Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 // Copyright (c) 2020 Facebook
0003 
0004 #include <linux/bpf.h>
0005 #include <bpf/bpf_helpers.h>
0006 
0007 #define LOOP_BOUND 0xf
0008 #define MAX_ENTRIES 8
0009 #define HALF_ENTRIES (MAX_ENTRIES >> 1)
0010 
0011 _Static_assert(MAX_ENTRIES < LOOP_BOUND, "MAX_ENTRIES must be < LOOP_BOUND");
0012 
0013 enum bpf_map_type g_map_type = BPF_MAP_TYPE_UNSPEC;
0014 __u32 g_line = 0;
0015 int page_size = 0; /* userspace should set it */
0016 
0017 #define VERIFY_TYPE(type, func) ({  \
0018     g_map_type = type;      \
0019     if (!func())            \
0020         return 0;       \
0021 })
0022 
0023 
0024 #define VERIFY(expr) ({     \
0025     g_line = __LINE__;  \
0026     if (!(expr))        \
0027         return 0;   \
0028 })
0029 
0030 struct bpf_map {
0031     enum bpf_map_type map_type;
0032     __u32 key_size;
0033     __u32 value_size;
0034     __u32 max_entries;
0035     __u32 id;
0036 } __attribute__((preserve_access_index));
0037 
0038 static inline int check_bpf_map_fields(struct bpf_map *map, __u32 key_size,
0039                        __u32 value_size, __u32 max_entries)
0040 {
0041     VERIFY(map->map_type == g_map_type);
0042     VERIFY(map->key_size == key_size);
0043     VERIFY(map->value_size == value_size);
0044     VERIFY(map->max_entries == max_entries);
0045     VERIFY(map->id > 0);
0046 
0047     return 1;
0048 }
0049 
0050 static inline int check_bpf_map_ptr(struct bpf_map *indirect,
0051                     struct bpf_map *direct)
0052 {
0053     VERIFY(indirect->map_type == direct->map_type);
0054     VERIFY(indirect->key_size == direct->key_size);
0055     VERIFY(indirect->value_size == direct->value_size);
0056     VERIFY(indirect->max_entries == direct->max_entries);
0057     VERIFY(indirect->id == direct->id);
0058 
0059     return 1;
0060 }
0061 
0062 static inline int check(struct bpf_map *indirect, struct bpf_map *direct,
0063             __u32 key_size, __u32 value_size, __u32 max_entries)
0064 {
0065     VERIFY(check_bpf_map_ptr(indirect, direct));
0066     VERIFY(check_bpf_map_fields(indirect, key_size, value_size,
0067                     max_entries));
0068     return 1;
0069 }
0070 
0071 static inline int check_default(struct bpf_map *indirect,
0072                 struct bpf_map *direct)
0073 {
0074     VERIFY(check(indirect, direct, sizeof(__u32), sizeof(__u32),
0075              MAX_ENTRIES));
0076     return 1;
0077 }
0078 
0079 static __noinline int
0080 check_default_noinline(struct bpf_map *indirect, struct bpf_map *direct)
0081 {
0082     VERIFY(check(indirect, direct, sizeof(__u32), sizeof(__u32),
0083              MAX_ENTRIES));
0084     return 1;
0085 }
0086 
0087 typedef struct {
0088     int counter;
0089 } atomic_t;
0090 
0091 struct bpf_htab {
0092     struct bpf_map map;
0093     atomic_t count;
0094     __u32 n_buckets;
0095     __u32 elem_size;
0096 } __attribute__((preserve_access_index));
0097 
0098 struct {
0099     __uint(type, BPF_MAP_TYPE_HASH);
0100     __uint(map_flags, BPF_F_NO_PREALLOC); /* to test bpf_htab.count */
0101     __uint(max_entries, MAX_ENTRIES);
0102     __type(key, __u32);
0103     __type(value, __u32);
0104 } m_hash SEC(".maps");
0105 
0106 static inline int check_hash(void)
0107 {
0108     struct bpf_htab *hash = (struct bpf_htab *)&m_hash;
0109     struct bpf_map *map = (struct bpf_map *)&m_hash;
0110     int i;
0111 
0112     VERIFY(check_default_noinline(&hash->map, map));
0113 
0114     VERIFY(hash->n_buckets == MAX_ENTRIES);
0115     VERIFY(hash->elem_size == 64);
0116 
0117     VERIFY(hash->count.counter == 0);
0118     for (i = 0; i < HALF_ENTRIES; ++i) {
0119         const __u32 key = i;
0120         const __u32 val = 1;
0121 
0122         if (bpf_map_update_elem(hash, &key, &val, 0))
0123             return 0;
0124     }
0125     VERIFY(hash->count.counter == HALF_ENTRIES);
0126 
0127     return 1;
0128 }
0129 
0130 struct bpf_array {
0131     struct bpf_map map;
0132     __u32 elem_size;
0133 } __attribute__((preserve_access_index));
0134 
0135 struct {
0136     __uint(type, BPF_MAP_TYPE_ARRAY);
0137     __uint(max_entries, MAX_ENTRIES);
0138     __type(key, __u32);
0139     __type(value, __u32);
0140 } m_array SEC(".maps");
0141 
0142 static inline int check_array(void)
0143 {
0144     struct bpf_array *array = (struct bpf_array *)&m_array;
0145     struct bpf_map *map = (struct bpf_map *)&m_array;
0146     int i, n_lookups = 0, n_keys = 0;
0147 
0148     VERIFY(check_default(&array->map, map));
0149 
0150     VERIFY(array->elem_size == 8);
0151 
0152     for (i = 0; i < array->map.max_entries && i < LOOP_BOUND; ++i) {
0153         const __u32 key = i;
0154         __u32 *val = bpf_map_lookup_elem(array, &key);
0155 
0156         ++n_lookups;
0157         if (val)
0158             ++n_keys;
0159     }
0160 
0161     VERIFY(n_lookups == MAX_ENTRIES);
0162     VERIFY(n_keys == MAX_ENTRIES);
0163 
0164     return 1;
0165 }
0166 
0167 struct {
0168     __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
0169     __uint(max_entries, MAX_ENTRIES);
0170     __type(key, __u32);
0171     __type(value, __u32);
0172 } m_prog_array SEC(".maps");
0173 
0174 static inline int check_prog_array(void)
0175 {
0176     struct bpf_array *prog_array = (struct bpf_array *)&m_prog_array;
0177     struct bpf_map *map = (struct bpf_map *)&m_prog_array;
0178 
0179     VERIFY(check_default(&prog_array->map, map));
0180 
0181     return 1;
0182 }
0183 
0184 struct {
0185     __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
0186     __uint(max_entries, MAX_ENTRIES);
0187     __type(key, __u32);
0188     __type(value, __u32);
0189 } m_perf_event_array SEC(".maps");
0190 
0191 static inline int check_perf_event_array(void)
0192 {
0193     struct bpf_array *perf_event_array = (struct bpf_array *)&m_perf_event_array;
0194     struct bpf_map *map = (struct bpf_map *)&m_perf_event_array;
0195 
0196     VERIFY(check_default(&perf_event_array->map, map));
0197 
0198     return 1;
0199 }
0200 
0201 struct {
0202     __uint(type, BPF_MAP_TYPE_PERCPU_HASH);
0203     __uint(max_entries, MAX_ENTRIES);
0204     __type(key, __u32);
0205     __type(value, __u32);
0206 } m_percpu_hash SEC(".maps");
0207 
0208 static inline int check_percpu_hash(void)
0209 {
0210     struct bpf_htab *percpu_hash = (struct bpf_htab *)&m_percpu_hash;
0211     struct bpf_map *map = (struct bpf_map *)&m_percpu_hash;
0212 
0213     VERIFY(check_default(&percpu_hash->map, map));
0214 
0215     return 1;
0216 }
0217 
0218 struct {
0219     __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
0220     __uint(max_entries, MAX_ENTRIES);
0221     __type(key, __u32);
0222     __type(value, __u32);
0223 } m_percpu_array SEC(".maps");
0224 
0225 static inline int check_percpu_array(void)
0226 {
0227     struct bpf_array *percpu_array = (struct bpf_array *)&m_percpu_array;
0228     struct bpf_map *map = (struct bpf_map *)&m_percpu_array;
0229 
0230     VERIFY(check_default(&percpu_array->map, map));
0231 
0232     return 1;
0233 }
0234 
0235 struct bpf_stack_map {
0236     struct bpf_map map;
0237 } __attribute__((preserve_access_index));
0238 
0239 struct {
0240     __uint(type, BPF_MAP_TYPE_STACK_TRACE);
0241     __uint(max_entries, MAX_ENTRIES);
0242     __type(key, __u32);
0243     __type(value, __u64);
0244 } m_stack_trace SEC(".maps");
0245 
0246 static inline int check_stack_trace(void)
0247 {
0248     struct bpf_stack_map *stack_trace =
0249         (struct bpf_stack_map *)&m_stack_trace;
0250     struct bpf_map *map = (struct bpf_map *)&m_stack_trace;
0251 
0252     VERIFY(check(&stack_trace->map, map, sizeof(__u32), sizeof(__u64),
0253              MAX_ENTRIES));
0254 
0255     return 1;
0256 }
0257 
0258 struct {
0259     __uint(type, BPF_MAP_TYPE_CGROUP_ARRAY);
0260     __uint(max_entries, MAX_ENTRIES);
0261     __type(key, __u32);
0262     __type(value, __u32);
0263 } m_cgroup_array SEC(".maps");
0264 
0265 static inline int check_cgroup_array(void)
0266 {
0267     struct bpf_array *cgroup_array = (struct bpf_array *)&m_cgroup_array;
0268     struct bpf_map *map = (struct bpf_map *)&m_cgroup_array;
0269 
0270     VERIFY(check_default(&cgroup_array->map, map));
0271 
0272     return 1;
0273 }
0274 
0275 struct {
0276     __uint(type, BPF_MAP_TYPE_LRU_HASH);
0277     __uint(max_entries, MAX_ENTRIES);
0278     __type(key, __u32);
0279     __type(value, __u32);
0280 } m_lru_hash SEC(".maps");
0281 
0282 static inline int check_lru_hash(void)
0283 {
0284     struct bpf_htab *lru_hash = (struct bpf_htab *)&m_lru_hash;
0285     struct bpf_map *map = (struct bpf_map *)&m_lru_hash;
0286 
0287     VERIFY(check_default(&lru_hash->map, map));
0288 
0289     return 1;
0290 }
0291 
0292 struct {
0293     __uint(type, BPF_MAP_TYPE_LRU_PERCPU_HASH);
0294     __uint(max_entries, MAX_ENTRIES);
0295     __type(key, __u32);
0296     __type(value, __u32);
0297 } m_lru_percpu_hash SEC(".maps");
0298 
0299 static inline int check_lru_percpu_hash(void)
0300 {
0301     struct bpf_htab *lru_percpu_hash = (struct bpf_htab *)&m_lru_percpu_hash;
0302     struct bpf_map *map = (struct bpf_map *)&m_lru_percpu_hash;
0303 
0304     VERIFY(check_default(&lru_percpu_hash->map, map));
0305 
0306     return 1;
0307 }
0308 
0309 struct lpm_trie {
0310     struct bpf_map map;
0311 } __attribute__((preserve_access_index));
0312 
0313 struct lpm_key {
0314     struct bpf_lpm_trie_key trie_key;
0315     __u32 data;
0316 };
0317 
0318 struct {
0319     __uint(type, BPF_MAP_TYPE_LPM_TRIE);
0320     __uint(map_flags, BPF_F_NO_PREALLOC);
0321     __uint(max_entries, MAX_ENTRIES);
0322     __type(key, struct lpm_key);
0323     __type(value, __u32);
0324 } m_lpm_trie SEC(".maps");
0325 
0326 static inline int check_lpm_trie(void)
0327 {
0328     struct lpm_trie *lpm_trie = (struct lpm_trie *)&m_lpm_trie;
0329     struct bpf_map *map = (struct bpf_map *)&m_lpm_trie;
0330 
0331     VERIFY(check(&lpm_trie->map, map, sizeof(struct lpm_key), sizeof(__u32),
0332              MAX_ENTRIES));
0333 
0334     return 1;
0335 }
0336 
0337 #define INNER_MAX_ENTRIES 1234
0338 
0339 struct inner_map {
0340     __uint(type, BPF_MAP_TYPE_ARRAY);
0341     __uint(max_entries, INNER_MAX_ENTRIES);
0342     __type(key, __u32);
0343     __type(value, __u32);
0344 } inner_map SEC(".maps");
0345 
0346 struct {
0347     __uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
0348     __uint(max_entries, MAX_ENTRIES);
0349     __type(key, __u32);
0350     __type(value, __u32);
0351     __array(values, struct {
0352         __uint(type, BPF_MAP_TYPE_ARRAY);
0353         __uint(max_entries, INNER_MAX_ENTRIES);
0354         __type(key, __u32);
0355         __type(value, __u32);
0356     });
0357 } m_array_of_maps SEC(".maps") = {
0358     .values = { (void *)&inner_map, 0, 0, 0, 0, 0, 0, 0, 0 },
0359 };
0360 
0361 static inline int check_array_of_maps(void)
0362 {
0363     struct bpf_array *array_of_maps = (struct bpf_array *)&m_array_of_maps;
0364     struct bpf_map *map = (struct bpf_map *)&m_array_of_maps;
0365     struct bpf_array *inner_map;
0366     int key = 0;
0367 
0368     VERIFY(check_default(&array_of_maps->map, map));
0369     inner_map = bpf_map_lookup_elem(array_of_maps, &key);
0370     VERIFY(inner_map != NULL);
0371     VERIFY(inner_map->map.max_entries == INNER_MAX_ENTRIES);
0372 
0373     return 1;
0374 }
0375 
0376 struct {
0377     __uint(type, BPF_MAP_TYPE_HASH_OF_MAPS);
0378     __uint(max_entries, MAX_ENTRIES);
0379     __type(key, __u32);
0380     __type(value, __u32);
0381     __array(values, struct inner_map);
0382 } m_hash_of_maps SEC(".maps") = {
0383     .values = {
0384         [2] = &inner_map,
0385     },
0386 };
0387 
0388 static inline int check_hash_of_maps(void)
0389 {
0390     struct bpf_htab *hash_of_maps = (struct bpf_htab *)&m_hash_of_maps;
0391     struct bpf_map *map = (struct bpf_map *)&m_hash_of_maps;
0392     struct bpf_htab *inner_map;
0393     int key = 2;
0394 
0395     VERIFY(check_default(&hash_of_maps->map, map));
0396     inner_map = bpf_map_lookup_elem(hash_of_maps, &key);
0397     VERIFY(inner_map != NULL);
0398     VERIFY(inner_map->map.max_entries == INNER_MAX_ENTRIES);
0399 
0400     return 1;
0401 }
0402 
0403 struct bpf_dtab {
0404     struct bpf_map map;
0405 } __attribute__((preserve_access_index));
0406 
0407 struct {
0408     __uint(type, BPF_MAP_TYPE_DEVMAP);
0409     __uint(max_entries, MAX_ENTRIES);
0410     __type(key, __u32);
0411     __type(value, __u32);
0412 } m_devmap SEC(".maps");
0413 
0414 static inline int check_devmap(void)
0415 {
0416     struct bpf_dtab *devmap = (struct bpf_dtab *)&m_devmap;
0417     struct bpf_map *map = (struct bpf_map *)&m_devmap;
0418 
0419     VERIFY(check_default(&devmap->map, map));
0420 
0421     return 1;
0422 }
0423 
0424 struct bpf_stab {
0425     struct bpf_map map;
0426 } __attribute__((preserve_access_index));
0427 
0428 struct {
0429     __uint(type, BPF_MAP_TYPE_SOCKMAP);
0430     __uint(max_entries, MAX_ENTRIES);
0431     __type(key, __u32);
0432     __type(value, __u32);
0433 } m_sockmap SEC(".maps");
0434 
0435 static inline int check_sockmap(void)
0436 {
0437     struct bpf_stab *sockmap = (struct bpf_stab *)&m_sockmap;
0438     struct bpf_map *map = (struct bpf_map *)&m_sockmap;
0439 
0440     VERIFY(check_default(&sockmap->map, map));
0441 
0442     return 1;
0443 }
0444 
0445 struct bpf_cpu_map {
0446     struct bpf_map map;
0447 } __attribute__((preserve_access_index));
0448 
0449 struct {
0450     __uint(type, BPF_MAP_TYPE_CPUMAP);
0451     __uint(max_entries, MAX_ENTRIES);
0452     __type(key, __u32);
0453     __type(value, __u32);
0454 } m_cpumap SEC(".maps");
0455 
0456 static inline int check_cpumap(void)
0457 {
0458     struct bpf_cpu_map *cpumap = (struct bpf_cpu_map *)&m_cpumap;
0459     struct bpf_map *map = (struct bpf_map *)&m_cpumap;
0460 
0461     VERIFY(check_default(&cpumap->map, map));
0462 
0463     return 1;
0464 }
0465 
0466 struct xsk_map {
0467     struct bpf_map map;
0468 } __attribute__((preserve_access_index));
0469 
0470 struct {
0471     __uint(type, BPF_MAP_TYPE_XSKMAP);
0472     __uint(max_entries, MAX_ENTRIES);
0473     __type(key, __u32);
0474     __type(value, __u32);
0475 } m_xskmap SEC(".maps");
0476 
0477 static inline int check_xskmap(void)
0478 {
0479     struct xsk_map *xskmap = (struct xsk_map *)&m_xskmap;
0480     struct bpf_map *map = (struct bpf_map *)&m_xskmap;
0481 
0482     VERIFY(check_default(&xskmap->map, map));
0483 
0484     return 1;
0485 }
0486 
0487 struct bpf_shtab {
0488     struct bpf_map map;
0489 } __attribute__((preserve_access_index));
0490 
0491 struct {
0492     __uint(type, BPF_MAP_TYPE_SOCKHASH);
0493     __uint(max_entries, MAX_ENTRIES);
0494     __type(key, __u32);
0495     __type(value, __u32);
0496 } m_sockhash SEC(".maps");
0497 
0498 static inline int check_sockhash(void)
0499 {
0500     struct bpf_shtab *sockhash = (struct bpf_shtab *)&m_sockhash;
0501     struct bpf_map *map = (struct bpf_map *)&m_sockhash;
0502 
0503     VERIFY(check_default(&sockhash->map, map));
0504 
0505     return 1;
0506 }
0507 
0508 struct bpf_cgroup_storage_map {
0509     struct bpf_map map;
0510 } __attribute__((preserve_access_index));
0511 
0512 struct {
0513     __uint(type, BPF_MAP_TYPE_CGROUP_STORAGE);
0514     __type(key, struct bpf_cgroup_storage_key);
0515     __type(value, __u32);
0516 } m_cgroup_storage SEC(".maps");
0517 
0518 static inline int check_cgroup_storage(void)
0519 {
0520     struct bpf_cgroup_storage_map *cgroup_storage =
0521         (struct bpf_cgroup_storage_map *)&m_cgroup_storage;
0522     struct bpf_map *map = (struct bpf_map *)&m_cgroup_storage;
0523 
0524     VERIFY(check(&cgroup_storage->map, map,
0525              sizeof(struct bpf_cgroup_storage_key), sizeof(__u32), 0));
0526 
0527     return 1;
0528 }
0529 
0530 struct reuseport_array {
0531     struct bpf_map map;
0532 } __attribute__((preserve_access_index));
0533 
0534 struct {
0535     __uint(type, BPF_MAP_TYPE_REUSEPORT_SOCKARRAY);
0536     __uint(max_entries, MAX_ENTRIES);
0537     __type(key, __u32);
0538     __type(value, __u32);
0539 } m_reuseport_sockarray SEC(".maps");
0540 
0541 static inline int check_reuseport_sockarray(void)
0542 {
0543     struct reuseport_array *reuseport_sockarray =
0544         (struct reuseport_array *)&m_reuseport_sockarray;
0545     struct bpf_map *map = (struct bpf_map *)&m_reuseport_sockarray;
0546 
0547     VERIFY(check_default(&reuseport_sockarray->map, map));
0548 
0549     return 1;
0550 }
0551 
0552 struct {
0553     __uint(type, BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE);
0554     __type(key, struct bpf_cgroup_storage_key);
0555     __type(value, __u32);
0556 } m_percpu_cgroup_storage SEC(".maps");
0557 
0558 static inline int check_percpu_cgroup_storage(void)
0559 {
0560     struct bpf_cgroup_storage_map *percpu_cgroup_storage =
0561         (struct bpf_cgroup_storage_map *)&m_percpu_cgroup_storage;
0562     struct bpf_map *map = (struct bpf_map *)&m_percpu_cgroup_storage;
0563 
0564     VERIFY(check(&percpu_cgroup_storage->map, map,
0565              sizeof(struct bpf_cgroup_storage_key), sizeof(__u32), 0));
0566 
0567     return 1;
0568 }
0569 
0570 struct bpf_queue_stack {
0571     struct bpf_map map;
0572 } __attribute__((preserve_access_index));
0573 
0574 struct {
0575     __uint(type, BPF_MAP_TYPE_QUEUE);
0576     __uint(max_entries, MAX_ENTRIES);
0577     __type(value, __u32);
0578 } m_queue SEC(".maps");
0579 
0580 static inline int check_queue(void)
0581 {
0582     struct bpf_queue_stack *queue = (struct bpf_queue_stack *)&m_queue;
0583     struct bpf_map *map = (struct bpf_map *)&m_queue;
0584 
0585     VERIFY(check(&queue->map, map, 0, sizeof(__u32), MAX_ENTRIES));
0586 
0587     return 1;
0588 }
0589 
0590 struct {
0591     __uint(type, BPF_MAP_TYPE_STACK);
0592     __uint(max_entries, MAX_ENTRIES);
0593     __type(value, __u32);
0594 } m_stack SEC(".maps");
0595 
0596 static inline int check_stack(void)
0597 {
0598     struct bpf_queue_stack *stack = (struct bpf_queue_stack *)&m_stack;
0599     struct bpf_map *map = (struct bpf_map *)&m_stack;
0600 
0601     VERIFY(check(&stack->map, map, 0, sizeof(__u32), MAX_ENTRIES));
0602 
0603     return 1;
0604 }
0605 
0606 struct bpf_local_storage_map {
0607     struct bpf_map map;
0608 } __attribute__((preserve_access_index));
0609 
0610 struct {
0611     __uint(type, BPF_MAP_TYPE_SK_STORAGE);
0612     __uint(map_flags, BPF_F_NO_PREALLOC);
0613     __type(key, __u32);
0614     __type(value, __u32);
0615 } m_sk_storage SEC(".maps");
0616 
0617 static inline int check_sk_storage(void)
0618 {
0619     struct bpf_local_storage_map *sk_storage =
0620         (struct bpf_local_storage_map *)&m_sk_storage;
0621     struct bpf_map *map = (struct bpf_map *)&m_sk_storage;
0622 
0623     VERIFY(check(&sk_storage->map, map, sizeof(__u32), sizeof(__u32), 0));
0624 
0625     return 1;
0626 }
0627 
0628 struct {
0629     __uint(type, BPF_MAP_TYPE_DEVMAP_HASH);
0630     __uint(max_entries, MAX_ENTRIES);
0631     __type(key, __u32);
0632     __type(value, __u32);
0633 } m_devmap_hash SEC(".maps");
0634 
0635 static inline int check_devmap_hash(void)
0636 {
0637     struct bpf_dtab *devmap_hash = (struct bpf_dtab *)&m_devmap_hash;
0638     struct bpf_map *map = (struct bpf_map *)&m_devmap_hash;
0639 
0640     VERIFY(check_default(&devmap_hash->map, map));
0641 
0642     return 1;
0643 }
0644 
0645 struct bpf_ringbuf_map {
0646     struct bpf_map map;
0647 } __attribute__((preserve_access_index));
0648 
0649 struct {
0650     __uint(type, BPF_MAP_TYPE_RINGBUF);
0651 } m_ringbuf SEC(".maps");
0652 
0653 static inline int check_ringbuf(void)
0654 {
0655     struct bpf_ringbuf_map *ringbuf = (struct bpf_ringbuf_map *)&m_ringbuf;
0656     struct bpf_map *map = (struct bpf_map *)&m_ringbuf;
0657 
0658     VERIFY(check(&ringbuf->map, map, 0, 0, page_size));
0659 
0660     return 1;
0661 }
0662 
0663 SEC("cgroup_skb/egress")
0664 int cg_skb(void *ctx)
0665 {
0666     VERIFY_TYPE(BPF_MAP_TYPE_HASH, check_hash);
0667     VERIFY_TYPE(BPF_MAP_TYPE_ARRAY, check_array);
0668     VERIFY_TYPE(BPF_MAP_TYPE_PROG_ARRAY, check_prog_array);
0669     VERIFY_TYPE(BPF_MAP_TYPE_PERF_EVENT_ARRAY, check_perf_event_array);
0670     VERIFY_TYPE(BPF_MAP_TYPE_PERCPU_HASH, check_percpu_hash);
0671     VERIFY_TYPE(BPF_MAP_TYPE_PERCPU_ARRAY, check_percpu_array);
0672     VERIFY_TYPE(BPF_MAP_TYPE_STACK_TRACE, check_stack_trace);
0673     VERIFY_TYPE(BPF_MAP_TYPE_CGROUP_ARRAY, check_cgroup_array);
0674     VERIFY_TYPE(BPF_MAP_TYPE_LRU_HASH, check_lru_hash);
0675     VERIFY_TYPE(BPF_MAP_TYPE_LRU_PERCPU_HASH, check_lru_percpu_hash);
0676     VERIFY_TYPE(BPF_MAP_TYPE_LPM_TRIE, check_lpm_trie);
0677     VERIFY_TYPE(BPF_MAP_TYPE_ARRAY_OF_MAPS, check_array_of_maps);
0678     VERIFY_TYPE(BPF_MAP_TYPE_HASH_OF_MAPS, check_hash_of_maps);
0679     VERIFY_TYPE(BPF_MAP_TYPE_DEVMAP, check_devmap);
0680     VERIFY_TYPE(BPF_MAP_TYPE_SOCKMAP, check_sockmap);
0681     VERIFY_TYPE(BPF_MAP_TYPE_CPUMAP, check_cpumap);
0682     VERIFY_TYPE(BPF_MAP_TYPE_XSKMAP, check_xskmap);
0683     VERIFY_TYPE(BPF_MAP_TYPE_SOCKHASH, check_sockhash);
0684     VERIFY_TYPE(BPF_MAP_TYPE_CGROUP_STORAGE, check_cgroup_storage);
0685     VERIFY_TYPE(BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
0686             check_reuseport_sockarray);
0687     VERIFY_TYPE(BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
0688             check_percpu_cgroup_storage);
0689     VERIFY_TYPE(BPF_MAP_TYPE_QUEUE, check_queue);
0690     VERIFY_TYPE(BPF_MAP_TYPE_STACK, check_stack);
0691     VERIFY_TYPE(BPF_MAP_TYPE_SK_STORAGE, check_sk_storage);
0692     VERIFY_TYPE(BPF_MAP_TYPE_DEVMAP_HASH, check_devmap_hash);
0693     VERIFY_TYPE(BPF_MAP_TYPE_RINGBUF, check_ringbuf);
0694 
0695     return 1;
0696 }
0697 
0698 char _license[] SEC("license") = "GPL";