Skip to content

Commit 1da8ac7

Browse files
4astdavem330
authored andcommitted
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 <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Tested-by: Daniel Borkmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 79099aa commit 1da8ac7

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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__ */

tools/testing/selftests/bpf/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
LIBDIR := ../../../lib
22
BPFOBJ := $(LIBDIR)/bpf/bpf.o
33

4-
CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR)
4+
CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR) $(BPFOBJ)
55

66
TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map
77

88
TEST_PROGS := test_kmod.sh
99

10+
all: $(TEST_GEN_PROGS)
11+
1012
.PHONY: all clean force
1113

1214
# force a rebuild of BPFOBJ when its dependencies are updated

tools/testing/selftests/bpf/test_verifier.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* License as published by the Free Software Foundation.
99
*/
1010

11+
#include <asm/types.h>
12+
#include <linux/types.h>
1113
#include <stdint.h>
1214
#include <stdio.h>
1315
#include <stdlib.h>
@@ -4583,10 +4585,12 @@ static bool is_admin(void)
45834585
cap_flag_value_t sysadmin = CAP_CLEAR;
45844586
const cap_value_t cap_val = CAP_SYS_ADMIN;
45854587

4588+
#ifdef CAP_IS_SUPPORTED
45864589
if (!CAP_IS_SUPPORTED(CAP_SETFCAP)) {
45874590
perror("cap_get_flag");
45884591
return false;
45894592
}
4593+
#endif
45904594
caps = cap_get_proc();
45914595
if (!caps) {
45924596
perror("cap_get_proc");

0 commit comments

Comments
 (0)