Commit 1da8ac7c authored by Alexei Starovoitov's avatar Alexei Starovoitov Committed by David S. Miller

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: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Tested-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 79099aab
/* Copyright (c) 2016 Facebook
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*/
#ifndef _UAPI__LINUX_BPF_PERF_EVENT_H__
#define _UAPI__LINUX_BPF_PERF_EVENT_H__
#include <linux/types.h>
#include <linux/ptrace.h>
struct bpf_perf_event_data {
struct pt_regs regs;
__u64 sample_period;
};
#endif /* _UAPI__LINUX_BPF_PERF_EVENT_H__ */
LIBDIR := ../../../lib LIBDIR := ../../../lib
BPFOBJ := $(LIBDIR)/bpf/bpf.o BPFOBJ := $(LIBDIR)/bpf/bpf.o
CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR) CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR) $(BPFOBJ)
TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map
TEST_PROGS := test_kmod.sh TEST_PROGS := test_kmod.sh
all: $(TEST_GEN_PROGS)
.PHONY: all clean force .PHONY: all clean force
# force a rebuild of BPFOBJ when its dependencies are updated # force a rebuild of BPFOBJ when its dependencies are updated
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
* License as published by the Free Software Foundation. * License as published by the Free Software Foundation.
*/ */
#include <asm/types.h>
#include <linux/types.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -4583,10 +4585,12 @@ static bool is_admin(void) ...@@ -4583,10 +4585,12 @@ static bool is_admin(void)
cap_flag_value_t sysadmin = CAP_CLEAR; cap_flag_value_t sysadmin = CAP_CLEAR;
const cap_value_t cap_val = CAP_SYS_ADMIN; const cap_value_t cap_val = CAP_SYS_ADMIN;
#ifdef CAP_IS_SUPPORTED
if (!CAP_IS_SUPPORTED(CAP_SETFCAP)) { if (!CAP_IS_SUPPORTED(CAP_SETFCAP)) {
perror("cap_get_flag"); perror("cap_get_flag");
return false; return false;
} }
#endif
caps = cap_get_proc(); caps = cap_get_proc();
if (!caps) { if (!caps) {
perror("cap_get_proc"); perror("cap_get_proc");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment