diff options
author | Alexei Starovoitov <ast@fb.com> | 2017-03-11 01:05:55 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-03-13 02:48:41 -0400 |
commit | 1da8ac7c49fb2879ba95006d8bd1095e6870ea1a (patch) | |
tree | 98d5fd4bdf9ea69d47039e52c11304c8a461121e | |
parent | 79099aab38c8f5c746748b066ae74ba984fe2cc8 (diff) |
selftests/bpf: fix broken build
Recent merge of 'linux-kselftest-4.11-rc1' tree broke bpf test build.
None of the tests were building and test_verifier.c had tons of compiler errors.
Fix it and add #ifdef CAP_IS_SUPPORTED to support old versions of libcap.
Tested on centos 6.8 and 7
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | tools/include/uapi/linux/bpf_perf_event.h | 18 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/Makefile | 4 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/test_verifier.c | 4 |
3 files changed, 25 insertions, 1 deletions
diff --git a/tools/include/uapi/linux/bpf_perf_event.h b/tools/include/uapi/linux/bpf_perf_event.h new file mode 100644 index 000000000000..067427259820 --- /dev/null +++ b/tools/include/uapi/linux/bpf_perf_event.h | |||
@@ -0,0 +1,18 @@ | |||
1 | /* Copyright (c) 2016 Facebook | ||
2 | * | ||
3 | * This program is free software; you can redistribute it and/or | ||
4 | * modify it under the terms of version 2 of the GNU General Public | ||
5 | * License as published by the Free Software Foundation. | ||
6 | */ | ||
7 | #ifndef _UAPI__LINUX_BPF_PERF_EVENT_H__ | ||
8 | #define _UAPI__LINUX_BPF_PERF_EVENT_H__ | ||
9 | |||
10 | #include <linux/types.h> | ||
11 | #include <linux/ptrace.h> | ||
12 | |||
13 | struct bpf_perf_event_data { | ||
14 | struct pt_regs regs; | ||
15 | __u64 sample_period; | ||
16 | }; | ||
17 | |||
18 | #endif /* _UAPI__LINUX_BPF_PERF_EVENT_H__ */ | ||
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 4b498265dae6..67531f47781b 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile | |||
@@ -1,12 +1,14 @@ | |||
1 | LIBDIR := ../../../lib | 1 | LIBDIR := ../../../lib |
2 | BPFOBJ := $(LIBDIR)/bpf/bpf.o | 2 | BPFOBJ := $(LIBDIR)/bpf/bpf.o |
3 | 3 | ||
4 | CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR) | 4 | CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR) $(BPFOBJ) |
5 | 5 | ||
6 | TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map | 6 | TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map |
7 | 7 | ||
8 | TEST_PROGS := test_kmod.sh | 8 | TEST_PROGS := test_kmod.sh |
9 | 9 | ||
10 | all: $(TEST_GEN_PROGS) | ||
11 | |||
10 | .PHONY: all clean force | 12 | .PHONY: all clean force |
11 | 13 | ||
12 | # force a rebuild of BPFOBJ when its dependencies are updated | 14 | # force a rebuild of BPFOBJ when its dependencies are updated |
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index e1f5b9eea1e8..d1555e4240c0 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * License as published by the Free Software Foundation. | 8 | * License as published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <asm/types.h> | ||
12 | #include <linux/types.h> | ||
11 | #include <stdint.h> | 13 | #include <stdint.h> |
12 | #include <stdio.h> | 14 | #include <stdio.h> |
13 | #include <stdlib.h> | 15 | #include <stdlib.h> |
@@ -4583,10 +4585,12 @@ static bool is_admin(void) | |||
4583 | cap_flag_value_t sysadmin = CAP_CLEAR; | 4585 | cap_flag_value_t sysadmin = CAP_CLEAR; |
4584 | const cap_value_t cap_val = CAP_SYS_ADMIN; | 4586 | const cap_value_t cap_val = CAP_SYS_ADMIN; |
4585 | 4587 | ||
4588 | #ifdef CAP_IS_SUPPORTED | ||
4586 | if (!CAP_IS_SUPPORTED(CAP_SETFCAP)) { | 4589 | if (!CAP_IS_SUPPORTED(CAP_SETFCAP)) { |
4587 | perror("cap_get_flag"); | 4590 | perror("cap_get_flag"); |
4588 | return false; | 4591 | return false; |
4589 | } | 4592 | } |
4593 | #endif | ||
4590 | caps = cap_get_proc(); | 4594 | caps = cap_get_proc(); |
4591 | if (!caps) { | 4595 | if (!caps) { |
4592 | perror("cap_get_proc"); | 4596 | perror("cap_get_proc"); |