Rename ebpf_helpers.h to bpf_helpers.h for cross-plat compat (#472)
Libbpf has bpf_helpers.h which is mostly platform-agnostic, and
bpf_helper_defs.h which is platform-specific but is included
by bpf_helpers.h. Until libbpf is made more platform-agnostic
(issue #351), the workaround is to have a separate pair of files.
Our bpf_helpers.h and our own bpf_helper_defs.h, both of which
would ideally be merged into libbpf's in the future.
Platform-specific defines are in ebpf_struct.h, though that
name may need to change later on. Linux uses "linux/bpf.h"
(e.g., as used in the https://docs.cilium.io/en/v1.8/bpf/ and
https://developers.redhat.com/blog/2021/04/01/get-started-with-xdp
articles) or "vmlinux.h" (e.g., as used in the
https://ruderich.org/simon/notes/xdp-minimal-example article),
and these filenames are hard coded in eBPF programs. In the future,
we should probably settle on a cross-platform name and use include
paths to distinguish them, as opposed to requiring ifdefs in eBPF
programs. However, all of that is part of issue 351 and not this
issue.
Also removed obsolete/unused "repro.c" from tests/samples
Fixes #426
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-09-02 02:30:33 +03:00
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// On Linux, including the bpf_helpers.h in libbpf must be done after including
|
|
|
|
// a platform-specific include file such as vmlinux.h or linux/types.h which makes
|
|
|
|
// it not quite platform-agnostic today. We hope this to change in the future
|
|
|
|
// once libbpf itself becomes cross-platform (issue #351). In the meantime,
|
|
|
|
// this version of bpf_helpers.h is already cross-platform.
|
|
|
|
|
|
|
|
// Include platform-specific definitions.
|
|
|
|
#include "ebpf_structs.h"
|
|
|
|
#include "bpf_helpers_platform.h"
|
|
|
|
|
|
|
|
// If we're compiling an actual eBPF program, then include
|
|
|
|
// libbpf's bpf_helpers.h for the rest of the platform-agnostic
|
|
|
|
// defines.
|
|
|
|
#ifndef _MSC_VER
|
2022-04-25 20:26:56 +03:00
|
|
|
#include "libbpf/src/bpf_helpers.h"
|
2022-04-08 04:53:21 +03:00
|
|
|
#define bpf_map_def _ebpf_map_definition_in_file
|
|
|
|
#include "ebpf_nethooks.h"
|
Rename ebpf_helpers.h to bpf_helpers.h for cross-plat compat (#472)
Libbpf has bpf_helpers.h which is mostly platform-agnostic, and
bpf_helper_defs.h which is platform-specific but is included
by bpf_helpers.h. Until libbpf is made more platform-agnostic
(issue #351), the workaround is to have a separate pair of files.
Our bpf_helpers.h and our own bpf_helper_defs.h, both of which
would ideally be merged into libbpf's in the future.
Platform-specific defines are in ebpf_struct.h, though that
name may need to change later on. Linux uses "linux/bpf.h"
(e.g., as used in the https://docs.cilium.io/en/v1.8/bpf/ and
https://developers.redhat.com/blog/2021/04/01/get-started-with-xdp
articles) or "vmlinux.h" (e.g., as used in the
https://ruderich.org/simon/notes/xdp-minimal-example article),
and these filenames are hard coded in eBPF programs. In the future,
we should probably settle on a cross-platform name and use include
paths to distinguish them, as opposed to requiring ifdefs in eBPF
programs. However, all of that is part of issue 351 and not this
issue.
Also removed obsolete/unused "repro.c" from tests/samples
Fixes #426
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
Co-authored-by: Alan Jowett <alanjo@microsoft.com>
2021-09-02 02:30:33 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __doxygen
|
|
|
|
#define EBPF_HELPER(return_type, name, args) typedef return_type(*name##_t) args
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "bpf_helper_defs.h"
|
|
|
|
|
|
|
|
#define MAX_TAIL_CALL_CNT 32
|