blob: 82070eadfc070ffdadc4e729950ab7ae386dfab1 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Wang Nan8f9e05f2016-01-11 13:47:57 +00002#include <asm/unistd.h>
Wang Nan1b76c132015-07-01 02:13:51 +00003#include <linux/bpf.h>
Wang Nan8f9e05f2016-01-11 13:47:57 +00004#include <unistd.h>
5
6#ifndef __NR_bpf
7# if defined(__i386__)
8# define __NR_bpf 357
9# elif defined(__x86_64__)
10# define __NR_bpf 321
11# elif defined(__aarch64__)
12# define __NR_bpf 280
David S. Millerb0c47802017-04-22 12:31:05 -070013# elif defined(__sparc__)
14# define __NR_bpf 349
Daniel Borkmannbad19262017-08-04 14:20:55 +020015# elif defined(__s390__)
16# define __NR_bpf 351
David S. Millerb0c47802017-04-22 12:31:05 -070017# else
Wang Nan8f9e05f2016-01-11 13:47:57 +000018# error __NR_bpf not defined. libbpf does not support your arch.
19# endif
20#endif
Wang Nan1b76c132015-07-01 02:13:51 +000021
22int main(void)
23{
24 union bpf_attr attr;
25
Wang Nan8f9e05f2016-01-11 13:47:57 +000026 /* Check fields in attr */
Wang Nan1b76c132015-07-01 02:13:51 +000027 attr.prog_type = BPF_PROG_TYPE_KPROBE;
28 attr.insn_cnt = 0;
29 attr.insns = 0;
30 attr.license = 0;
31 attr.log_buf = 0;
32 attr.log_size = 0;
33 attr.log_level = 0;
34 attr.kern_version = 0;
David S. Millere07b98d2017-05-10 11:38:07 -070035 attr.prog_flags = 0;
Wang Nan1b76c132015-07-01 02:13:51 +000036
Wang Nan8f9e05f2016-01-11 13:47:57 +000037 /*
38 * Test existence of __NR_bpf and BPF_PROG_LOAD.
39 * This call should fail if we run the testcase.
40 */
Florian Fainelli1a714762016-04-24 19:34:54 -070041 return syscall(__NR_bpf, BPF_PROG_LOAD, &attr, sizeof(attr));
Wang Nan1b76c132015-07-01 02:13:51 +000042}