eBPF for Windows
|
#include "libbpf_legacy.h"
Go to the source code of this file.
Functions | |
__u32 | bpf_program__flags (const struct bpf_program *prog) |
Query the BPF program flags. | |
int | bpf_program__set_flags (struct bpf_program *prog, __u32 flags) |
Set the BPF program flags. The set of flags is defined by the program type. Neither libbpf nor the eBPF runtime check the flags and only the extension that handles this program type will interpret them. See the documentation for the program type for what flags are defined for that program type. | |
LIBBPF_API struct perf_buffer * | perf_buffer__new (int map_fd, size_t page_cnt, perf_buffer_sample_fn sample_cb, perf_buffer_lost_fn lost_cb, void *ctx, const struct perf_buffer_opts *opts) |
Create BPF perfbuf manager. | |
LIBBPF_API void | perf_buffer__free (struct perf_buffer *pb) |
Free a perf buffer manager. | |
Link-related functions | |
int | bpf_link__destroy (struct bpf_link *link) |
Clean up a link. | |
void | bpf_link__disconnect (struct bpf_link *link) |
Release ownership of a link so that it is not detached when destroyed. | |
int | bpf_link__fd (const struct bpf_link *link) |
Get a file descriptor that refers to a link. | |
int | bpf_link__pin (struct bpf_link *link, const char *path) |
Pin a link to a specified path. | |
int | bpf_link__unpin (struct bpf_link *link) |
Unpin a link. | |
const char * | libbpf_bpf_link_type_str (enum bpf_link_type t) |
libbpf_bpf_link_type_str() converts the provided link type value into a textual representation. | |
Map-related functions | |
int | bpf_map__fd (const struct bpf_map *map) |
Get a file descriptor that refers to a map. | |
bool | bpf_map__is_pinned (const struct bpf_map *map) |
Determine whether a map is pinned. | |
__u32 | bpf_map__key_size (const struct bpf_map *map) |
Get the size of keys in a given map. | |
__u32 | bpf_map__max_entries (const struct bpf_map *map) |
Get the maximum number of entries allowed in a given map. | |
const char * | bpf_map__name (const struct bpf_map *map) |
Get the name of an eBPF map. | |
int | bpf_map__pin (struct bpf_map *map, const char *path) |
Pin a map to a specified path. | |
enum bpf_map_type | bpf_map__type (const struct bpf_map *map) |
Get the type of a map. | |
int | bpf_map__unpin (struct bpf_map *map, const char *path) |
Unpin a map. | |
__u32 | bpf_map__value_size (const struct bpf_map *map) |
Get the size of values in a given map. | |
const char * | libbpf_bpf_map_type_str (enum bpf_map_type t) |
libbpf_bpf_map_type_str() converts the provided map type value into a textual representation. | |
Object-related functions | |
void | bpf_object__close (struct bpf_object *object) |
Close an eBPF object. | |
struct bpf_map * | bpf_object__find_map_by_name (const struct bpf_object *obj, const char *name) |
bpf_object__find_map_by_name() returns BPF map of the given name, if it exists within the passed BPF object | |
int | bpf_object__find_map_fd_by_name (const struct bpf_object *obj, const char *name) |
Find a map with a given name among maps associated with an eBPF object. | |
struct bpf_program * | bpf_object__find_program_by_name (const struct bpf_object *obj, const char *name) |
Find a program with a given name among programs associated with an eBPF object. | |
int | bpf_object__load (struct bpf_object *obj) |
Load all the programs in a given object. | |
const char * | bpf_object__name (const struct bpf_object *obj) |
Get the name of an eBPF object. | |
struct bpf_map * | bpf_object__next_map (const struct bpf_object *obj, const struct bpf_map *map) |
Get the next map for a given eBPF object. | |
struct bpf_program * | bpf_object__next_program (const struct bpf_object *obj, struct bpf_program *prog) |
Get the next program for a given eBPF object. | |
struct bpf_object * | bpf_object__open (const char *path) |
Open a file without loading the programs. | |
struct bpf_object * | bpf_object__open_file (const char *path, const struct bpf_object_open_opts *opts) |
Open a file without loading the programs. | |
int | bpf_object__pin (struct bpf_object *object, const char *path) |
Pin an eBPF object to a specified path. | |
int | bpf_object__pin_maps (struct bpf_object *obj, const char *path) |
Pin all maps associated with an eBPF object to a specified path. | |
int | bpf_object__pin_programs (struct bpf_object *obj, const char *path) |
Pin all programs associated with an eBPF object to a specified path. | |
struct bpf_map * | bpf_object__prev_map (const struct bpf_object *obj, const struct bpf_map *map) |
Get the previous map for a given eBPF object. | |
struct bpf_program * | bpf_object__prev_program (const struct bpf_object *obj, struct bpf_program *prog) |
Get the previous eBPF program for a given eBPF object. | |
int | bpf_object__unpin_maps (struct bpf_object *obj, const char *path) |
Unpin all maps associated with an eBPF object from a specified path. | |
int | bpf_object__unpin_programs (struct bpf_object *obj, const char *path) |
Unpin all programs associated with an eBPF object from a specified path. | |
Program-related functions | |
struct bpf_link * | bpf_program__attach (const struct bpf_program *prog) |
bpf_program__attach() is a generic function for attaching a BPF program based on the program's expected attach type. | |
struct bpf_link * | bpf_program__attach_xdp (struct bpf_program *prog, int ifindex) |
Attach an eBPF program to an XDP hook. | |
bool | bpf_program__autoload (const struct bpf_program *prog) |
Get whether an eBPF program will be loaded when the object is loaded. | |
int | bpf_program__set_autoload (struct bpf_program *prog, bool autoload) |
Set whether an eBPF program will be loaded when the object is loaded. | |
int | bpf_prog_attach (int prog_fd, int attachable_fd, enum bpf_attach_type type, unsigned int flags) |
Attach an eBPF program to an attach point. | |
int | bpf_prog_detach (int attachable_fd, enum bpf_attach_type type) |
Detach eBPF program(s) from an attach point. | |
int | bpf_prog_detach2 (int prog_fd, int attachable_fd, enum bpf_attach_type type) |
Detach an eBPF program from an attach point. | |
int | bpf_program__fd (const struct bpf_program *prog) |
Get a file descriptor that refers to a program. | |
enum bpf_attach_type | bpf_program__get_expected_attach_type (const struct bpf_program *prog) |
Get the expected attach type for an eBPF program. | |
enum bpf_prog_type | bpf_program__get_type (const struct bpf_program *prog) |
Get the program type for an eBPF program. | |
size_t | bpf_program__insn_cnt (const struct bpf_program *prog) |
bpf_program__insn_cnt() returns number of struct bpf_insn 's that form specified BPF program. | |
const char * | bpf_program__name (const struct bpf_program *prog) |
Get the function name of an eBPF program. | |
int | bpf_program__pin (struct bpf_program *prog, const char *path) |
Pin a program to a specified path. This increments the programs reference count, allowing it to stay loaded after the process which loaded it has exited. | |
const char * | bpf_program__section_name (const struct bpf_program *prog) |
Gets the ELF section name of an eBPF program, if any. | |
int | bpf_program__set_expected_attach_type (struct bpf_program *prog, enum bpf_attach_type type) |
bpf_program__set_expected_attach_type() sets the attach type of the passed BPF program. This is used for auto-detection of attachment when programs are loaded. | |
int | bpf_program__set_type (struct bpf_program *prog, enum bpf_prog_type type) |
bpf_program__set_type() sets the program type of the passed BPF program. | |
enum bpf_prog_type | bpf_program__type (const struct bpf_program *prog) |
Get the program type for an eBPF program. | |
void | bpf_program__unload (struct bpf_program *prog) |
Unload a program. | |
int | bpf_program__unpin (struct bpf_program *prog, const char *path) |
Unpin a program. | |
int | bpf_xdp_attach (int ifindex, int prog_fd, __u32 flags, const struct bpf_xdp_attach_opts *opts) |
Attach an XDP program to a given interface. | |
int | bpf_xdp_detach (int ifindex, __u32 flags, const struct bpf_xdp_attach_opts *opts) |
Detach an XDP program from a given interface. | |
int | bpf_xdp_query_id (int ifindex, int flags, __u32 *prog_id) |
Get the XDP program id attached to a given interface index. | |
int | libbpf_attach_type_by_name (const char *name, enum bpf_attach_type *attach_type) |
libbpf_attach_type_by_name() converts the provided textual representation into an attach type value. | |
const char * | libbpf_bpf_attach_type_str (enum bpf_attach_type t) |
libbpf_bpf_attach_type_str() converts the provided attach type value into a textual representation. | |
const char * | libbpf_bpf_prog_type_str (enum bpf_prog_type t) |
libbpf_bpf_prog_type_str() converts the provided program type value into a textual representation. | |
int | libbpf_prog_type_by_name (const char *name, enum bpf_prog_type *prog_type, enum bpf_attach_type *expected_attach_type) |
Get a program type and expected attach type by name. | |
System-related functions | |
long | libbpf_get_error (const void *ptr) |
Get a negative error code based on errno and a possibly null pointer. | |
int | libbpf_strerror (int err, char *buf, size_t size) |
Get an error message. | |
int | libbpf_num_possible_cpus (void) |
Get the number of processors on the current system. | |
struct ring_buffer * | ring_buffer__new (int map_fd, ring_buffer_sample_fn sample_cb, void *ctx, const struct ring_buffer_opts *opts) |
Creates a new ring buffer manager. | |
void | ring_buffer__free (struct ring_buffer *rb) |
Frees a new ring buffer manager. | |
int bpf_link__destroy | ( | struct bpf_link * | link | ) |
Clean up a link.
Unless bpf_link__disconnect was called first, this API detaches the link. Either way, it then closes the link fd and frees the memory for the link.
[in] | link | Link to destroy. |
void bpf_link__disconnect | ( | struct bpf_link * | link | ) |
Release ownership of a link so that it is not detached when destroyed.
[in] | link | Link to disconnect. |
int bpf_link__fd | ( | const struct bpf_link * | link | ) |
Get a file descriptor that refers to a link.
[in] | link | Link to get a file descriptor for. |
int bpf_link__pin | ( | struct bpf_link * | link, |
const char * | path | ||
) |
Pin a link to a specified path.
[in] | link | Link to pin. |
[in] | path | Path to pin the link to. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
-EBUSY | A pin path was previously specified. |
-EEXIST | Something is already pinned to the specified path. |
-EINVAL | An invalid argument was provided. |
-ENOMEM | Out of memory. |
int bpf_link__unpin | ( | struct bpf_link * | link | ) |
Unpin a link.
[in] | link | Link to unpin. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
-EINVAL | An invalid argument was provided. |
-ENOENT | The link was not pinned. |
int bpf_map__fd | ( | const struct bpf_map * | map | ) |
Get a file descriptor that refers to a map.
[in] | map | Map to get a file descriptor for. |
bool bpf_map__is_pinned | ( | const struct bpf_map * | map | ) |
Determine whether a map is pinned.
[in] | map | Map to check. |
true | The map is pinned. |
false | The map is not pinned. |
Get the size of keys in a given map.
[in] | map | Map to check. |
Get the maximum number of entries allowed in a given map.
[in] | map | Map to check. |
const char * bpf_map__name | ( | const struct bpf_map * | map | ) |
Get the name of an eBPF map.
[in] | map | The map to check. |
int bpf_map__pin | ( | struct bpf_map * | map, |
const char * | path | ||
) |
Pin a map to a specified path.
[in] | map | Map to pin. |
[in] | path | Path to pin the map to. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
-EBUSY | A pin path was previously specified. |
-EEXIST | Something is already pinned to the specified path. |
-EINVAL | An invalid argument was provided. |
-ENOMEM | Out of memory. |
enum bpf_map_type bpf_map__type | ( | const struct bpf_map * | map | ) |
Get the type of a map.
[in] | map | Map to check. |
int bpf_map__unpin | ( | struct bpf_map * | map, |
const char * | path | ||
) |
Unpin a map.
[in] | map | Map to unpin. |
[in] | path | Path from which to unpin the map. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
-EINVAL | An invalid argument was provided. |
-ENOENT | The map was not pinned. |
Get the size of values in a given map.
[in] | map | Map to check. |
void bpf_object__close | ( | struct bpf_object * | object | ) |
struct bpf_map * bpf_object__find_map_by_name | ( | const struct bpf_object * | obj, |
const char * | name | ||
) |
bpf_object__find_map_by_name() returns BPF map of the given name, if it exists within the passed BPF object
obj | BPF object |
name | name of the BPF map |
int bpf_object__find_map_fd_by_name | ( | const struct bpf_object * | obj, |
const char * | name | ||
) |
Find a map with a given name among maps associated with an eBPF object.
[in] | obj | The object to check. |
[in] | name | The name to look for. |
struct bpf_program * bpf_object__find_program_by_name | ( | const struct bpf_object * | obj, |
const char * | name | ||
) |
Find a program with a given name among programs associated with an eBPF object.
[in] | obj | The object to check. |
[in] | name | The name to look for. |
int bpf_object__load | ( | struct bpf_object * | obj | ) |
Load all the programs in a given object.
[in] | obj | Object from which to load programs. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
-EINVAL | An invalid argument was provided. |
-ENOMEM | Out of memory. |
const char * bpf_object__name | ( | const struct bpf_object * | obj | ) |
Get the name of an eBPF object.
[in] | obj | The object to check. |
Get the next map for a given eBPF object.
[in] | obj | Object with maps. |
[in] | map | Previous map. |
struct bpf_program * bpf_object__next_program | ( | const struct bpf_object * | obj, |
struct bpf_program * | prog | ||
) |
Get the next program for a given eBPF object.
[in] | obj | Object with programs. |
[in] | prog | Previous program, or NULL to get the first program. |
struct bpf_object * bpf_object__open | ( | const char * | path | ) |
Open a file without loading the programs.
[in] | path | File name to open. |
struct bpf_object * bpf_object__open_file | ( | const char * | path, |
const struct bpf_object_open_opts * | opts | ||
) |
Open a file without loading the programs.
[in] | path | File name to open. |
opts | options for how to load the bpf object, this parameter is optional and can be set to NULL |
int bpf_object__pin | ( | struct bpf_object * | object, |
const char * | path | ||
) |
Pin an eBPF object to a specified path.
[in] | object | Object to pin. |
[in] | path | Path to pin the object to. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
-EBUSY | Something is already pinned to the specified path. |
-EINVAL | An invalid argument was provided. |
-ENOMEM | Out of memory. |
int bpf_object__pin_maps | ( | struct bpf_object * | obj, |
const char * | path | ||
) |
Pin all maps associated with an eBPF object to a specified path.
[in] | obj | Object to pin maps of. |
[in] | path | Path to pin the maps to. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
-EBUSY | Something is already pinned to the specified path. |
-EINVAL | An invalid argument was provided. |
-ENOMEM | Out of memory. |
int bpf_object__pin_programs | ( | struct bpf_object * | obj, |
const char * | path | ||
) |
Pin all programs associated with an eBPF object to a specified path.
[in] | obj | Object to pin programs of. |
[in] | path | Path to pin the programs to. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
-EBUSY | Something is already pinned to the specified path. |
-EINVAL | An invalid argument was provided. |
-ENOMEM | Out of memory. |
Get the previous map for a given eBPF object.
[in] | obj | Object with maps. |
[in] | map | Next map. |
struct bpf_program * bpf_object__prev_program | ( | const struct bpf_object * | obj, |
struct bpf_program * | prog | ||
) |
Get the previous eBPF program for a given eBPF object.
[in] | obj | Object with programs. |
[in] | prog | Next program. |
int bpf_object__unpin_maps | ( | struct bpf_object * | obj, |
const char * | path | ||
) |
Unpin all maps associated with an eBPF object from a specified path.
[in] | obj | Object to unpin maps of. |
[in] | path | Path from which to unpin the maps. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
-EINVAL | An invalid argument was provided. |
int bpf_object__unpin_programs | ( | struct bpf_object * | obj, |
const char * | path | ||
) |
Unpin all programs associated with an eBPF object from a specified path.
[in] | obj | Object to unpin programs of. |
[in] | path | Path from which to unpin the programs. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
-EINVAL | An invalid argument was provided. |
int bpf_prog_attach | ( | int | prog_fd, |
int | attachable_fd, | ||
enum bpf_attach_type | type, | ||
unsigned int | flags | ||
) |
Attach an eBPF program to an attach point.
[in] | prog_fd | File descriptor of the program to attach. |
[in] | attachable_fd | File descriptor corresponding to the attach point. |
[in] | type | Attach type. |
[in] | flags | Flags (currently 0). |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
int bpf_prog_detach | ( | int | attachable_fd, |
enum bpf_attach_type | type | ||
) |
Detach eBPF program(s) from an attach point.
[in] | attachable_fd | File descriptor corresponding to the attach point. |
[in] | type | Attach type. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
int bpf_prog_detach2 | ( | int | prog_fd, |
int | attachable_fd, | ||
enum bpf_attach_type | type | ||
) |
Detach an eBPF program from an attach point.
[in] | prog_fd | File descriptor of the program to detach. |
[in] | attachable_fd | File descriptor corresponding to the attach point. |
[in] | type | Attach type. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
struct bpf_link * bpf_program__attach | ( | const struct bpf_program * | prog | ) |
bpf_program__attach() is a generic function for attaching a BPF program based on the program's expected attach type.
prog | BPF program to attach. |
struct bpf_link * bpf_program__attach_xdp | ( | struct bpf_program * | prog, |
int | ifindex | ||
) |
Attach an eBPF program to an XDP hook.
[in] | prog | The program to attach. |
[in] | ifindex | The interface index to attach to. |
bool bpf_program__autoload | ( | const struct bpf_program * | prog | ) |
Get whether an eBPF program will be loaded when the object is loaded.
[in] | prog | The program to check. |
int bpf_program__fd | ( | const struct bpf_program * | prog | ) |
Get a file descriptor that refers to a program.
[in] | prog | Program to get a file descriptor for. |
__u32 bpf_program__flags | ( | const struct bpf_program * | prog | ) |
Query the BPF program flags.
[in] | prog | A pointer to the BPF program. |
enum bpf_attach_type bpf_program__get_expected_attach_type | ( | const struct bpf_program * | prog | ) |
Get the expected attach type for an eBPF program.
[in] | prog | Program to check. |
enum bpf_prog_type bpf_program__get_type | ( | const struct bpf_program * | prog | ) |
Get the program type for an eBPF program.
[in] | prog | Program to check. |
size_t bpf_program__insn_cnt | ( | const struct bpf_program * | prog | ) |
bpf_program__insn_cnt() returns number of struct bpf_insn
's that form specified BPF program.
[in] | prog | BPF program for which to return number of BPF instructions |
const char * bpf_program__name | ( | const struct bpf_program * | prog | ) |
Get the function name of an eBPF program.
[in] | prog | Program to check. |
int bpf_program__pin | ( | struct bpf_program * | prog, |
const char * | path | ||
) |
Pin a program to a specified path. This increments the programs reference count, allowing it to stay loaded after the process which loaded it has exited.
[in] | prog | Program to pin. |
[in] | path | Path to pin the program to. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
-EBUSY | A pin path was previously specified. |
-EEXIST | Something is already pinned to the specified path. |
-EINVAL | An invalid argument was provided. |
-ENOMEM | Out of memory. |
const char * bpf_program__section_name | ( | const struct bpf_program * | prog | ) |
Gets the ELF section name of an eBPF program, if any.
[in] | prog | An eBPF program. |
int bpf_program__set_autoload | ( | struct bpf_program * | prog, |
bool | autoload | ||
) |
Set whether an eBPF program will be loaded when the object is loaded.
[in] | prog | The program to update. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
int bpf_program__set_expected_attach_type | ( | struct bpf_program * | prog, |
enum bpf_attach_type | type | ||
) |
bpf_program__set_expected_attach_type() sets the attach type of the passed BPF program. This is used for auto-detection of attachment when programs are loaded.
prog | BPF program to set the attach type for |
type | attach type to set the BPF map to have |
This must be called before the BPF object is loaded, otherwise it has no effect and an error is returned.
int bpf_program__set_flags | ( | struct bpf_program * | prog, |
__u32 | flags | ||
) |
Set the BPF program flags. The set of flags is defined by the program type. Neither libbpf nor the eBPF runtime check the flags and only the extension that handles this program type will interpret them. See the documentation for the program type for what flags are defined for that program type.
[in] | prog | A pointer to the BPF program. |
[in] | flags | The flags to set. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
int bpf_program__set_type | ( | struct bpf_program * | prog, |
enum bpf_prog_type | type | ||
) |
bpf_program__set_type() sets the program type of the passed BPF program.
prog | BPF program to set the program type for |
type | program type to set the BPF map to have |
This must be called before the BPF object is loaded, otherwise it has no effect and an error is returned.
enum bpf_prog_type bpf_program__type | ( | const struct bpf_program * | prog | ) |
Get the program type for an eBPF program.
[in] | prog | Program to check. |
void bpf_program__unload | ( | struct bpf_program * | prog | ) |
int bpf_program__unpin | ( | struct bpf_program * | prog, |
const char * | path | ||
) |
Unpin a program.
[in] | prog | Program to unpin. |
[in] | path | Path from which to unpin the program. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
-EINVAL | An invalid argument was provided. |
-ENOENT | The program was not pinned. |
int bpf_xdp_attach | ( | int | ifindex, |
int | prog_fd, | ||
__u32 | flags, | ||
const struct bpf_xdp_attach_opts * | opts | ||
) |
Attach an XDP program to a given interface.
[in] | ifindex | The interface index to attach to, or -1 to detach. |
[in] | prog_fd | File descriptor of program to attach. |
[in] | flags | Flags. Use XDP_FLAGS_REPLACE to replace any program previously attached to the specified interface index. |
[in] | opts | Options (currently unused). |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
int bpf_xdp_detach | ( | int | ifindex, |
__u32 | flags, | ||
const struct bpf_xdp_attach_opts * | opts | ||
) |
Detach an XDP program from a given interface.
[in] | ifindex | The interface index to detach from. |
[in] | prog_fd | File descriptor of program to detach. |
[in] | flags | Flags. Use XDP_FLAGS_REPLACE to detach any program previously attached to the specified interface index. |
[in] | opts | Options (currently unused). |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
int bpf_xdp_query_id | ( | int | ifindex, |
int | flags, | ||
__u32 * | prog_id | ||
) |
Get the XDP program id attached to a given interface index.
[in] | ifindex | The interface index to query. |
[in] | flags | Flags (currently 0). |
[out] | prog_id | The ID of the program attached. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
int libbpf_attach_type_by_name | ( | const char * | name, |
enum bpf_attach_type * | attach_type | ||
) |
libbpf_attach_type_by_name() converts the provided textual representation into an attach type value.
[in] | name | The textual representation of an attach type. |
[out] | attach_type | Returns the attach type. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
const char * libbpf_bpf_attach_type_str | ( | enum bpf_attach_type | t | ) |
libbpf_bpf_attach_type_str() converts the provided attach type value into a textual representation.
[in] | t | The attach type. |
const char * libbpf_bpf_link_type_str | ( | enum bpf_link_type | t | ) |
libbpf_bpf_link_type_str() converts the provided link type value into a textual representation.
[in] | t | The link type. |
const char * libbpf_bpf_map_type_str | ( | enum bpf_map_type | t | ) |
libbpf_bpf_map_type_str() converts the provided map type value into a textual representation.
[in] | t | The map type. |
const char * libbpf_bpf_prog_type_str | ( | enum bpf_prog_type | t | ) |
libbpf_bpf_prog_type_str() converts the provided program type value into a textual representation.
[in] | t | The program type. |
long libbpf_get_error | ( | const void * | ptr | ) |
Get a negative error code based on errno and a possibly null pointer.
[in] | ptr | Pointer that may be NULL. |
int libbpf_num_possible_cpus | ( | void | ) |
Get the number of processors on the current system.
int libbpf_prog_type_by_name | ( | const char * | name, |
enum bpf_prog_type * | prog_type, | ||
enum bpf_attach_type * | expected_attach_type | ||
) |
Get a program type and expected attach type by name.
[in] | name | Name, as if it were a section name in an ELF file. |
[out] | prog_type | Program type. |
[out] | expected_attach_type | Expected attach type. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
int libbpf_strerror | ( | int | err, |
char * | buf, | ||
size_t | size | ||
) |
Get an error message.
[in] | err | Error number. |
[out] | buf | Pointer to buffer to write message into. |
[in] | size | Size of output buffer. |
0 | The operation was successful. |
<0 | An error occurred, and errno was set. |
LIBBPF_API void perf_buffer__free | ( | struct perf_buffer * | pb | ) |
Free a perf buffer manager.
[in] | rb | Pointer to perf buffer manager to be freed. |
LIBBPF_API struct perf_buffer * perf_buffer__new | ( | int | map_fd, |
size_t | page_cnt, | ||
perf_buffer_sample_fn | sample_cb, | ||
perf_buffer_lost_fn | lost_cb, | ||
void * | ctx, | ||
const struct perf_buffer_opts * | opts | ||
) |
Create BPF perfbuf manager.
[in] | map_fd | File descriptor to perf event array map. |
[in] | page_cnt | Number of memory pages allocated for each per-CPU buffer. This should be set to 0. |
[in] | sample_cb | Pointer to perf buffer notification callback function. |
[in] | lost_cb | Function pointer for callback when record loss has occurred. |
[in] | ctx | User provided extra context passed into sample_cb and lost_cb. |
[in] | opts | The perf buffer manager options. This should be set to NULL. |
void ring_buffer__free | ( | struct ring_buffer * | rb | ) |
Frees a new ring buffer manager.
[in] | rb | Pointer to ring buffer to be freed. |
struct ring_buffer * ring_buffer__new | ( | int | map_fd, |
ring_buffer_sample_fn | sample_cb, | ||
void * | ctx, | ||
const struct ring_buffer_opts * | opts | ||
) |
Creates a new ring buffer manager.
[in] | map_fd | File descriptor to ring buffer map. |
[in] | sample_cb | Pointer to ring buffer notification callback function. |
[in] | ctx | Pointer to sample_cb callback function. |
[in] | opts | Ring buffer options. |