--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+Name: libbpf
+Summary: Libbpf library
+Version: 0.2.0
+Release: 1
+Group: System/Network
+License: LGPL-2.1+ or BSD-2-Clause
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: pkgconfig(libelf)
+BuildRequires: cmake
+
+# This package supersedes libbpf from kernel-tools,
+# which has default Epoch: 0. By having Epoch: > 0
+# this libbpf will take over smoothly
+Epoch: 2
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+A mirror of bpf-next linux tree bpf-next/tools/lib/bpf directory plus its
+supporting header files. The version of the package reflects the version of
+ABI.
+
+%package devel
+Summary: Development files for %{name}
+Requires: %{name} = 2:%{version}-%{release}
+Requires: kernel-headers >= 5.14.0
+Requires: zlib
+
+%description devel
+The %{name}-devel package contains libraries header files for
+developing applications that use %{name}
+
+%package static
+Summary: Static library for libbpf development
+Requires: %{name}-devel = 2:%{version}-%{release}
+
+%description static
+The %{name}-static package contains static library for
+developing applications that use %{name}
+
+%prep
+%setup -q
+
+%build
+%ifarch aarch64
+make -C ./src __aarch64__=1
+%else
+make -C ./src __arm__=1
+%endif
+
+%install
+make -C ./src install DESTDIR=%{buildroot} INSTALL_DIR=%{buildroot}
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+%license LICENSE LICENSE.BSD-2-Clause LICENSE.LGPL-2.1
+%{_libdir}/libbpf.so.%{version}
+%{_libdir}/libbpf.so.0
+
+%files devel
+%{_libdir}/libbpf.so
+%{_includedir}/bpf/
+%{_libdir}/pkgconfig/libbpf.pc
+
+%files static
+%{_libdir}/libbpf.a
LIBBPF_VERSION := $(shell \
grep -oE '^LIBBPF_([0-9.]+)' libbpf.map | \
- sort -rV | head -n1 | cut -d'_' -f2)
+ sort -r | head -n1 | cut -d'_' -f2)
LIBBPF_MAJOR_VERSION := $(firstword $(subst ., ,$(LIBBPF_VERSION)))
TOPDIR = ..
DESTDIR ?=
-ifeq ($(shell uname -m),x86_64)
+ifeq ($(shell uname -m),aarch64)
LIBSUBDIR := lib64
else
LIBSUBDIR := lib
# define __NR_bpf 351
# elif defined(__arc__)
# define __NR_bpf 280
+# elif defined(__arm__)
+# define __NR_BPF_OABI_SYSCALL_BASE 0x900000
+# if defined(__thumb__) || defined(__ARM_EABI__)
+# define __NR_BPF_SYSCALL_BASE 0
+# else
+# define __NR_BPF_SYSCALL_BASE __NR_BPF_OABI_SYSCALL_BASE
+# endif
+# define __NR_bpf (__NR_BPF_SYSCALL_BASE+386)
# else
# error __NR_bpf not defined. libbpf does not support your arch.
# endif
#define __printf(a, b) __attribute__((format(printf, a, b)))
+#ifndef PERF_EVENT_IOC_SET_BPF
+# define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32)
+#endif
+
+#ifndef PERF_FLAG_FD_CLOEXEC
+# define PERF_FLAG_FD_CLOEXEC (1UL << 3) /* O_CLOEXEC */
+#endif
+
+#ifndef PERF_COUNT_SW_BPF_OUTPUT
+# define PERF_COUNT_SW_BPF_OUTPUT 10
+#endif
+
static struct bpf_map *bpf_object__add_map(struct bpf_object *obj);
static const struct btf_type *
skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id);