1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (c) 2021 Facebook */ 3#include "vmlinux.h" 4#include <bpf/bpf_helpers.h> 5#include <bpf/bpf_tracing.h> 6 7#if __has_attribute(btf_decl_tag) 8#define __tag1 __attribute__((btf_decl_tag("tag1"))) 9#define __tag2 __attribute__((btf_decl_tag("tag2"))) 10volatile const bool skip_tests __tag1 __tag2 = false; 11#else 12#define __tag1 13#define __tag2 14volatile const bool skip_tests = true; 15#endif 16 17struct key_t { 18 int a; 19 int b __tag1 __tag2; 20 int c; 21} __tag1 __tag2; 22 23typedef struct { 24 int a; 25 int b; 26} value_t __tag1 __tag2; 27 28struct { 29 __uint(type, BPF_MAP_TYPE_HASH); 30 __uint(max_entries, 3); 31 __type(key, struct key_t); 32 __type(value, value_t); 33} hashmap1 SEC(".maps"); 34 35 36static __noinline int foo(int x __tag1 __tag2) __tag1 __tag2 37{ 38 struct key_t key; 39 value_t val = {}; 40 41 key.a = key.b = key.c = x; 42 bpf_map_update_elem(&hashmap1, &key, &val, 0); 43 return 0; 44} 45 46SEC("fentry/bpf_fentry_test1") 47int BPF_PROG(sub, int x) 48{ 49 return foo(x); 50} 51