xref: /openbmc/linux/tools/testing/selftests/bpf/progs/fexit_bpf2bpf_simple.c (revision 7b73a9c8e26ce5769c41d4b787767c10fe7269db)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2019 Facebook */
3 #include <linux/bpf.h>
4 #include "bpf_helpers.h"
5 #include "bpf_trace_helpers.h"
6 
7 struct sk_buff {
8 	unsigned int len;
9 };
10 
11 __u64 test_result = 0;
12 BPF_TRACE_2("fexit/test_pkt_md_access", test_main2,
13 	    struct sk_buff *, skb, int, ret)
14 {
15 	int len;
16 
17 	__builtin_preserve_access_index(({
18 		len = skb->len;
19 	}));
20 	if (len != 74 || ret != 0)
21 		return 0;
22 
23 	test_result = 1;
24 	return 0;
25 }
26 char _license[] SEC("license") = "GPL";
27