2021-08-28 21:05:57 +03:00
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
// eBPF program for testing utility general helper functions.
|
|
|
|
|
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
|
|
|
#include "bpf_helpers.h"
|
2021-08-28 21:05:57 +03:00
|
|
|
#include "ebpf_nethooks.h"
|
2021-09-03 03:23:16 +03:00
|
|
|
#include "sample_common_routines.h"
|
2021-08-28 21:05:57 +03:00
|
|
|
#include "sample_test_common.h"
|
|
|
|
|
|
|
|
#define VALUE_SIZE 32
|
|
|
|
|
2021-08-31 05:14:08 +03:00
|
|
|
SEC("maps")
|
|
|
|
struct bpf_map utility_map = {
|
|
|
|
.size = sizeof(struct bpf_map),
|
2021-08-28 21:05:57 +03:00
|
|
|
.type = BPF_MAP_TYPE_ARRAY,
|
|
|
|
.key_size = sizeof(uint32_t),
|
|
|
|
.value_size = sizeof(ebpf_utility_helpers_data_t),
|
|
|
|
.max_entries = UTILITY_MAP_SIZE};
|
|
|
|
|
2021-08-31 05:14:08 +03:00
|
|
|
SEC("xdp")
|
2021-08-28 21:05:57 +03:00
|
|
|
int
|
2021-09-03 03:23:16 +03:00
|
|
|
test_utility_helpers(xdp_md_t* context)
|
2021-08-28 21:05:57 +03:00
|
|
|
{
|
2021-09-03 03:23:16 +03:00
|
|
|
return test_utility_helper_functions(&utility_map);
|
2021-08-28 21:05:57 +03:00
|
|
|
}
|