Include required Clang version (#431)

* Update Getting Started to recommend current release version of Clang/LLVM

Clang-format behaves differently depending on the version of Clang installed.
Update getting started guide to recommend Clang / LLVM 10.0.0.
Update the development guide to indicate that Clang 10 or higher is required for consistent formatting.
Reformat all code using Clang 10.0.0

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
This commit is contained in:
Alan Jowett 2021-08-25 09:01:16 -06:00 коммит произвёл GitHub
Родитель c9d40f09c4
Коммит 4be43a7ea1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
26 изменённых файлов: 151 добавлений и 122 удалений

Просмотреть файл

@ -80,6 +80,8 @@ the default Visual Studio style. See [clang-format style options](
http://releases.llvm.org/3.6.0/tools/clang/docs/ClangFormatStyleOptions.html)
for details.
If you see unexpected formatting changes in the code, verify that you are running version 10 or higher of the LLVM tool-chain.
### License Header
The following license header **must** be included at the top of every code file:

Просмотреть файл

@ -10,7 +10,7 @@ The following must be installed in order to build this project:
which must be selected as an Individual component in the VS installer
3. [Visual Studio Build Tools 2019](https://aka.ms/vs/16/release/vs_buildtools.exe)
4. [WDK for Windows 10, version 2004](https://go.microsoft.com/fwlink/?linkid=2128854)
5. [Clang/LLVM for Windows 64-bit](https://github.com/llvm/llvm-project/releases/download/llvmorg-8.0.1/LLVM-8.0.1-win64.exe)
5. [Clang for Windows 64-bit version 10.0.0](https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/LLVM-10.0.0-win64.exe) or [The latest release of Clang for Windows 64-bit](https://github.com/llvm/llvm-project/releases/latest)
6. [nuget.exe](https://www.nuget.org/downloads)
## How to clone and build the project

Просмотреть файл

@ -27,8 +27,8 @@ service_install();
int __cdecl wmain(ULONG argc, PWSTR* argv)
{
SERVICE_TABLE_ENTRY dispatch_table[] = {{(PWSTR)SERVICE_NAME, (LPSERVICE_MAIN_FUNCTION)service_main},
{nullptr, nullptr}};
SERVICE_TABLE_ENTRY dispatch_table[] = {
{(PWSTR)SERVICE_NAME, (LPSERVICE_MAIN_FUNCTION)service_main}, {nullptr, nullptr}};
// If command-line parameter is "install", install the service.
// Otherwise, the service is probably being started by the SCM.

Просмотреть файл

@ -94,7 +94,7 @@ extern "C"
// The requested key is already present.
EBPF_KEY_ALREADY_EXISTS,
/// Caller has reached tail call limit.
EBPF_NO_MORE_TAIL_CALLS,
} ebpf_result_t;

Просмотреть файл

@ -348,11 +348,12 @@ ebpf_api_elf_enumerate_sections(
}
}
sequence.emplace_back(tlv_pack<tlv_sequence>({tlv_pack(raw_program.section.c_str()),
tlv_pack(raw_program.info.type.name.c_str()),
tlv_pack(raw_program.info.map_descriptors.size()),
tlv_pack(convert_ebpf_program_to_bytes(raw_program.prog)),
tlv_pack(stats_sequence)}));
sequence.emplace_back(tlv_pack<tlv_sequence>(
{tlv_pack(raw_program.section.c_str()),
tlv_pack(raw_program.info.type.name.c_str()),
tlv_pack(raw_program.info.map_descriptors.size()),
tlv_pack(convert_ebpf_program_to_bytes(raw_program.prog)),
tlv_pack(stats_sequence)}));
}
auto retval = tlv_pack(sequence);

Просмотреть файл

@ -1072,9 +1072,10 @@ ebpf_get_next_program(fd_t previous_fd, _Out_ fd_t* next_fd)
*next_fd = ebpf_fd_invalid;
ebpf_handle_t previous_handle = _get_handle_from_fd(local_fd);
ebpf_operation_get_next_program_request_t request{sizeof(request),
ebpf_operation_id_t::EBPF_OPERATION_GET_NEXT_PROGRAM,
reinterpret_cast<uint64_t>(previous_handle)};
ebpf_operation_get_next_program_request_t request{
sizeof(request),
ebpf_operation_id_t::EBPF_OPERATION_GET_NEXT_PROGRAM,
reinterpret_cast<uint64_t>(previous_handle)};
ebpf_operation_get_next_program_reply_t reply;
@ -1171,10 +1172,11 @@ ebpf_program_query_info(
uint32_t
ebpf_api_link_program(ebpf_handle_t program_handle, ebpf_attach_type_t attach_type, ebpf_handle_t* link_handle)
{
ebpf_operation_link_program_request_t request = {EBPF_OFFSET_OF(ebpf_operation_link_program_request_t, data),
EBPF_OPERATION_LINK_PROGRAM,
reinterpret_cast<uint64_t>(program_handle),
attach_type};
ebpf_operation_link_program_request_t request = {
EBPF_OFFSET_OF(ebpf_operation_link_program_request_t, data),
EBPF_OPERATION_LINK_PROGRAM,
reinterpret_cast<uint64_t>(program_handle),
attach_type};
ebpf_operation_link_program_reply_t reply;
uint32_t retval = invoke_ioctl(request, reply);

Просмотреть файл

@ -62,18 +62,19 @@ parse_maps_section_windows(
std::vector<ebpf_map_definition_t>((ebpf_map_definition_t*)data, (ebpf_map_definition_t*)(data + size));
for (int i = 0; i < mapdefs.size(); i++) {
auto& s = mapdefs[i];
map_descriptors.emplace_back(EbpfMapDescriptor{.original_fd = create_map_windows(
s.type,
s.key_size,
s.value_size,
s.max_entries,
s.inner_map_idx,
(i * sizeof(ebpf_map_definition_t)),
options),
.type = (uint32_t)s.type,
.key_size = s.key_size,
.value_size = s.value_size,
.inner_map_fd = s.inner_map_idx});
map_descriptors.emplace_back(EbpfMapDescriptor{
.original_fd = create_map_windows(
s.type,
s.key_size,
s.value_size,
s.max_entries,
s.inner_map_idx,
(i * sizeof(ebpf_map_definition_t)),
options),
.type = (uint32_t)s.type,
.key_size = s.key_size,
.value_size = s.value_size,
.inner_map_fd = s.inner_map_idx});
}
for (size_t i = 0; i < mapdefs.size(); i++) {
unsigned int inner = mapdefs[i].inner_map_idx;

Просмотреть файл

@ -34,8 +34,9 @@ allocate_string(const std::string& string, uint32_t* length) noexcept
std::vector<uint8_t>
convert_ebpf_program_to_bytes(const std::vector<ebpf_inst>& instructions)
{
return {reinterpret_cast<const uint8_t*>(instructions.data()),
reinterpret_cast<const uint8_t*>(instructions.data()) + instructions.size() * sizeof(ebpf_inst)};
return {
reinterpret_cast<const uint8_t*>(instructions.data()),
reinterpret_cast<const uint8_t*>(instructions.data()) + instructions.size() * sizeof(ebpf_inst)};
}
int

Просмотреть файл

@ -29,10 +29,11 @@
// the preprocessor treat a prefix list as one macro argument.
#define COMMA ,
const ebpf_context_descriptor_t g_xdp_context_descriptor = {sizeof(xdp_md_t),
EBPF_OFFSET_OF(xdp_md_t, data),
EBPF_OFFSET_OF(xdp_md_t, data_end),
EBPF_OFFSET_OF(xdp_md_t, data_meta)};
const ebpf_context_descriptor_t g_xdp_context_descriptor = {
sizeof(xdp_md_t),
EBPF_OFFSET_OF(xdp_md_t, data),
EBPF_OFFSET_OF(xdp_md_t, data_end),
EBPF_OFFSET_OF(xdp_md_t, data_meta)};
const EbpfProgramType windows_xdp_program_type =
PTYPE("xdp", &g_xdp_context_descriptor, (uint64_t)&EBPF_PROGRAM_TYPE_XDP, {"xdp"});
@ -53,10 +54,11 @@ const ebpf_context_descriptor_t g_sample_ext_context_descriptor = {
const EbpfProgramType windows_sample_ext_program_type =
PTYPE("sample_ext", &g_sample_ext_context_descriptor, (uint64_t)&EBPF_PROGRAM_TYPE_SAMPLE, {"sample_ext"});
const std::vector<EbpfProgramType> windows_program_types = {PTYPE("unspecified", {0}, 0, {}),
windows_xdp_program_type,
windows_bind_program_type,
windows_sample_ext_program_type};
const std::vector<EbpfProgramType> windows_program_types = {
PTYPE("unspecified", {0}, 0, {}),
windows_xdp_program_type,
windows_bind_program_type,
windows_sample_ext_program_type};
const std::map<ebpf_program_type_t*, ebpf_attach_type_t*> windows_program_type_to_attach_type = {
{&EBPF_PROGRAM_TYPE_XDP, &EBPF_ATTACH_TYPE_XDP},

Просмотреть файл

@ -112,11 +112,12 @@ handle_ebpf_add_program(
UNREFERENCED_PARAMETER(data);
UNREFERENCED_PARAMETER(done);
TAG_TYPE tags[] = {{TOKEN_FILENAME, NS_REQ_PRESENT, FALSE},
{TOKEN_SECTION, NS_REQ_PRESENT, FALSE},
{TOKEN_TYPE, NS_REQ_ZERO, FALSE},
{TOKEN_PINNED, NS_REQ_ZERO, FALSE},
{TOKEN_EXECUTION, NS_REQ_ZERO, FALSE}};
TAG_TYPE tags[] = {
{TOKEN_FILENAME, NS_REQ_PRESENT, FALSE},
{TOKEN_SECTION, NS_REQ_PRESENT, FALSE},
{TOKEN_TYPE, NS_REQ_ZERO, FALSE},
{TOKEN_PINNED, NS_REQ_ZERO, FALSE},
{TOKEN_EXECUTION, NS_REQ_ZERO, FALSE}};
ULONG tag_type[_countof(tags)] = {0};
ULONG status =

Просмотреть файл

@ -193,8 +193,8 @@ TEST_CASE("program", "[execution_context]")
ebpf_result_t (*function_pointer1)() = provider_function1;
uint32_t test_function_ids[] = {(EBPF_MAX_GENERAL_HELPER_FUNCTION + 1)};
const void* helper_functions[] = {(void*)function_pointer1};
ebpf_helper_function_addresses_t helper_function_addresses = {EBPF_COUNT_OF(helper_functions),
(uint64_t*)helper_functions};
ebpf_helper_function_addresses_t helper_function_addresses = {
EBPF_COUNT_OF(helper_functions), (uint64_t*)helper_functions};
REQUIRE(ebpf_allocate_trampoline_table(1, &table) == EBPF_SUCCESS);
REQUIRE(

Просмотреть файл

@ -74,10 +74,13 @@ TEST_CASE("hash_table_test", "[platform]")
// Insert first
REQUIRE(
ebpf_hash_table_update(table, key_1.data(), data_1.data(), nullptr, EBPF_HASH_TABLE_OPERATION_INSERT) == EBPF_SUCCESS);
ebpf_hash_table_update(table, key_1.data(), data_1.data(), nullptr, EBPF_HASH_TABLE_OPERATION_INSERT) ==
EBPF_SUCCESS);
// Insert second
REQUIRE(ebpf_hash_table_update(table, key_2.data(), data_2.data(), nullptr, EBPF_HASH_TABLE_OPERATION_ANY) == EBPF_SUCCESS);
REQUIRE(
ebpf_hash_table_update(table, key_2.data(), data_2.data(), nullptr, EBPF_HASH_TABLE_OPERATION_ANY) ==
EBPF_SUCCESS);
// Find the first
REQUIRE(ebpf_hash_table_find(table, key_1.data(), &returned_value) == EBPF_SUCCESS);
@ -90,7 +93,8 @@ TEST_CASE("hash_table_test", "[platform]")
// Replace
memset(data_1.data(), '0x55', data_1.size());
REQUIRE(
ebpf_hash_table_update(table, key_1.data(), data_1.data(), nullptr, EBPF_HASH_TABLE_OPERATION_REPLACE) == EBPF_SUCCESS);
ebpf_hash_table_update(table, key_1.data(), data_1.data(), nullptr, EBPF_HASH_TABLE_OPERATION_REPLACE) ==
EBPF_SUCCESS);
// Find the first
REQUIRE(ebpf_hash_table_find(table, key_1.data(), &returned_value) == EBPF_SUCCESS);
@ -346,8 +350,8 @@ TEST_CASE("trampoline_test", "[platform]")
auto provider_function2 = []() { return EBPF_OBJECT_ALREADY_EXISTS; };
ebpf_result_t (*function_pointer2)() = provider_function2;
const void* helper_functions2[] = {(void*)function_pointer2};
ebpf_helper_function_addresses_t helper_function_addresses2 = {EBPF_COUNT_OF(helper_functions1),
(uint64_t*)helper_functions2};
ebpf_helper_function_addresses_t helper_function_addresses2 = {
EBPF_COUNT_OF(helper_functions1), (uint64_t*)helper_functions2};
REQUIRE(ebpf_allocate_trampoline_table(1, &table) == EBPF_SUCCESS);
REQUIRE(
@ -396,10 +400,11 @@ TEST_CASE("program_type_info", "[platform]")
{
_test_helper test_helper;
ebpf_context_descriptor_t context_descriptor{sizeof(xdp_md_t),
EBPF_OFFSET_OF(xdp_md_t, data),
EBPF_OFFSET_OF(xdp_md_t, data_end),
EBPF_OFFSET_OF(xdp_md_t, data_meta)};
ebpf_context_descriptor_t context_descriptor{
sizeof(xdp_md_t),
EBPF_OFFSET_OF(xdp_md_t, data),
EBPF_OFFSET_OF(xdp_md_t, data_end),
EBPF_OFFSET_OF(xdp_md_t, data_meta)};
ebpf_program_type_descriptor_t program_type{"xdp", &context_descriptor};
ebpf_program_info_t program_info{program_type, _countof(_helper_functions), _helper_functions};
ebpf_program_info_t* new_program_info = nullptr;

Просмотреть файл

@ -51,8 +51,8 @@ verify_byte_code(
uint32_t* error_message_size)
{
const ebpf_platform_t* platform = &g_ebpf_platform_windows_service;
std::vector<ebpf_inst> instructions{(ebpf_inst*)byte_code,
(ebpf_inst*)byte_code + byte_code_size / sizeof(ebpf_inst)};
std::vector<ebpf_inst> instructions{
(ebpf_inst*)byte_code, (ebpf_inst*)byte_code + byte_code_size / sizeof(ebpf_inst)};
program_info info{platform};
std::string section;
std::string file;

Просмотреть файл

@ -70,8 +70,9 @@ import "wtypes.idl";
[ out, ref ] uint32_t * logs_size,
[ out, size_is(, *logs_size), ref ] char** logs);
ebpf_result_t verify_program(
[ in, ref ] ebpf_program_verify_info * info,
[out] uint32_t * logs_size,
[ out, size_is(, *logs_size), ref ] char** logs);
ebpf_result_t verify_program([ in, ref ] ebpf_program_verify_info * info, [out] uint32_t * logs_size, [
out,
size_is(, *logs_size),
ref
] char** logs);
}

Просмотреть файл

@ -174,7 +174,7 @@ check_clang-format()
cf="clang-format"
fi
local required_cfver='7.0.1'
local required_cfver='10.0.0'
# shellcheck disable=SC2155
local cfver=$(${cf} --version | grep -o -E '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
check_version "${required_cfver}" "${cfver}"

Просмотреть файл

@ -250,7 +250,7 @@ function check_clang-format()
# Windows does not have a clang-format-7 executable
$required_cfver='7.0.0'
$required_cfver='10.0.01'
try {
$cfver=(( Invoke-Expression "clang-format --version" 2> $null ) -split " ")[2]

Просмотреть файл

@ -16,17 +16,19 @@ typedef struct _process_entry
} process_entry_t;
#pragma clang section data = "maps"
ebpf_map_definition_t process_map = {.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_HASH,
.key_size = sizeof(uint64_t),
.value_size = sizeof(process_entry_t),
.max_entries = 1024};
ebpf_map_definition_t process_map = {
.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_HASH,
.key_size = sizeof(uint64_t),
.value_size = sizeof(process_entry_t),
.max_entries = 1024};
ebpf_map_definition_t limits_map = {.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint32_t),
.max_entries = 1};
ebpf_map_definition_t limits_map = {
.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint32_t),
.max_entries = 1};
inline process_entry_t*
find_or_create_process_entry(bind_md_t* ctx)

Просмотреть файл

@ -10,11 +10,12 @@
#include "ebpf_helpers.h"
#pragma clang section data = "maps"
ebpf_map_definition_t test_map = {.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint32_t),
.max_entries = 1};
ebpf_map_definition_t test_map = {
.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint32_t),
.max_entries = 1};
#pragma clang section text = "xdp"
uint32_t

Просмотреть файл

@ -10,11 +10,12 @@
#include "ebpf_helpers.h"
#pragma clang section data = "maps"
ebpf_map_definition_t port_map = {.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint64_t),
.max_entries = 1};
ebpf_map_definition_t port_map = {
.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint64_t),
.max_entries = 1};
#pragma clang section text = "xdp"
int

Просмотреть файл

@ -10,11 +10,12 @@
#include "ebpf_helpers.h"
#pragma clang section data = "maps"
ebpf_map_definition_t port_map = {.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint64_t),
.max_entries = 1};
ebpf_map_definition_t port_map = {
.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint64_t),
.max_entries = 1};
#pragma clang section text = "xdp"
int

Просмотреть файл

@ -22,10 +22,11 @@
// f788ef4a-207d-4dc3-85cf-0f2ea107213c
DEFINE_GUID(EBPF_PROGRAM_TYPE_SAMPLE, 0xf788ef4a, 0x207d, 0x4dc3, 0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c);
static ebpf_context_descriptor_t _sample_ebpf_context_descriptor = {sizeof(test_program_context_t),
EBPF_OFFSET_OF(test_program_context_t, data_start),
EBPF_OFFSET_OF(test_program_context_t, data_end),
-1};
static ebpf_context_descriptor_t _sample_ebpf_context_descriptor = {
sizeof(test_program_context_t),
EBPF_OFFSET_OF(test_program_context_t, data_start),
EBPF_OFFSET_OF(test_program_context_t, data_end),
-1};
// Test Extension Helper function prototype descriptors.
static ebpf_helper_function_prototype_t _sample_ebpf_extension_helper_function_prototype[] = {
@ -63,9 +64,10 @@ static int64_t
_sample_ebpf_extension_replace(
_In_ const void* buffer, uint32_t size, int64_t position, _In_ const void* replace, uint32_t arg_size);
static const void* _sample_ebpf_extension_helpers[] = {(void*)&_sample_ebpf_extension_helper_function1,
(void*)&_sample_ebpf_extension_find,
(void*)&_sample_ebpf_extension_replace};
static const void* _sample_ebpf_extension_helpers[] = {
(void*)&_sample_ebpf_extension_helper_function1,
(void*)&_sample_ebpf_extension_find,
(void*)&_sample_ebpf_extension_replace};
static ebpf_helper_function_addresses_t _sample_ebpf_extension_helper_function_address_table = {
EBPF_COUNT_OF(_sample_ebpf_extension_helpers), (uint64_t*)_sample_ebpf_extension_helpers};
@ -201,9 +203,10 @@ _sample_ebpf_extension_hook_provider_detach_client(_In_ void* provider_binding_c
// Test eBPF extension Hook NPI provider characteristics
ebpf_attach_provider_data_t _sample_ebpf_extension_attach_provider_data;
ebpf_extension_data_t _sample_ebpf_extension_hook_provider_data = {EBPF_ATTACH_PROVIDER_DATA_VERSION,
sizeof(_sample_ebpf_extension_attach_provider_data),
&_sample_ebpf_extension_attach_provider_data};
ebpf_extension_data_t _sample_ebpf_extension_hook_provider_data = {
EBPF_ATTACH_PROVIDER_DATA_VERSION,
sizeof(_sample_ebpf_extension_attach_provider_data),
&_sample_ebpf_extension_attach_provider_data};
const NPI_PROVIDER_CHARACTERISTICS _sample_ebpf_extension_hook_provider_characteristics = {
0,

Просмотреть файл

@ -7,12 +7,13 @@ typedef unsigned int uint32_t;
typedef unsigned long uint64_t;
SEC("maps")
struct bpf_map outer_map = {.type = BPF_MAP_TYPE_ARRAY_OF_MAPS,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint32_t),
.max_entries = 1,
// inner_map_idx refers to the map index in the same ELF object.
.inner_map_idx = 1}; // (uint32_t)&inner_map
struct bpf_map outer_map = {
.type = BPF_MAP_TYPE_ARRAY_OF_MAPS,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint32_t),
.max_entries = 1,
// inner_map_idx refers to the map index in the same ELF object.
.inner_map_idx = 1}; // (uint32_t)&inner_map
SEC("maps")
struct bpf_map inner_map = {

Просмотреть файл

@ -21,11 +21,12 @@ typedef unsigned char uint8_t;
#include "ebpf_helpers.h"
#pragma clang section data = "maps"
ebpf_map_definition_t test_map = {.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_HASH,
.key_size = sizeof(uint64_t),
.value_size = sizeof(uint64_t),
.max_entries = 1};
ebpf_map_definition_t test_map = {
.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_HASH,
.key_size = sizeof(uint64_t),
.value_size = sizeof(uint64_t),
.max_entries = 1};
#pragma clang section text = "bind"
int

Просмотреть файл

@ -7,11 +7,12 @@
#include "ebpf_helpers.h"
#include "ebpf_nethooks.h"
__attribute__((section("maps"), used)) struct bpf_map outer_map = {.size = sizeof(struct bpf_map),
.type = BPF_MAP_TYPE_ARRAY_OF_MAPS,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint32_t),
.max_entries = 1};
__attribute__((section("maps"), used)) struct bpf_map outer_map = {
.size = sizeof(struct bpf_map),
.type = BPF_MAP_TYPE_ARRAY_OF_MAPS,
.key_size = sizeof(uint32_t),
.value_size = sizeof(uint32_t),
.max_entries = 1};
__attribute__((section("xdp_prog"), used)) int
caller(struct xdp_md* ctx)

Просмотреть файл

@ -10,11 +10,12 @@
#define VALUE_SIZE 32
#pragma clang section data = "maps"
ebpf_map_definition_t test_map = {.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(uint32_t),
.value_size = VALUE_SIZE,
.max_entries = 2};
ebpf_map_definition_t test_map = {
.size = sizeof(ebpf_map_definition_t),
.type = BPF_MAP_TYPE_ARRAY,
.key_size = sizeof(uint32_t),
.value_size = VALUE_SIZE,
.max_entries = 2};
#pragma clang section text = "sample_ext"
int

Просмотреть файл

@ -84,10 +84,11 @@ _encode_xdp()
ebpf_result_t return_value;
uint8_t* buffer = NULL;
unsigned long buffer_size = 0;
ebpf_context_descriptor_t xdp_context_descriptor = {sizeof(xdp_md_t),
EBPF_OFFSET_OF(xdp_md_t, data),
EBPF_OFFSET_OF(xdp_md_t, data_end),
EBPF_OFFSET_OF(xdp_md_t, data_meta)};
ebpf_context_descriptor_t xdp_context_descriptor = {
sizeof(xdp_md_t),
EBPF_OFFSET_OF(xdp_md_t, data),
EBPF_OFFSET_OF(xdp_md_t, data_end),
EBPF_OFFSET_OF(xdp_md_t, data_meta)};
ebpf_program_type_descriptor_t xdp_program_type = {"xdp", &xdp_context_descriptor, EBPF_PROGRAM_TYPE_XDP};
ebpf_program_info_t xdp_program_info = {
xdp_program_type, EBPF_COUNT_OF(_ebpf_helper_function_prototype), _ebpf_helper_function_prototype};