From 26173499033394e79e90cbac54609db2e5deb3a9 Mon Sep 17 00:00:00 2001 From: Dave Thaler Date: Tue, 3 Aug 2021 17:25:50 -0700 Subject: [PATCH] Remove duplicate public APIs where standard libbpf APIs exist (#356) * Remove duplicate public APIs where standard libbpf APIs exist Signed-off-by: Dave Thaler --- ebpfapi/Source.def | 7 -- include/ebpf_api.h | 75 +----------------- include/ebpf_helpers.h | 30 +++---- include/ebpf_program_types.h | 2 +- include/ebpf_structs.h | 10 +-- include/libbpf.h | 7 ++ include/linux/bpf.h | 12 ++- libs/api/api_internal.h | 79 +++++++++++++++++-- libs/api/ebpf_api.cpp | 31 ++++---- libs/api/libbpf_object.cpp | 2 +- libs/api_common/windows_platform_common.cpp | 8 +- libs/execution_context/ebpf_core.c | 14 ++-- libs/execution_context/ebpf_maps.c | 10 +-- libs/execution_context/ebpf_program.c | 4 +- libs/execution_context/ebpf_program.h | 7 +- libs/execution_context/ebpf_protocol.h | 4 +- .../unit/execution_context_unit_test.cpp | 6 +- libs/platform/ebpf_object.h | 2 + libs/platform/unit/platform_unit_test.cpp | 8 +- tests/api_test/api_test.cpp | 48 +++++------ tests/end_to_end/end_to_end.cpp | 6 +- tests/ext/app/test_ext_app.cpp | 9 ++- tests/libs/common/common_tests.cpp | 4 +- tests/sample/bindmonitor.c | 14 ++-- tests/sample/divide_by_zero.c | 4 +- tests/sample/droppacket.c | 4 +- tests/sample/droppacket_unsafe.c | 4 +- tests/sample/ebpf.h | 6 +- tests/sample/repro.c | 4 +- tests/sample/test_ebpf.c | 2 +- tests/unit/test.vcxproj | 4 +- .../encode_program_info.cpp | 6 +- 32 files changed, 213 insertions(+), 220 deletions(-) create mode 100644 include/libbpf.h diff --git a/ebpfapi/Source.def b/ebpfapi/Source.def index 0138f99f8..ad701729e 100644 --- a/ebpfapi/Source.def +++ b/ebpfapi/Source.def @@ -59,11 +59,4 @@ EXPORTS ebpf_api_get_pinned_map_info ebpf_api_map_info_free ebpf_free_string - ebpf_map_get_fd - ebpf_map_next - ebpf_map_previous - ebpf_object_close - ebpf_program_get_fd ebpf_program_load - ebpf_program_next - ebpf_program_previous diff --git a/include/ebpf_api.h b/include/ebpf_api.h index f5ce30be6..9116457f8 100644 --- a/include/ebpf_api.h +++ b/include/ebpf_api.h @@ -70,9 +70,9 @@ extern "C" const ebpf_handle_t ebpf_handle_invalid = (ebpf_handle_t)-1; typedef struct _tlv_type_length_value tlv_type_length_value_t; - struct _ebpf_object; - struct _ebpf_program; - struct _ebpf_map; + struct bpf_object; + struct bpf_program; + struct bpf_map; /** * @brief Initialize the eBPF user mode library. @@ -442,77 +442,10 @@ extern "C" _In_opt_ const ebpf_program_type_t* program_type, _In_opt_ const ebpf_attach_type_t* attach_type, _In_ ebpf_execution_type_t execution_type, - _Outptr_ struct _ebpf_object** object, + _Outptr_ struct bpf_object** object, _Out_ fd_t* program_fd, _Outptr_result_maybenull_z_ const char** log_buffer); - /** - * @brief Get next program in ebpf_object object. - * - * @param[in] previous Pointer to previous eBPF program, or NULL to get the first one. - * @param[in] object Pointer to eBPF object. - * @return Pointer to the next program, or NULL if none. - */ - _Ret_maybenull_ struct _ebpf_program* - ebpf_program_next(_In_opt_ const struct _ebpf_program* previous, _In_ const struct _ebpf_object* object); - - /** - * @brief Get previous program in ebpf_object object. - * - * @param[in] next Pointer to next eBPF program, or NULL to get the last one. - * @param[in] object Pointer to eBPF object. - * @return Pointer to the previous program, or NULL if none. - */ - _Ret_maybenull_ struct _ebpf_program* - ebpf_program_previous(_In_opt_ const struct _ebpf_program* next, _In_ const struct _ebpf_object* object); - - /** - * @brief Get next map in ebpf_object object. - * - * @param[in] previous Pointer to previous eBPF map, or NULL to get the first one. - * @param[in] object Pointer to eBPF object. - * @return Pointer to the next map, or NULL if none. - */ - _Ret_maybenull_ struct _ebpf_map* - ebpf_map_next(_In_opt_ const struct _ebpf_map* previous, _In_ const struct _ebpf_object* object); - - /** - * @brief Get previous map in ebpf_object object. - * - * @param[in] next Pointer to next eBPF map, or NULL to get the last one. - * @param[in] object Pointer to eBPF object. - * @return Pointer to the previous map, or NULL if none. - */ - _Ret_maybenull_ struct _ebpf_map* - ebpf_map_previous(_In_opt_ const struct _ebpf_map* next, _In_ const struct _ebpf_object* object); - - /** - * @brief Fetch fd for a program object. - * - * @param[in] program Pointer to eBPF program. - * @return fd for the program on success, ebpf_fd_invalid on failure. - */ - fd_t - ebpf_program_get_fd(_In_ const struct _ebpf_program* program); - - /** - * @brief Fetch fd for a map object. - * - * @param[in] map Pointer to eBPF map. - * @return fd for the map on success, ebpf_fd_invalid on failure. - */ - fd_t - ebpf_map_get_fd(_In_ const struct _ebpf_map* map); - - /** - * @brief Clean up ebpf_object. Also delete all the sub objects - * (maps, programs) and close the related file descriptors. - * - * @param[in] object Pointer to ebpf_object. - */ - void - ebpf_object_close(_In_ _Post_invalid_ struct _ebpf_object* object); - #ifdef __cplusplus } #endif diff --git a/include/ebpf_helpers.h b/include/ebpf_helpers.h index d9a13ceaa..a44eecee9 100644 --- a/include/ebpf_helpers.h +++ b/include/ebpf_helpers.h @@ -6,6 +6,11 @@ #include "ebpf_structs.h" +// In an execution context, struct bpf_map means struct _ebpf_map_definition, +// as opposed to for user mode apps, so define the alias here where the execution +// context and eBPF programs will get it. +#define bpf_map _ebpf_map_definition + #ifndef __doxygen #define EBPF_HELPER(return_type, name, args) typedef return_type(*name##_t) args #endif @@ -20,9 +25,9 @@ * @param[in] key Key to use when searching map. * @return Pointer to the value if found or NULL. */ -EBPF_HELPER(void*, ebpf_map_lookup_element, (ebpf_map_definition_t * map, void* key)); +EBPF_HELPER(void*, bpf_map_lookup_elem, (struct bpf_map * map, void* key)); #ifndef __doxygen -#define ebpf_map_lookup_element ((ebpf_map_lookup_element_t)1) +#define bpf_map_lookup_elem ((bpf_map_lookup_elem_t)1) #endif /** @@ -36,9 +41,9 @@ EBPF_HELPER(void*, ebpf_map_lookup_element, (ebpf_map_definition_t * map, void* * @retval EBPF_NO_MEMORY Unable to allocate resources for this * entry. */ -EBPF_HELPER(int64_t, ebpf_map_update_element, (ebpf_map_definition_t * map, void* key, void* value, uint64_t flags)); +EBPF_HELPER(int64_t, bpf_map_update_elem, (struct bpf_map * map, void* key, void* value, uint64_t flags)); #ifndef __doxygen -#define ebpf_map_update_element ((ebpf_map_update_element_t)2) +#define bpf_map_update_elem ((bpf_map_update_elem_t)2) #endif /** @@ -50,20 +55,7 @@ EBPF_HELPER(int64_t, ebpf_map_update_element, (ebpf_map_definition_t * map, void * @retval EBPF_INVALID_ARGUMENT One or more parameters are * invalid. */ -EBPF_HELPER(int64_t, ebpf_map_delete_element, (ebpf_map_definition_t * map, void* key)); +EBPF_HELPER(int64_t, bpf_map_delete_elem, (struct bpf_map * map, void* key)); #ifndef __doxygen -#define ebpf_map_delete_element ((ebpf_map_delete_element_t)3) +#define bpf_map_delete_elem ((bpf_map_delete_elem_t)3) #endif - -// -// Defines for cross-platform compatibility. -// - -#define bpf_map _ebpf_map_definition -#define bpf_map_lookup_elem ebpf_map_lookup_element -#define bpf_map_update_elem ebpf_map_update_element -#define bpf_map_delete_elem ebpf_map_delete_element - -#define BPF_MAP_TYPE_UNSPECIFIED EBPF_MAP_TYPE_UNSPECIFIED -#define BPF_MAP_TYPE_HASH EBPF_MAP_TYPE_HASH -#define BPF_MAP_TYPE_ARRAY EBPF_MAP_TYPE_ARRAY diff --git a/include/ebpf_program_types.h b/include/ebpf_program_types.h index 6ac2603d3..2e3588135 100644 --- a/include/ebpf_program_types.h +++ b/include/ebpf_program_types.h @@ -54,4 +54,4 @@ typedef struct _ebpf_program_data { ebpf_program_info_t* program_info; ebpf_helper_function_addresses_t* helper_function_addresses; -} ebpf_program_data_t; \ No newline at end of file +} ebpf_program_data_t; diff --git a/include/ebpf_structs.h b/include/ebpf_structs.h index ab254d308..1ac7c6625 100644 --- a/include/ebpf_structs.h +++ b/include/ebpf_structs.h @@ -9,15 +9,15 @@ #include #include "../external/ebpf-verifier/src/ebpf_base.h" -typedef enum _ebpf_map_type +typedef enum bpf_map_type { - EBPF_MAP_TYPE_UNSPECIFIED = 0, ///< Unspecified map type. - EBPF_MAP_TYPE_HASH = 1, ///< Hash table. - EBPF_MAP_TYPE_ARRAY = 2, ///< Array, wehere the map key is the array index. + BPF_MAP_TYPE_UNSPECIFIED = 0, ///< Unspecified map type. + BPF_MAP_TYPE_HASH = 1, ///< Hash table. + BPF_MAP_TYPE_ARRAY = 2, ///< Array, wehere the map key is the array index. } ebpf_map_type_t; /** - * @brief eBPF Map Definition + * @brief eBPF Map Definition. */ typedef struct _ebpf_map_definition { diff --git a/include/libbpf.h b/include/libbpf.h new file mode 100644 index 000000000..1894fc5d8 --- /dev/null +++ b/include/libbpf.h @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation +// SPDX-License-Identifier: MIT + +#pragma warning(push) +#pragma warning(disable : 4200) // Zero-sized array in struct/union +#include "../external/libbpf/src/libbpf.h" +#pragma warning(pop) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index f94b9498d..e32c684d7 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -17,13 +17,6 @@ typedef uint32_t __u32; typedef uint64_t __u64; typedef uint32_t pid_t; -#define bpf_map _ebpf_map -#define bpf_map_type _ebpf_map_type -#define bpf_object _ebpf_object -#define bpf_program _ebpf_program -#define bpf_prog_info _ebpf_program_info -#define BPF_MAP_TYPE_ARRAY EBPF_MAP_TYPE_ARRAY - enum bpf_prog_type { BPF_PROG_TYPE_UNKNOWN, @@ -45,3 +38,8 @@ enum bpf_stats_type { BPF_STATS_TYPE_UNKNOWN }; + +struct bpf_prog_info +{ + int data; +}; diff --git a/libs/api/api_internal.h b/libs/api/api_internal.h index 55a17ca51..44d8c1532 100644 --- a/libs/api/api_internal.h +++ b/libs/api/api_internal.h @@ -8,11 +8,11 @@ #include "ebpf_windows.h" #include "spec_type_descriptors.hpp" -struct _ebpf_object; +struct bpf_object; -typedef struct _ebpf_program +typedef struct bpf_program { - struct _ebpf_object* object; + struct bpf_object* object; char* section_name; char* program_name; uint8_t* byte_code; @@ -23,9 +23,9 @@ typedef struct _ebpf_program fd_t fd; } ebpf_program_t; -typedef struct _ebpf_map +typedef struct bpf_map { - const struct _ebpf_object* object; + const struct bpf_object* object; char* name; ebpf_handle_t map_handle; fd_t map_fd; @@ -34,7 +34,7 @@ typedef struct _ebpf_map bool pinned; } ebpf_map_t; -typedef struct _ebpf_object +typedef struct bpf_object { char* file_name = nullptr; std::vector programs; @@ -62,3 +62,70 @@ clean_up_ebpf_programs(_Inout_ std::vector& programs); void clean_up_ebpf_maps(_Inout_ std::vector& maps); + +/** + * @brief Get next program in ebpf_object object. + * + * @param[in] previous Pointer to previous eBPF program, or NULL to get the first one. + * @param[in] object Pointer to eBPF object. + * @return Pointer to the next program, or NULL if none. + */ +_Ret_maybenull_ struct bpf_program* +ebpf_program_next(_In_opt_ const struct bpf_program* previous, _In_ const struct bpf_object* object); + +/** + * @brief Get previous program in ebpf_object object. + * + * @param[in] next Pointer to next eBPF program, or NULL to get the last one. + * @param[in] object Pointer to eBPF object. + * @return Pointer to the previous program, or NULL if none. + */ +_Ret_maybenull_ struct bpf_program* +ebpf_program_previous(_In_opt_ const struct bpf_program* next, _In_ const struct bpf_object* object); + +/** + * @brief Get next map in ebpf_object object. + * + * @param[in] previous Pointer to previous eBPF map, or NULL to get the first one. + * @param[in] object Pointer to eBPF object. + * @return Pointer to the next map, or NULL if none. + */ +_Ret_maybenull_ struct bpf_map* +ebpf_map_next(_In_opt_ const struct bpf_map* previous, _In_ const struct bpf_object* object); + +/** + * @brief Get previous map in ebpf_object object. + * + * @param[in] next Pointer to next eBPF map, or NULL to get the last one. + * @param[in] object Pointer to eBPF object. + * @return Pointer to the previous map, or NULL if none. + */ +_Ret_maybenull_ struct bpf_map* +ebpf_map_previous(_In_opt_ const struct bpf_map* next, _In_ const struct bpf_object* object); + +/** + * @brief Fetch fd for a program object. + * + * @param[in] program Pointer to eBPF program. + * @return fd for the program on success, ebpf_fd_invalid on failure. + */ +fd_t +ebpf_program_get_fd(_In_ const struct bpf_program* program); + +/** + * @brief Fetch fd for a map object. + * + * @param[in] map Pointer to eBPF map. + * @return fd for the map on success, ebpf_fd_invalid on failure. + */ +fd_t +ebpf_map_get_fd(_In_ const struct bpf_map* map); + +/** + * @brief Clean up ebpf_object. Also delete all the sub objects + * (maps, programs) and close the related file descriptors. + * + * @param[in] object Pointer to ebpf_object. + */ +void +ebpf_object_close(_In_ _Post_invalid_ struct bpf_object* object); diff --git a/libs/api/ebpf_api.cpp b/libs/api/ebpf_api.cpp index a781411c1..9143d3083 100644 --- a/libs/api/ebpf_api.cpp +++ b/libs/api/ebpf_api.cpp @@ -472,9 +472,10 @@ ebpf_api_get_next_map(ebpf_handle_t previous_handle, ebpf_handle_t* next_handle) uint32_t ebpf_api_get_next_program(ebpf_handle_t previous_handle, ebpf_handle_t* next_handle) { - _ebpf_operation_get_next_program_request request{sizeof(request), - ebpf_operation_id_t::EBPF_OPERATION_GET_NEXT_PROGRAM, - reinterpret_cast(previous_handle)}; + _ebpf_operation_get_next_program_request request{ + sizeof(request), + ebpf_operation_id_t::EBPF_OPERATION_GET_NEXT_PROGRAM, + reinterpret_cast(previous_handle)}; _ebpf_operation_get_next_program_reply reply; @@ -832,7 +833,7 @@ ebpf_program_load( _In_opt_ const ebpf_program_type_t* program_type, _In_opt_ const ebpf_attach_type_t* attach_type, _In_ ebpf_execution_type_t execution_type, - _Outptr_ struct _ebpf_object** object, + _Outptr_ struct bpf_object** object, _Out_ fd_t* program_fd, _Outptr_result_maybenull_z_ const char** log_buffer) { @@ -938,8 +939,8 @@ Done: return result; } -_Ret_maybenull_ struct _ebpf_program* -ebpf_program_next(_In_opt_ const struct _ebpf_program* previous, _In_ const struct _ebpf_object* object) +_Ret_maybenull_ struct bpf_program* +ebpf_program_next(_In_opt_ const struct bpf_program* previous, _In_ const struct bpf_object* object) { ebpf_program_t* program = nullptr; if (object == nullptr) { @@ -964,8 +965,8 @@ Exit: return program; } -_Ret_maybenull_ struct _ebpf_program* -ebpf_program_previous(_In_opt_ const struct _ebpf_program* next, _In_ const struct _ebpf_object* object) +_Ret_maybenull_ struct bpf_program* +ebpf_program_previous(_In_opt_ const struct bpf_program* next, _In_ const struct bpf_object* object) { ebpf_program_t* program = nullptr; if (object == nullptr) { @@ -990,8 +991,8 @@ Exit: return program; } -_Ret_maybenull_ struct _ebpf_map* -ebpf_map_next(_In_opt_ const struct _ebpf_map* previous, _In_ const struct _ebpf_object* object) +_Ret_maybenull_ struct bpf_map* +ebpf_map_next(_In_opt_ const struct bpf_map* previous, _In_ const struct bpf_object* object) { ebpf_map_t* map = nullptr; if (object == nullptr) { @@ -1016,8 +1017,8 @@ Exit: return map; } -_Ret_maybenull_ struct _ebpf_map* -ebpf_map_previous(_In_opt_ const struct _ebpf_map* next, _In_ const struct _ebpf_object* object) +_Ret_maybenull_ struct bpf_map* +ebpf_map_previous(_In_opt_ const struct bpf_map* next, _In_ const struct bpf_object* object) { ebpf_map_t* map = nullptr; if (object == nullptr) { @@ -1043,7 +1044,7 @@ Exit: } fd_t -ebpf_program_get_fd(_In_ const struct _ebpf_program* program) +ebpf_program_get_fd(_In_ const struct bpf_program* program) { if (program == nullptr) { return ebpf_fd_invalid; @@ -1052,7 +1053,7 @@ ebpf_program_get_fd(_In_ const struct _ebpf_program* program) } fd_t -ebpf_map_get_fd(_In_ const struct _ebpf_map* map) +ebpf_map_get_fd(_In_ const struct bpf_map* map) { if (map == nullptr) { return ebpf_fd_invalid; @@ -1061,7 +1062,7 @@ ebpf_map_get_fd(_In_ const struct _ebpf_map* map) } void -ebpf_object_close(_In_ _Post_invalid_ struct _ebpf_object* object) +ebpf_object_close(_In_ _Post_invalid_ struct bpf_object* object) { if (object == nullptr) { return; diff --git a/libs/api/libbpf_object.cpp b/libs/api/libbpf_object.cpp index d1dbb5ea8..70d930ee9 100644 --- a/libs/api/libbpf_object.cpp +++ b/libs/api/libbpf_object.cpp @@ -9,7 +9,7 @@ #include "libbpf_internal.h" // This file implements APIs in LibBPF's libbpf.h and is based on code in external/libbpf/src/libbpf.c -// used under the BSD-2-Clause license , so the coding style tries to match the libbpf.c style to +// used under the BSD-2-Clause license, so the coding style tries to match the libbpf.c style to // minimize diffs until libbpf becomes cross-platform capable. This is a temporary workaround for // issue #351 until we can compile and use libbpf.c directly. diff --git a/libs/api_common/windows_platform_common.cpp b/libs/api_common/windows_platform_common.cpp index e5217389b..2c867c1e1 100644 --- a/libs/api_common/windows_platform_common.cpp +++ b/libs/api_common/windows_platform_common.cpp @@ -105,12 +105,12 @@ get_program_type_windows(const std::string& section, const std::string&) return windows_xdp_program_type; } -#define EBPF_MAP_TYPE(x) EBPF_MAP_TYPE_##x, #x +#define BPF_MAP_TYPE(x) BPF_MAP_TYPE_##x, #x static const EbpfMapType windows_map_types[] = { - {EBPF_MAP_TYPE(UNSPECIFIED)}, - {EBPF_MAP_TYPE(HASH)}, - {EBPF_MAP_TYPE(ARRAY), true}, + {BPF_MAP_TYPE(UNSPECIFIED)}, + {BPF_MAP_TYPE(HASH)}, + {BPF_MAP_TYPE(ARRAY), true}, }; EbpfMapType diff --git a/libs/execution_context/ebpf_core.c b/libs/execution_context/ebpf_core.c index 521bc2c4d..71abc294e 100644 --- a/libs/execution_context/ebpf_core.c +++ b/libs/execution_context/ebpf_core.c @@ -32,16 +32,16 @@ _ebpf_core_map_delete_element(ebpf_map_t* map, const uint8_t* key); #define EBPF_CORE_GLOBAL_HELPER_EXTENSION_VERSION 0 static ebpf_helper_function_prototype_t _ebpf_map_helper_function_prototype[] = { - {(uint32_t)(intptr_t)ebpf_map_lookup_element, - "ebpf_map_lookup_element", + {(uint32_t)(intptr_t)bpf_map_lookup_elem, + "bpf_map_lookup_elem", EBPF_RETURN_TYPE_PTR_TO_MAP_VALUE_OR_NULL, {EBPF_ARGUMENT_TYPE_PTR_TO_MAP, EBPF_ARGUMENT_TYPE_PTR_TO_MAP_KEY}}, - {(uint32_t)(intptr_t)ebpf_map_update_element, - "ebpf_map_update_element", + {(uint32_t)(intptr_t)bpf_map_update_elem, + "bpf_map_update_elem", EBPF_RETURN_TYPE_INTEGER, {EBPF_ARGUMENT_TYPE_PTR_TO_MAP, EBPF_ARGUMENT_TYPE_PTR_TO_MAP_KEY, EBPF_ARGUMENT_TYPE_PTR_TO_MAP_VALUE}}, - {(uint32_t)(intptr_t)ebpf_map_delete_element, - "ebpf_map_delete_element", + {(uint32_t)(intptr_t)bpf_map_delete_elem, + "bpf_map_delete_elem", EBPF_RETURN_TYPE_INTEGER, {EBPF_ARGUMENT_TYPE_PTR_TO_MAP, EBPF_ARGUMENT_TYPE_PTR_TO_MAP_KEY}}}; @@ -158,7 +158,7 @@ _ebpf_core_protocol_load_code(_In_ const ebpf_operation_load_code_request_t* req retval = ebpf_program_load_machine_code(program, code, code_length); } else { retval = - ebpf_program_load_byte_code(program, (ebpf_instuction_t*)code, code_length / sizeof(ebpf_instuction_t)); + ebpf_program_load_byte_code(program, (ebpf_instruction_t*)code, code_length / sizeof(ebpf_instruction_t)); } if (retval != EBPF_SUCCESS) diff --git a/libs/execution_context/ebpf_maps.c b/libs/execution_context/ebpf_maps.c index a5a62be0e..cd2da0185 100644 --- a/libs/execution_context/ebpf_maps.c +++ b/libs/execution_context/ebpf_maps.c @@ -23,7 +23,7 @@ typedef struct _ebpf_map_function_table ebpf_result_t (*next_key)(_In_ ebpf_core_map_t* map, _In_ const uint8_t* previous_key, _Out_ uint8_t* next_key); } ebpf_map_function_table_t; -extern ebpf_map_function_table_t ebpf_map_function_tables[EBPF_MAP_TYPE_ARRAY + 1]; +extern ebpf_map_function_table_t ebpf_map_function_tables[BPF_MAP_TYPE_ARRAY + 1]; ebpf_result_t ebpf_map_create(_In_ const ebpf_map_definition_t* ebpf_map_definition, _Outptr_ ebpf_map_t** ebpf_map) @@ -31,7 +31,7 @@ ebpf_map_create(_In_ const ebpf_map_definition_t* ebpf_map_definition, _Outptr_ ebpf_map_t* local_map = NULL; size_t type = ebpf_map_definition->type; - if (ebpf_map_definition->type > EBPF_MAP_TYPE_ARRAY) + if (ebpf_map_definition->type > BPF_MAP_TYPE_ARRAY) return EBPF_INVALID_ARGUMENT; if (!ebpf_map_function_tables[type].create_map) @@ -306,16 +306,16 @@ ebpf_next_hash_map_key(_In_ ebpf_core_map_t* map, _In_ const uint8_t* previous_k } ebpf_map_function_table_t ebpf_map_function_tables[] = { - {// EBPF_MAP_TYPE_UNSPECIFIED + {// BPF_MAP_TYPE_UNSPECIFIED NULL}, - {// EBPF_MAP_TYPE_HASH + {// BPF_MAP_TYPE_HASH ebpf_create_hash_map, ebpf_delete_hash_map, ebpf_find_hash_map_entry, ebpf_update_hash_map_entry, ebpf_delete_hash_map_entry, ebpf_next_hash_map_key}, - {// EBPF_MAP_TYPE_ARRAY + {// BPF_MAP_TYPE_ARRAY ebpf_create_array_map, ebpf_delete_array_map, ebpf_find_array_map_entry, diff --git a/libs/execution_context/ebpf_program.c b/libs/execution_context/ebpf_program.c index e2ffbf8fd..c52a633de 100644 --- a/libs/execution_context/ebpf_program.c +++ b/libs/execution_context/ebpf_program.c @@ -389,7 +389,7 @@ _ebpf_program_register_helpers(ebpf_program_t* program) } ebpf_result_t -ebpf_program_load_byte_code(ebpf_program_t* program, ebpf_instuction_t* instructions, size_t instruction_count) +ebpf_program_load_byte_code(ebpf_program_t* program, ebpf_instruction_t* instructions, size_t instruction_count) { ebpf_result_t return_value; char* error_message = NULL; @@ -418,7 +418,7 @@ ebpf_program_load_byte_code(ebpf_program_t* program, ebpf_instuction_t* instruct if (ubpf_load( program->code_or_vm.vm, instructions, - (uint32_t)(instruction_count * sizeof(ebpf_instuction_t)), + (uint32_t)(instruction_count * sizeof(ebpf_instruction_t)), &error_message) != 0) { ebpf_free(error_message); return_value = EBPF_INVALID_ARGUMENT; diff --git a/libs/execution_context/ebpf_program.h b/libs/execution_context/ebpf_program.h index 0f964d0f4..a49c5f811 100644 --- a/libs/execution_context/ebpf_program.h +++ b/libs/execution_context/ebpf_program.h @@ -14,16 +14,15 @@ extern "C" #endif typedef enum _ebpf_code_type ebpf_code_type_t; - typedef struct _ebpf_instuction + typedef struct _ebpf_instruction { uint8_t opcode; uint8_t dst : 4; //< Destination register uint8_t src : 4; //< Source register int16_t offset; int32_t imm; //< Immediate constant - } ebpf_instuction_t; + } ebpf_instruction_t; - typedef struct _ebpf_program ebpf_program_t; typedef struct _ebpf_program_parameters { ebpf_program_type_t program_type; @@ -130,7 +129,7 @@ extern "C" * program instance. */ ebpf_result_t - ebpf_program_load_byte_code(ebpf_program_t* program, ebpf_instuction_t* instructions, size_t instruction_count); + ebpf_program_load_byte_code(ebpf_program_t* program, ebpf_instruction_t* instructions, size_t instruction_count); /** * @brief Invoke an ebpf_program_t instance. diff --git a/libs/execution_context/ebpf_protocol.h b/libs/execution_context/ebpf_protocol.h index 930437f04..f90cd73b6 100644 --- a/libs/execution_context/ebpf_protocol.h +++ b/libs/execution_context/ebpf_protocol.h @@ -2,8 +2,10 @@ // SPDX-License-Identifier: MIT #pragma once + +// This file must only include headers that are safe +// to include in both user mode and kernel mode. #include "ebpf_core_structs.h" -#include "ebpf_helpers.h" #include "ebpf_windows.h" typedef enum _ebpf_operation_id diff --git a/libs/execution_context/unit/execution_context_unit_test.cpp b/libs/execution_context/unit/execution_context_unit_test.cpp index dbbd32699..fd743d53f 100644 --- a/libs/execution_context/unit/execution_context_unit_test.cpp +++ b/libs/execution_context/unit/execution_context_unit_test.cpp @@ -95,9 +95,9 @@ test_crud_operations(ebpf_map_type_t map_type) REQUIRE(memcmp(retrieved_map_definition, &map_definition, sizeof(map_definition)) == 0); } -TEST_CASE("map_crud_operations_array", "[execution_context]") { test_crud_operations(EBPF_MAP_TYPE_ARRAY); } +TEST_CASE("map_crud_operations_array", "[execution_context]") { test_crud_operations(BPF_MAP_TYPE_ARRAY); } -TEST_CASE("map_crud_operations_hash", "[execution_context]") { test_crud_operations(EBPF_MAP_TYPE_HASH); } +TEST_CASE("map_crud_operations_hash", "[execution_context]") { test_crud_operations(BPF_MAP_TYPE_HASH); } #define TEST_FUNCTION_RETURN 42 @@ -118,7 +118,7 @@ TEST_CASE("program", "[execution_context]") } ebpf_map_definition_t map_definition{ - sizeof(ebpf_map_definition_t), EBPF_MAP_TYPE_HASH, sizeof(uint32_t), sizeof(uint64_t), 10}; + sizeof(ebpf_map_definition_t), BPF_MAP_TYPE_HASH, sizeof(uint32_t), sizeof(uint64_t), 10}; map_ptr map; { ebpf_map_t* local_map; diff --git a/libs/platform/ebpf_object.h b/libs/platform/ebpf_object.h index 60940dc42..c28e3112b 100644 --- a/libs/platform/ebpf_object.h +++ b/libs/platform/ebpf_object.h @@ -22,6 +22,8 @@ extern "C" typedef struct _ebpf_object ebpf_object_t; typedef void (*ebpf_free_object_t)(ebpf_object_t* object); + // This type probably ought to be renamed to avoid confusion with + // ebpf_object_t in libs\api\api_internal.h typedef struct _ebpf_object { uint32_t marker; diff --git a/libs/platform/unit/platform_unit_test.cpp b/libs/platform/unit/platform_unit_test.cpp index afc25fd8d..6f5e9284f 100644 --- a/libs/platform/unit/platform_unit_test.cpp +++ b/libs/platform/unit/platform_unit_test.cpp @@ -226,15 +226,15 @@ TEST_CASE("program_type_info", "[platform]") ebpf_helper_function_prototype_t helper_functions[] = { {1, - "ebpf_map_lookup_element", + "bpf_map_lookup_elem", EBPF_RETURN_TYPE_PTR_TO_MAP_VALUE_OR_NULL, {EBPF_ARGUMENT_TYPE_PTR_TO_MAP, EBPF_ARGUMENT_TYPE_PTR_TO_MAP_KEY}}, {2, - "ebpf_map_update_element", + "bpf_map_update_elem", EBPF_RETURN_TYPE_INTEGER, {EBPF_ARGUMENT_TYPE_PTR_TO_MAP, EBPF_ARGUMENT_TYPE_PTR_TO_MAP_KEY, EBPF_ARGUMENT_TYPE_PTR_TO_MAP_VALUE}}, {3, - "ebpf_map_delete_element", + "bpf_map_delete_elem", EBPF_RETURN_TYPE_PTR_TO_MAP_VALUE_OR_NULL, {EBPF_ARGUMENT_TYPE_PTR_TO_MAP, EBPF_ARGUMENT_TYPE_PTR_TO_MAP_KEY}}, }; @@ -355,7 +355,7 @@ TEST_CASE("serialize_map_test", "[platform]") for (int i = 0; i < map_count; i++) { ebpf_map_info_internal_t* map_info = &internal_map_info_array[i]; map_info->definition.size = (i + 1) * 32; - map_info->definition.type = static_cast(i % (EBPF_MAP_TYPE_ARRAY + 1)); + map_info->definition.type = static_cast(i % (BPF_MAP_TYPE_ARRAY + 1)); map_info->definition.key_size = i + 1; map_info->definition.value_size = (i + 1) * (i + 1); map_info->definition.max_entries = (i + 1) * 128; diff --git a/tests/api_test/api_test.cpp b/tests/api_test/api_test.cpp index 78d0b4896..104755cb0 100644 --- a/tests/api_test/api_test.cpp +++ b/tests/api_test/api_test.cpp @@ -11,13 +11,7 @@ #include "catch_wrapper.hpp" #include "common_tests.h" #include "service_helper.h" - -namespace api_test { -#pragma warning(push) -#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union -#include "../sample/ebpf.h" -#pragma warning(pop) -}; // namespace api_test +#include "libbpf.h" #define SAMPLE_PATH "" @@ -50,7 +44,7 @@ _program_load_helper( const char* file_name, const ebpf_program_type_t* program_type, ebpf_execution_type_t execution_type, - struct _ebpf_object** object, + struct bpf_object** object, fd_t* program_fd) { ebpf_result_t result; @@ -69,7 +63,7 @@ _test_program_load( bool expected_to_load) { ebpf_result_t result; - struct _ebpf_object* object = nullptr; + struct bpf_object* object = nullptr; fd_t program_fd; ebpf_handle_t program_handle = INVALID_HANDLE_VALUE; ebpf_handle_t next_program_handle = INVALID_HANDLE_VALUE; @@ -111,7 +105,7 @@ _test_program_load( ebpf_api_close_handle(program_handle); program_handle = INVALID_HANDLE_VALUE; - ebpf_object_close(object); + bpf_object__close(object); // We have closed both handles to the program. Program should be unloaded now. REQUIRE(ebpf_api_get_next_program(program_handle, &next_program_handle) == ERROR_SUCCESS); @@ -122,68 +116,68 @@ static void _test_map_next_previous(const char* file_name, int expected_map_count) { ebpf_result_t result; - struct _ebpf_object* object = nullptr; + struct bpf_object* object = nullptr; fd_t program_fd; int map_count = 0; - struct _ebpf_map* previous = nullptr; - struct _ebpf_map* next = nullptr; + struct bpf_map* previous = nullptr; + struct bpf_map* next = nullptr; result = _program_load_helper(file_name, nullptr, EBPF_EXECUTION_ANY, &object, &program_fd); REQUIRE(result == EBPF_SUCCESS); - next = ebpf_map_next(previous, object); + next = bpf_map__next(previous, object); while (next != nullptr) { map_count++; previous = next; - next = ebpf_map_next(previous, object); + next = bpf_map__next(previous, object); } REQUIRE(map_count == expected_map_count); map_count = 0; previous = next = nullptr; - previous = ebpf_map_previous(next, object); + previous = bpf_map__prev(next, object); while (previous != nullptr) { map_count++; next = previous; - previous = ebpf_map_previous(next, object); + previous = bpf_map__prev(next, object); } REQUIRE(map_count == expected_map_count); - ebpf_object_close(object); + bpf_object__close(object); } static void _test_program_next_previous(const char* file_name, int expected_program_count) { ebpf_result_t result; - struct _ebpf_object* object = nullptr; + struct bpf_object* object = nullptr; fd_t program_fd; int program_count = 0; - struct _ebpf_program* previous = nullptr; - struct _ebpf_program* next = nullptr; + struct bpf_program* previous = nullptr; + struct bpf_program* next = nullptr; result = _program_load_helper(file_name, nullptr, EBPF_EXECUTION_ANY, &object, &program_fd); REQUIRE(result == EBPF_SUCCESS); - next = ebpf_program_next(previous, object); + next = bpf_program__next(previous, object); while (next != nullptr) { program_count++; previous = next; - next = ebpf_program_next(previous, object); + next = bpf_program__next(previous, object); } REQUIRE(program_count == expected_program_count); program_count = 0; previous = next = nullptr; - previous = ebpf_program_previous(next, object); + previous = bpf_program__prev(next, object); while (previous != nullptr) { program_count++; next = previous; - previous = ebpf_program_previous(next, object); + previous = bpf_program__prev(next, object); } REQUIRE(program_count == expected_program_count); - ebpf_object_close(object); + bpf_object__close(object); } TEST_CASE("pinned_map_enum", "[pinned_map_enum]") @@ -246,4 +240,4 @@ TEST_CASE("test_ebpf_map_next_previous", "[test_ebpf_map_next_previous]") _test_map_next_previous("bindmonitor.o", BIND_MONITOR_MAP_COUNT); ebpf_api_terminate(); -} \ No newline at end of file +} diff --git a/tests/end_to_end/end_to_end.cpp b/tests/end_to_end/end_to_end.cpp index 803b25b7f..bf05532a2 100644 --- a/tests/end_to_end/end_to_end.cpp +++ b/tests/end_to_end/end_to_end.cpp @@ -578,10 +578,10 @@ TEST_CASE("enumerate_and_query_maps", "[end_to_end]") ebpf_map_definition_t map_definitions[_countof(map_handles)]; ebpf_map_definition_t process_map = { - sizeof(ebpf_map_definition_t), EBPF_MAP_TYPE_HASH, sizeof(uint64_t), sizeof(process_entry_t), 1024}; + sizeof(ebpf_map_definition_t), BPF_MAP_TYPE_HASH, sizeof(uint64_t), sizeof(process_entry_t), 1024}; ebpf_map_definition_t limits_map = { - sizeof(ebpf_map_definition_t), EBPF_MAP_TYPE_ARRAY, sizeof(uint32_t), sizeof(uint32_t), 1}; + sizeof(ebpf_map_definition_t), BPF_MAP_TYPE_ARRAY, sizeof(uint32_t), sizeof(uint32_t), 1}; for (size_t index = 0; index < _countof(map_handles); index++) { REQUIRE( @@ -818,4 +818,4 @@ TEST_CASE("implicit_explicit_detach", "[end_to_end]") // ebpf_object_tracking_terminate() which is called when the test // exits checks if all the objects in EC have been deleted. hook.detach(); -} \ No newline at end of file +} diff --git a/tests/ext/app/test_ext_app.cpp b/tests/ext/app/test_ext_app.cpp index a3b7828cb..983ec2151 100644 --- a/tests/ext/app/test_ext_app.cpp +++ b/tests/ext/app/test_ext_app.cpp @@ -9,6 +9,7 @@ #include "catch_wrapper.hpp" #include "common_tests.h" +#include "libbpf.h" #include "service_helper.h" #include "test_ext_app.h" @@ -39,7 +40,7 @@ _program_load_helper( _In_z_ const char* file_name, _In_ const ebpf_program_type_t* program_type, ebpf_execution_type_t execution_type, - _Outptr_ struct _ebpf_object** object, + _Outptr_ struct bpf_object** object, _Out_ fd_t* program_fd) { ebpf_result_t result; @@ -53,7 +54,7 @@ _program_load_helper( TEST_CASE("test_test", "[test_test]") { ebpf_result_t result; - struct _ebpf_object* object = nullptr; + struct bpf_object* object = nullptr; fd_t program_fd; ebpf_handle_t program_handle = INVALID_HANDLE_VALUE; ebpf_handle_t next_program_handle = INVALID_HANDLE_VALUE; @@ -104,9 +105,9 @@ TEST_CASE("test_test", "[test_test]") nullptr) == TRUE); ebpf_api_close_handle(program_handle); - ebpf_object_close(object); + bpf_object__close(object); if (device_handle != INVALID_HANDLE_VALUE) ::CloseHandle(device_handle); ebpf_api_terminate(); -} \ No newline at end of file +} diff --git a/tests/libs/common/common_tests.cpp b/tests/libs/common/common_tests.cpp index 9a26704ba..cd0e41f64 100644 --- a/tests/libs/common/common_tests.cpp +++ b/tests/libs/common/common_tests.cpp @@ -18,7 +18,7 @@ ebpf_test_pinned_map_enum() ebpf_map_info_t* map_info = nullptr; REQUIRE( - (result = ebpf_api_create_map(EBPF_MAP_TYPE_ARRAY, sizeof(uint32_t), sizeof(uint64_t), 1024, 0, &map_handle)) == + (result = ebpf_api_create_map(BPF_MAP_TYPE_ARRAY, sizeof(uint32_t), sizeof(uint64_t), 1024, 0, &map_handle)) == EBPF_SUCCESS); if (result != EBPF_SUCCESS) @@ -69,4 +69,4 @@ Exit: ebpf_api_map_info_free(map_count, map_info); map_count = 0; map_info = nullptr; -} \ No newline at end of file +} diff --git a/tests/sample/bindmonitor.c b/tests/sample/bindmonitor.c index 3331cf227..cfd9753a3 100644 --- a/tests/sample/bindmonitor.c +++ b/tests/sample/bindmonitor.c @@ -17,13 +17,13 @@ typedef struct _process_entry #pragma clang section data = "maps" ebpf_map_definition_t process_map = {.size = sizeof(ebpf_map_definition_t), - .type = EBPF_MAP_TYPE_HASH, + .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 = EBPF_MAP_TYPE_ARRAY, + .type = BPF_MAP_TYPE_ARRAY, .key_size = sizeof(uint32_t), .value_size = sizeof(uint32_t), .max_entries = 1}; @@ -36,7 +36,7 @@ find_or_create_process_entry(bind_md_t* ctx) process_entry_t value = {0}; int index; - entry = ebpf_map_lookup_element(&process_map, &key); + entry = bpf_map_lookup_elem(&process_map, &key); if (entry) return entry; @@ -46,8 +46,8 @@ find_or_create_process_entry(bind_md_t* ctx) if (!ctx->app_id_start || !ctx->app_id_end) return entry; - ebpf_map_update_element(&process_map, &key, &value, 0); - entry = ebpf_map_lookup_element(&process_map, &key); + bpf_map_update_elem(&process_map, &key, &value, 0); + entry = bpf_map_lookup_elem(&process_map, &key); if (!entry) return entry; @@ -71,7 +71,7 @@ BindMonitor(bind_md_t* ctx) { uint32_t limit_key = 0; process_entry_t* entry; - uint32_t* limit = ebpf_map_lookup_element(&limits_map, &limit_key); + uint32_t* limit = bpf_map_lookup_elem(&limits_map, &limit_key); if (!limit || *limit == 0) return BIND_PERMIT; @@ -99,7 +99,7 @@ BindMonitor(bind_md_t* ctx) if (entry->count == 0) { uint64_t key = ctx->process_id; - ebpf_map_delete_element(&process_map, &key); + bpf_map_delete_elem(&process_map, &key); } return BIND_PERMIT; diff --git a/tests/sample/divide_by_zero.c b/tests/sample/divide_by_zero.c index 4d9d157f1..0ff593c39 100644 --- a/tests/sample/divide_by_zero.c +++ b/tests/sample/divide_by_zero.c @@ -10,7 +10,7 @@ #pragma clang section data = "maps" ebpf_map_definition_t test_map = {.size = sizeof(ebpf_map_definition_t), - .type = EBPF_MAP_TYPE_ARRAY, + .type = BPF_MAP_TYPE_ARRAY, .key_size = sizeof(uint32_t), .value_size = sizeof(uint32_t), .max_entries = 1}; @@ -20,7 +20,7 @@ uint32_t divide_by_zero(xdp_md_t* ctx) { uint32_t key = 0; - uint32_t* value = ebpf_map_lookup_element(&test_map, &key); + uint32_t* value = bpf_map_lookup_elem(&test_map, &key); if (value) { return 100000 / *value; } diff --git a/tests/sample/droppacket.c b/tests/sample/droppacket.c index bed9f258a..8aeb17f32 100644 --- a/tests/sample/droppacket.c +++ b/tests/sample/droppacket.c @@ -10,7 +10,7 @@ #pragma clang section data = "maps" ebpf_map_definition_t port_map = {.size = sizeof(ebpf_map_definition_t), - .type = EBPF_MAP_TYPE_ARRAY, + .type = BPF_MAP_TYPE_ARRAY, .key_size = sizeof(uint32_t), .value_size = sizeof(uint64_t), .max_entries = 1}; @@ -29,7 +29,7 @@ DropPacket(xdp_md_t* ctx) if (iphdr->Protocol == 17) { if (ntohs(udphdr->length) <= sizeof(UDP_HEADER)) { long key = 0; - long* count = ebpf_map_lookup_element(&port_map, &key); + long* count = bpf_map_lookup_elem(&port_map, &key); if (count) *count = (*count + 1); rc = XDP_DROP; diff --git a/tests/sample/droppacket_unsafe.c b/tests/sample/droppacket_unsafe.c index 2d8e0854b..affa4e412 100644 --- a/tests/sample/droppacket_unsafe.c +++ b/tests/sample/droppacket_unsafe.c @@ -10,7 +10,7 @@ #pragma clang section data = "maps" ebpf_map_definition_t port_map = {.size = sizeof(ebpf_map_definition_t), - .type = EBPF_MAP_TYPE_ARRAY, + .type = BPF_MAP_TYPE_ARRAY, .key_size = sizeof(uint32_t), .value_size = sizeof(uint64_t), .max_entries = 1}; @@ -27,7 +27,7 @@ DropPacket(xdp_md_t* ctx) if (iphdr->Protocol == 17) { if (ntohs(udphdr->length) <= sizeof(UDP_HEADER)) { long key = 0; - long* count = ebpf_map_lookup_element(&port_map, &key); + long* count = bpf_map_lookup_elem(&port_map, &key); if (count) *count = (*count + 1); rc = XDP_DROP; diff --git a/tests/sample/ebpf.h b/tests/sample/ebpf.h index df48d6680..3eaf48a9d 100644 --- a/tests/sample/ebpf.h +++ b/tests/sample/ebpf.h @@ -14,8 +14,10 @@ typedef unsigned char uint8_t; #include "ebpf_helpers.h" #include "ebpf_nethooks.h" +#if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union +#endif uint16_t ntohs(uint16_t us) @@ -72,4 +74,6 @@ typedef struct UDP_HEADER_ uint16_t checksum; } UDP_HEADER; -#pragma warning(pop) \ No newline at end of file +#if defined(_MSC_VER) +#pragma warning(pop) +#endif diff --git a/tests/sample/repro.c b/tests/sample/repro.c index 118fa00a6..a4a1fd9e6 100644 --- a/tests/sample/repro.c +++ b/tests/sample/repro.c @@ -22,7 +22,7 @@ typedef unsigned char uint8_t; #pragma clang section data = "maps" ebpf_map_definition_t test_map = {.size = sizeof(ebpf_map_definition_t), - .type = EBPF_MAP_TYPE_HASH, + .type = BPF_MAP_TYPE_HASH, .key_size = sizeof(uint64_t), .value_size = sizeof(uint64_t), .max_entries = 1}; @@ -33,7 +33,7 @@ BindMonitor(bind_md_t* ctx) { uint64_t key = ctx->process_id; - uint64_t* value = ebpf_map_lookup_element(&test_map, &key); + uint64_t* value = bpf_map_lookup_elem(&test_map, &key); *value = 1; diff --git a/tests/sample/test_ebpf.c b/tests/sample/test_ebpf.c index a0c06023e..87f4e86a3 100644 --- a/tests/sample/test_ebpf.c +++ b/tests/sample/test_ebpf.c @@ -9,7 +9,7 @@ #pragma clang section data = "maps" ebpf_map_definition_t test_map = {.size = sizeof(ebpf_map_definition_t), - .type = EBPF_MAP_TYPE_ARRAY, + .type = BPF_MAP_TYPE_ARRAY, .key_size = sizeof(uint32_t), .value_size = sizeof(uint64_t), .max_entries = 128}; diff --git a/tests/unit/test.vcxproj b/tests/unit/test.vcxproj index a0c8d8e19..4bdd93852 100644 --- a/tests/unit/test.vcxproj +++ b/tests/unit/test.vcxproj @@ -125,7 +125,7 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - $(SolutionDir)include;$(SolutionDir)libs\api;$(SolutionDir)libs\ebpfnetsh;$(SolutionDir)tests\libs\util;$(SolutionDir)tests\libs\common;$(OutDir);$(SolutionDir)external\ebpf-verifier\src;$(SolutionDir)libs\service;$(SolutionDir)rpc_interface;$(SolutionDir)libs\platform;$(SolutionDir)libs\platform\user;$(SolutionDir)libs\execution_context;$(SolutionDir)tests\end_to_end;$(SolutionDir)external\libbpf\src;%(AdditionalIncludeDirectories) + $(SolutionDir)include;$(SolutionDir)libs\api;$(SolutionDir)libs\ebpfnetsh;$(SolutionDir)tests\libs\util;$(SolutionDir)tests\libs\common;$(OutDir);$(SolutionDir)external\ebpf-verifier\src;$(SolutionDir)libs\service;$(SolutionDir)rpc_interface;$(SolutionDir)libs\platform;$(SolutionDir)libs\platform\user;$(SolutionDir)libs\execution_context;$(SolutionDir)tests\end_to_end;%(AdditionalIncludeDirectories) true stdcpp17 MultiThreadedDebug @@ -144,7 +144,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - $(SolutionDir)include;$(SolutionDir)libs\api;$(SolutionDir)libs\ebpfnetsh;$(SolutionDir)tests\libs\util;$(SolutionDir)tests\libs\common;$(OutDir);$(SolutionDir)external\ebpf-verifier\src;$(SolutionDir)libs\service;$(SolutionDir)rpc_interface;$(SolutionDir)libs\platform;$(SolutionDir)libs\platform\user;$(SolutionDir)libs\execution_context;$(SolutionDir)tests\end_to_end;$(SolutionDir)external\libbpf\src;%(AdditionalIncludeDirectories) + $(SolutionDir)include;$(SolutionDir)libs\api;$(SolutionDir)libs\ebpfnetsh;$(SolutionDir)tests\libs\util;$(SolutionDir)tests\libs\common;$(OutDir);$(SolutionDir)external\ebpf-verifier\src;$(SolutionDir)libs\service;$(SolutionDir)rpc_interface;$(SolutionDir)libs\platform;$(SolutionDir)libs\platform\user;$(SolutionDir)libs\execution_context;$(SolutionDir)tests\end_to_end;%(AdditionalIncludeDirectories) true stdcpp17 diff --git a/tools/encode_program_info/encode_program_info.cpp b/tools/encode_program_info/encode_program_info.cpp index 5ed4587ed..bd6a24615 100644 --- a/tools/encode_program_info/encode_program_info.cpp +++ b/tools/encode_program_info/encode_program_info.cpp @@ -33,15 +33,15 @@ _emit_program_info_file(const char* file_name, const char* symbol_name, uint8_t* static ebpf_helper_function_prototype_t _ebpf_helper_function_prototype[] = { {1, - "ebpf_map_lookup_element", + "bpf_map_lookup_elem", EBPF_RETURN_TYPE_PTR_TO_MAP_VALUE_OR_NULL, {EBPF_ARGUMENT_TYPE_PTR_TO_MAP, EBPF_ARGUMENT_TYPE_PTR_TO_MAP_KEY}}, {2, - "ebpf_map_update_element", + "bpf_map_update_elem", EBPF_RETURN_TYPE_INTEGER, {EBPF_ARGUMENT_TYPE_PTR_TO_MAP, EBPF_ARGUMENT_TYPE_PTR_TO_MAP_KEY, EBPF_ARGUMENT_TYPE_PTR_TO_MAP_VALUE}}, {3, - "ebpf_map_delete_element", + "bpf_map_delete_elem", EBPF_RETURN_TYPE_INTEGER, {EBPF_ARGUMENT_TYPE_PTR_TO_MAP, EBPF_ARGUMENT_TYPE_PTR_TO_MAP_KEY}}};