2021-08-11 03:04:07 +03:00
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
// SPDX-License-Identifier: MIT
|
2021-03-10 05:38:31 +03:00
|
|
|
|
|
|
|
#pragma once
|
2021-05-11 23:46:00 +03:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2021-06-09 18:44:24 +03:00
|
|
|
#include "ebpf_core_structs.h"
|
2021-09-15 22:08:18 +03:00
|
|
|
#include "ebpf_execution_type.h"
|
2022-02-26 04:53:12 +03:00
|
|
|
#include "ebpf_program_attach_type_guids.h"
|
2021-06-09 18:44:24 +03:00
|
|
|
#include "ebpf_result.h"
|
2021-03-10 05:38:31 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2022-08-08 03:21:23 +03:00
|
|
|
#include <stdexcept>
|
|
|
|
#define EBPF_NO_EXCEPT noexcept
|
2021-03-10 05:38:31 +03:00
|
|
|
extern "C"
|
|
|
|
{
|
2022-08-08 03:21:23 +03:00
|
|
|
#else
|
|
|
|
#define EBPF_NO_EXCEPT
|
2021-03-10 05:38:31 +03:00
|
|
|
#endif
|
|
|
|
|
2021-06-23 06:42:18 +03:00
|
|
|
typedef int32_t fd_t;
|
2021-09-24 05:32:09 +03:00
|
|
|
extern __declspec(selectany) const fd_t ebpf_fd_invalid = -1;
|
2021-09-14 18:25:56 +03:00
|
|
|
typedef intptr_t ebpf_handle_t;
|
2021-03-10 05:38:31 +03:00
|
|
|
|
2021-08-04 03:25:50 +03:00
|
|
|
struct bpf_object;
|
|
|
|
struct bpf_program;
|
|
|
|
struct bpf_map;
|
2021-08-11 03:04:07 +03:00
|
|
|
struct bpf_link;
|
|
|
|
|
2021-03-15 18:34:33 +03:00
|
|
|
/**
|
2021-07-07 21:16:35 +03:00
|
|
|
* @brief Query info about an eBPF program.
|
2021-08-11 03:04:07 +03:00
|
|
|
* @param[in] fd File descriptor of an eBPF program.
|
2021-06-01 18:47:26 +03:00
|
|
|
* @param[out] execution_type On success, contains the execution type.
|
2021-05-26 22:01:58 +03:00
|
|
|
* @param[out] file_name On success, contains the file name.
|
|
|
|
* @param[out] section_name On success, contains the section name.
|
2021-08-11 03:04:07 +03:00
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
2021-03-15 18:34:33 +03:00
|
|
|
*/
|
2021-08-11 03:04:07 +03:00
|
|
|
ebpf_result_t
|
|
|
|
ebpf_program_query_info(
|
|
|
|
fd_t fd,
|
|
|
|
_Out_ ebpf_execution_type_t* execution_type,
|
|
|
|
_Outptr_result_z_ const char** file_name,
|
|
|
|
_Outptr_result_z_ const char** section_name);
|
2021-03-15 18:34:33 +03:00
|
|
|
|
2022-05-12 00:06:49 +03:00
|
|
|
typedef struct _ebpf_stat
|
|
|
|
{
|
|
|
|
struct _ebpf_stat* next;
|
|
|
|
_Field_z_ const char* key;
|
|
|
|
int value;
|
|
|
|
} ebpf_stat_t;
|
|
|
|
|
|
|
|
typedef struct _ebpf_section_info
|
|
|
|
{
|
|
|
|
struct _ebpf_section_info* next;
|
|
|
|
_Field_z_ const char* section_name;
|
|
|
|
_Field_z_ const char* program_type_name;
|
2022-05-25 00:53:04 +03:00
|
|
|
_Field_z_ const char* program_name;
|
2022-06-15 18:59:39 +03:00
|
|
|
ebpf_program_type_t program_type;
|
|
|
|
ebpf_attach_type_t expected_attach_type;
|
2022-05-12 00:06:49 +03:00
|
|
|
size_t raw_data_size;
|
|
|
|
_Field_size_(raw_data_size) char* raw_data;
|
|
|
|
ebpf_stat_t* stats;
|
|
|
|
} ebpf_section_info_t;
|
|
|
|
|
2021-03-10 05:38:31 +03:00
|
|
|
/**
|
2022-05-12 00:06:49 +03:00
|
|
|
- * @brief Get list of programs and stats in an eBPF file.
|
|
|
|
- * @param[in] file Name of file containing eBPF programs.
|
|
|
|
- * @param[in] verbose Obtain additional info about the programs.
|
|
|
|
- * @param[out] infos On success points to a list of eBPF programs.
|
2022-05-25 00:53:04 +03:00
|
|
|
* The caller is responsible for freeing the list via ebpf_free_sections().
|
2022-05-12 00:06:49 +03:00
|
|
|
- * @param[out] error_message On failure points to a text description of
|
|
|
|
- * the error.
|
|
|
|
*/
|
|
|
|
ebpf_result_t
|
|
|
|
ebpf_enumerate_sections(
|
|
|
|
_In_z_ const char* file,
|
2021-03-10 05:38:31 +03:00
|
|
|
bool verbose,
|
2022-05-12 00:06:49 +03:00
|
|
|
_Outptr_result_maybenull_ ebpf_section_info_t** infos,
|
|
|
|
_Outptr_result_maybenull_z_ const char** error_message);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Free memory returned from \ref ebpf_enumerate_sections.
|
|
|
|
* @param[in] data Memory to free.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ebpf_free_sections(_In_opt_ ebpf_section_info_t* infos);
|
2021-03-10 05:38:31 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Convert an eBPF program to human readable byte code.
|
|
|
|
* @param[in] file Name of ELF file containing eBPF program.
|
|
|
|
* @param[in] section The name of the section to query.
|
2021-04-20 01:43:45 +03:00
|
|
|
* @param[out] disassembly On success points text version of the program.
|
2021-03-10 05:38:31 +03:00
|
|
|
* @param[out] error_message On failure points to a text description of
|
|
|
|
* the error.
|
|
|
|
*/
|
|
|
|
uint32_t
|
|
|
|
ebpf_api_elf_disassemble_section(
|
2022-08-04 20:11:12 +03:00
|
|
|
_In_z_ const char* file,
|
|
|
|
_In_z_ const char* section,
|
|
|
|
_Outptr_result_maybenull_z_ const char** disassembly,
|
|
|
|
_Outptr_result_maybenull_z_ const char** error_message);
|
2021-03-10 05:38:31 +03:00
|
|
|
|
2021-06-02 21:22:06 +03:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int total_unreachable;
|
|
|
|
int total_warnings;
|
|
|
|
int max_instruction_count;
|
|
|
|
} ebpf_api_verifier_stats_t;
|
|
|
|
|
2021-03-10 05:38:31 +03:00
|
|
|
/**
|
2022-04-18 21:52:55 +03:00
|
|
|
* @brief Verify that the program is safe to execute.
|
2021-03-10 05:38:31 +03:00
|
|
|
* @param[in] file Name of ELF file containing eBPF program.
|
|
|
|
* @param[in] section The name of the section to query.
|
2022-06-15 18:59:39 +03:00
|
|
|
* @param[in] program_type Optional program type.
|
|
|
|
* If NULL, the program type is derived from the section name.
|
2021-07-07 21:16:35 +03:00
|
|
|
* @param[in] verbose Obtain additional info about the programs.
|
2021-03-10 05:38:31 +03:00
|
|
|
* @param[out] report Points to a text section describing why the program
|
|
|
|
* failed verification.
|
|
|
|
* @param[out] error_message On failure points to a text description of
|
|
|
|
* the error.
|
2021-06-02 21:22:06 +03:00
|
|
|
* @param[out] stats If non-NULL, returns verification statistics.
|
2022-07-18 22:39:50 +03:00
|
|
|
* @retval 0 Verification succeeded.
|
|
|
|
* @retval 1 Verification failed.
|
2021-03-10 05:38:31 +03:00
|
|
|
*/
|
2022-07-18 22:39:50 +03:00
|
|
|
_Success_(return == 0) uint32_t ebpf_api_elf_verify_section_from_file(
|
2022-06-15 18:59:39 +03:00
|
|
|
_In_z_ const char* file,
|
|
|
|
_In_z_ const char* section,
|
|
|
|
_In_opt_ const ebpf_program_type_t* program_type,
|
2021-06-02 21:22:06 +03:00
|
|
|
bool verbose,
|
2022-07-18 22:39:50 +03:00
|
|
|
_Outptr_result_maybenull_z_ const char** report,
|
|
|
|
_Outptr_result_maybenull_z_ const char** error_message,
|
|
|
|
_Out_opt_ ebpf_api_verifier_stats_t* stats);
|
2021-03-10 05:38:31 +03:00
|
|
|
|
2022-04-18 21:52:55 +03:00
|
|
|
/**
|
|
|
|
* @brief Verify that the program is safe to execute.
|
|
|
|
* @param[in] data Memory containing the ELF file containing eBPF program.
|
|
|
|
* @param[in] data_length Length of data.
|
|
|
|
* @param[in] section The name of the section to query.
|
2022-06-15 18:59:39 +03:00
|
|
|
* @param[in] program_type Optional program type.
|
|
|
|
* If NULL, the program type is derived from the section name.
|
2022-04-18 21:52:55 +03:00
|
|
|
* @param[in] verbose Obtain additional info about the programs.
|
|
|
|
* @param[out] report Points to a text section describing why the program
|
|
|
|
* failed verification.
|
|
|
|
* @param[out] error_message On failure points to a text description of
|
|
|
|
* the error.
|
|
|
|
* @param[out] stats If non-NULL, returns verification statistics.
|
2022-07-18 22:39:50 +03:00
|
|
|
* @retval 0 Verification succeeded.
|
|
|
|
* @retval 1 Verification failed.
|
2022-04-18 21:52:55 +03:00
|
|
|
*/
|
2022-07-18 22:39:50 +03:00
|
|
|
_Success_(return == 0) uint32_t ebpf_api_elf_verify_section_from_memory(
|
2022-06-15 18:59:39 +03:00
|
|
|
_In_reads_(data_length) const char* data,
|
2022-04-18 21:52:55 +03:00
|
|
|
size_t data_length,
|
2022-06-15 18:59:39 +03:00
|
|
|
_In_z_ const char* section,
|
|
|
|
_In_opt_ const ebpf_program_type_t* program_type,
|
2022-04-18 21:52:55 +03:00
|
|
|
bool verbose,
|
2022-07-18 22:39:50 +03:00
|
|
|
_Outptr_result_maybenull_z_ const char** report,
|
|
|
|
_Outptr_result_maybenull_z_ const char** error_message,
|
|
|
|
_Out_opt_ ebpf_api_verifier_stats_t* stats);
|
2022-04-18 21:52:55 +03:00
|
|
|
|
2021-03-10 05:38:31 +03:00
|
|
|
/**
|
2021-07-02 00:27:24 +03:00
|
|
|
* @brief Free memory for a string returned from an eBPF API.
|
2021-03-15 18:34:33 +03:00
|
|
|
* @param[in] string Memory to free.
|
2021-03-10 05:38:31 +03:00
|
|
|
*/
|
|
|
|
void
|
2021-06-26 01:02:05 +03:00
|
|
|
ebpf_free_string(_In_opt_ _Post_invalid_ const char* string);
|
2021-03-10 05:38:31 +03:00
|
|
|
|
|
|
|
/**
|
2021-04-30 21:49:23 +03:00
|
|
|
* @brief Dissociate a name with an object handle.
|
2021-04-20 01:43:45 +03:00
|
|
|
* @param[in] name Name to dissociate.
|
2021-05-26 22:01:58 +03:00
|
|
|
* @param[in] name_length Length in bytes of the name.
|
2021-03-10 05:38:31 +03:00
|
|
|
*/
|
|
|
|
uint32_t
|
2021-04-30 21:49:23 +03:00
|
|
|
ebpf_api_unpin_object(const uint8_t* name, uint32_t name_length);
|
2021-03-10 05:38:31 +03:00
|
|
|
|
2021-08-11 03:04:07 +03:00
|
|
|
/**
|
|
|
|
* @brief Unpin the object from the specified path.
|
|
|
|
* @param[in] path Path from which to unpin.
|
|
|
|
*
|
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
*/
|
|
|
|
ebpf_result_t
|
|
|
|
ebpf_object_unpin(_In_z_ const char* path);
|
|
|
|
|
2021-03-10 05:38:31 +03:00
|
|
|
/**
|
2021-04-27 01:37:12 +03:00
|
|
|
* @brief Find a map given its associated name.
|
2021-03-10 05:38:31 +03:00
|
|
|
* @param[in] name Name to find.
|
2021-05-26 22:01:58 +03:00
|
|
|
* @param[in] name_length Length in bytes of name to find.
|
|
|
|
* @param[out] handle Pointer to memory that contains the map handle on success.
|
2021-03-10 05:38:31 +03:00
|
|
|
*/
|
|
|
|
uint32_t
|
2021-04-20 01:43:45 +03:00
|
|
|
ebpf_api_get_pinned_map(const uint8_t* name, uint32_t name_length, ebpf_handle_t* handle);
|
2021-03-10 05:38:31 +03:00
|
|
|
|
2021-07-31 03:17:16 +03:00
|
|
|
/**
|
|
|
|
* @brief Detach the eBPF program from the link.
|
|
|
|
*
|
|
|
|
* @param[in] link_handle Handle to the link.
|
|
|
|
*
|
2022-05-19 21:14:42 +03:00
|
|
|
* @retval EBPF_SUCCESS The operations succeeded.
|
|
|
|
* @retval EBPF_INVALID_ARGUMENT The link handle is invalid.
|
2021-07-31 03:17:16 +03:00
|
|
|
*/
|
2022-05-19 21:14:42 +03:00
|
|
|
ebpf_result_t
|
2021-07-31 03:17:16 +03:00
|
|
|
ebpf_api_unlink_program(ebpf_handle_t link_handle);
|
|
|
|
|
2021-04-28 01:21:21 +03:00
|
|
|
/**
|
2021-06-23 06:42:18 +03:00
|
|
|
* @brief Close an eBPF handle.
|
2021-04-28 01:21:21 +03:00
|
|
|
*
|
2021-06-23 06:42:18 +03:00
|
|
|
* @param[in] handle Handle to close.
|
2021-08-24 21:33:00 +03:00
|
|
|
* @retval EBPF_SUCCESS Handle was closed.
|
|
|
|
* @retval EBPF_INVALID_OBJECT Handle is not valid.
|
2021-04-28 01:21:21 +03:00
|
|
|
*/
|
2021-08-24 21:33:00 +03:00
|
|
|
ebpf_result_t
|
2021-04-28 01:21:21 +03:00
|
|
|
ebpf_api_close_handle(ebpf_handle_t handle);
|
|
|
|
|
2021-06-09 18:44:24 +03:00
|
|
|
/**
|
2021-07-07 21:16:35 +03:00
|
|
|
* @brief Returns an array of \ref ebpf_map_info_t for all pinned maps.
|
2021-06-09 18:44:24 +03:00
|
|
|
*
|
|
|
|
* @param[out] map_count Number of pinned maps.
|
2021-07-07 21:16:35 +03:00
|
|
|
* @param[out] map_info Array of ebpf_map_info_t for pinned maps.
|
2021-06-09 18:44:24 +03:00
|
|
|
*
|
|
|
|
* @retval EBPF_SUCCESS The API suceeded.
|
|
|
|
* @retval EBPF_NO_MEMORY Out of memory.
|
|
|
|
* @retval EBPF_INVALID_ARGUMENT One or more parameters are wrong.
|
|
|
|
*/
|
|
|
|
ebpf_result_t
|
|
|
|
ebpf_api_get_pinned_map_info(
|
2021-07-07 21:16:35 +03:00
|
|
|
_Out_ uint16_t* map_count, _Outptr_result_buffer_maybenull_(*map_count) ebpf_map_info_t** map_info);
|
2021-06-09 18:44:24 +03:00
|
|
|
|
|
|
|
/**
|
2021-07-07 21:16:35 +03:00
|
|
|
* @brief Helper Function to free array of \ref ebpf_map_info_t allocated by
|
2021-07-02 00:27:24 +03:00
|
|
|
* \ref ebpf_api_get_pinned_map_info function.
|
2021-06-09 18:44:24 +03:00
|
|
|
*
|
|
|
|
* @param[in] map_count Length of array to be freed.
|
|
|
|
* @param[in] map_info Map to be freed.
|
|
|
|
*/
|
|
|
|
void
|
2021-06-30 00:51:41 +03:00
|
|
|
ebpf_api_map_info_free(
|
2021-07-07 21:16:35 +03:00
|
|
|
uint16_t map_count, _In_opt_count_(map_count) _Post_ptr_invalid_ const ebpf_map_info_t* map_info);
|
2021-06-09 18:44:24 +03:00
|
|
|
|
2021-06-23 06:42:18 +03:00
|
|
|
/**
|
2022-05-25 00:53:04 +03:00
|
|
|
* @brief Get the execution type for an eBPF object file.
|
2021-06-23 06:42:18 +03:00
|
|
|
*
|
2022-05-25 00:53:04 +03:00
|
|
|
* @param[in] object The eBPF object file.
|
2021-06-23 06:42:18 +03:00
|
|
|
*
|
2022-05-25 00:53:04 +03:00
|
|
|
* @returns Execution type.
|
|
|
|
*/
|
|
|
|
ebpf_execution_type_t
|
|
|
|
ebpf_object_get_execution_type(_In_ struct bpf_object* object);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set the execution type for an eBPF object file.
|
|
|
|
*
|
|
|
|
* @param[in] object The eBPF object file.
|
|
|
|
* @param[in] execution_type Execution type to set.
|
2021-06-23 06:42:18 +03:00
|
|
|
*
|
2022-05-25 00:53:04 +03:00
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
2021-06-23 06:42:18 +03:00
|
|
|
* @retval EBPF_INVALID_ARGUMENT One or more parameters are incorrect.
|
|
|
|
*/
|
|
|
|
ebpf_result_t
|
2022-05-25 00:53:04 +03:00
|
|
|
ebpf_object_set_execution_type(_In_ struct bpf_object* object, ebpf_execution_type_t execution_type);
|
2021-06-23 06:42:18 +03:00
|
|
|
|
2021-08-11 03:04:07 +03:00
|
|
|
/**
|
|
|
|
* @brief Attach an eBPF program.
|
|
|
|
*
|
|
|
|
* @param[in] program Pointer to the eBPF program.
|
|
|
|
* @param[in] attach_type Optionally, the attach type for attaching the program.
|
|
|
|
* If attach type is not specified, then the earlier provided attach type
|
|
|
|
* or attach type derived from section prefix will be used to attach the
|
|
|
|
* program.
|
|
|
|
* @param[in] attach_params_size Size of the attach parameters.
|
|
|
|
* @param[in] attach_parameters Optionally, attach parameters. This is an
|
|
|
|
* opaque flat buffer containing the attach parameters which is interpreted
|
|
|
|
* by the extension provider.
|
|
|
|
* @param[out] link Pointer to ebpf_link structure.
|
|
|
|
*
|
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
*/
|
|
|
|
ebpf_result_t
|
|
|
|
ebpf_program_attach(
|
2022-02-09 00:21:19 +03:00
|
|
|
_In_ const struct bpf_program* program,
|
2021-08-11 03:04:07 +03:00
|
|
|
_In_opt_ const ebpf_attach_type_t* attach_type,
|
|
|
|
_In_reads_bytes_opt_(attach_params_size) void* attach_parameters,
|
|
|
|
_In_ size_t attach_params_size,
|
|
|
|
_Outptr_ struct bpf_link** link);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Attach an eBPF program by program file descriptor.
|
|
|
|
*
|
|
|
|
* @param[in] program_fd An eBPF program file descriptor.
|
|
|
|
* @param[in] attach_type Optionally, the attach type for attaching the program.
|
|
|
|
* If attach type is not specified, then the earlier provided attach type
|
|
|
|
* or attach type derived from section prefix will be used to attach the
|
|
|
|
* program.
|
2022-02-15 03:40:56 +03:00
|
|
|
* @param[in] attach_parameters_size Size of the attach parameters.
|
2021-08-11 03:04:07 +03:00
|
|
|
* @param[in] attach_parameters Optionally, attach parameters. This is an
|
|
|
|
* opaque flat buffer containing the attach parameters which is interpreted
|
|
|
|
* by the extension provider.
|
|
|
|
* @param[out] link Pointer to ebpf_link structure.
|
|
|
|
*
|
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
*/
|
|
|
|
ebpf_result_t
|
|
|
|
ebpf_program_attach_by_fd(
|
|
|
|
fd_t program_fd,
|
|
|
|
_In_opt_ const ebpf_attach_type_t* attach_type,
|
2022-02-15 03:40:56 +03:00
|
|
|
_In_reads_bytes_opt_(attach_parameters_size) void* attach_parameters,
|
|
|
|
_In_ size_t attach_parameters_size,
|
2021-08-11 03:04:07 +03:00
|
|
|
_Outptr_ struct bpf_link** link);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Detach an eBPF program from an attach point represented by
|
|
|
|
* the bpf_link structure.
|
|
|
|
*
|
|
|
|
* @param[in] link Pointer to bpf_link structure.
|
|
|
|
*
|
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
* @retval EBPF_INVALID_OBJECT Invalid object was passed.
|
|
|
|
*/
|
|
|
|
ebpf_result_t
|
|
|
|
ebpf_link_detach(_In_ struct bpf_link* link);
|
|
|
|
|
2022-08-08 03:21:23 +03:00
|
|
|
/**
|
|
|
|
* @brief Detach an eBPF program.
|
|
|
|
*
|
|
|
|
* @param[in] program_fd File descriptor of program to detach. If set to -1,
|
|
|
|
* this parameter is ignored.
|
|
|
|
* @param[in] attach_type The attach type for attaching the program.
|
|
|
|
* @param[in] attach_parameter_size Size of the attach parameter.
|
|
|
|
* @param[in] attach_parameter Pointer to attach parameter. This is an
|
|
|
|
* opaque flat buffer containing the attach parameters which is interpreted
|
|
|
|
* by the extension provider.
|
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
* @retval EBPF_INVALID_OBJECT Invalid object was passed.
|
|
|
|
*/
|
|
|
|
ebpf_result_t
|
|
|
|
ebpf_program_detach(
|
|
|
|
fd_t program_fd,
|
|
|
|
_In_ const ebpf_attach_type_t* attach_type,
|
|
|
|
_In_reads_bytes_(attach_parameter_size) void* attach_parameter,
|
|
|
|
size_t attach_parameter_size) EBPF_NO_EXCEPT;
|
|
|
|
|
2021-08-11 03:04:07 +03:00
|
|
|
/**
|
|
|
|
* Clean up and free bpf_link structure. Also close the
|
|
|
|
* underlying link fd.
|
|
|
|
*
|
|
|
|
* @param[in] link Pointer to the bpf_link structure.
|
|
|
|
*
|
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
* @retval EBPF_INVALID_ARGUMENT Invalid argument was provided.
|
2021-09-07 20:51:18 +03:00
|
|
|
*
|
|
|
|
* @sa bpf_link__destroy
|
|
|
|
* @sa bpf_link_detach
|
2021-08-11 03:04:07 +03:00
|
|
|
*/
|
|
|
|
ebpf_result_t
|
2022-04-29 00:31:33 +03:00
|
|
|
ebpf_link_close(_In_ _Post_invalid_ struct bpf_link* link);
|
2021-08-11 03:04:07 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Close a file descriptor. Also close the underlying handle.
|
|
|
|
* @param [in] fd File descriptor to be closed.
|
|
|
|
*
|
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
* @retval EBPF_INVALID_FD Invalid fd was provided.
|
|
|
|
*/
|
|
|
|
ebpf_result_t
|
|
|
|
ebpf_close_fd(fd_t fd);
|
|
|
|
|
2021-09-15 22:08:18 +03:00
|
|
|
/**
|
2022-07-01 02:53:03 +03:00
|
|
|
* @brief Get eBPF program type and expected attach type by name.
|
2021-09-15 22:08:18 +03:00
|
|
|
*
|
|
|
|
* @param[in] name Name, as if it were a section name in an ELF file.
|
2022-07-01 02:53:03 +03:00
|
|
|
* @param[out] program_type eBPF program type.
|
|
|
|
* @param[out] expected_attach_type Expected eBPF attach type.
|
2021-09-15 22:08:18 +03:00
|
|
|
*
|
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
* @retval EBPF_KEY_NOT_FOUND No program type was found.
|
|
|
|
*/
|
|
|
|
ebpf_result_t
|
|
|
|
ebpf_get_program_type_by_name(
|
|
|
|
_In_z_ const char* name,
|
|
|
|
_Out_ ebpf_program_type_t* program_type,
|
|
|
|
_Out_ ebpf_attach_type_t* expected_attach_type);
|
|
|
|
|
2021-09-28 19:45:22 +03:00
|
|
|
/**
|
|
|
|
* @brief Get the name of a given program type.
|
|
|
|
*
|
|
|
|
* @param[in] program_type Program type.
|
|
|
|
*
|
|
|
|
* @returns Name of the program type, or NULL if not found.
|
|
|
|
*/
|
|
|
|
_Ret_maybenull_z_ const char*
|
|
|
|
ebpf_get_program_type_name(_In_ const ebpf_program_type_t* program_type);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the name of a given attach type.
|
|
|
|
*
|
|
|
|
* @param[in] attach_type Attach type.
|
|
|
|
*
|
|
|
|
* @returns Name of the attach type, or NULL if not found.
|
|
|
|
*/
|
|
|
|
_Ret_maybenull_z_ const char*
|
|
|
|
ebpf_get_attach_type_name(_In_ const ebpf_attach_type_t* attach_type);
|
|
|
|
|
2021-09-16 04:40:44 +03:00
|
|
|
/**
|
2021-09-18 02:41:43 +03:00
|
|
|
* @brief Gets the next pinned program after a given path.
|
2021-09-16 04:40:44 +03:00
|
|
|
*
|
2021-09-18 02:41:43 +03:00
|
|
|
* @param[in] start_path Path to look for an entry greater than.
|
|
|
|
* @param[out] next_path Returns the next path, if one exists.
|
2021-09-16 04:40:44 +03:00
|
|
|
*
|
|
|
|
* @retval EBPF_SUCCESS The operation was successful.
|
|
|
|
* @retval EBPF_NO_MORE_KEYS No more entries found.
|
|
|
|
*/
|
|
|
|
ebpf_result_t
|
2021-09-18 02:41:43 +03:00
|
|
|
ebpf_get_next_pinned_program_path(
|
|
|
|
_In_z_ const char* start_path, _Out_writes_z_(EBPF_MAX_PIN_PATH_LENGTH) char* next_path);
|
2021-09-16 04:40:44 +03:00
|
|
|
|
2021-03-10 05:38:31 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|