eBPF for Windows
Data Structures
bpf_legacy.h File Reference
#include "libbpf.h"

Go to the source code of this file.

Data Structures

struct  bpf_create_map_attr
 
struct  bpf_load_program_attr
 

Functions

Map-related functions
int bpf_create_map (enum bpf_map_type map_type, int key_size, int value_size, int max_entries, __u32 map_flags)
 Create a new map. More...
 
int bpf_create_map_in_map (enum bpf_map_type map_type, const char *name, int key_size, int inner_map_fd, int max_entries, __u32 map_flags)
 Create a new map-in-map. More...
 
int bpf_create_map_xattr (const struct bpf_create_map_attr *create_attr)
 Create a new map. More...
 
Program-related functions
int bpf_load_program (enum bpf_prog_type type, const struct bpf_insn *insns, size_t insns_cnt, const char *license, __u32 kern_version, char *log_buf, size_t log_buf_sz)
 Load (but do not attach) an eBPF program from eBPF instructions supplied by the caller. More...
 
int bpf_load_program_xattr (const struct bpf_load_program_attr *load_attr, char *log_buf, size_t log_buf_sz)
 Load (but do not attach) an eBPF program from eBPF instructions supplied by the caller. More...
 

Function Documentation

◆ bpf_create_map()

int bpf_create_map ( enum bpf_map_type  map_type,
int  key_size,
int  value_size,
int  max_entries,
__u32  map_flags 
)

Create a new map.

Parameters
[in]map_typeType of map to create.
[in]key_sizeSize in bytes of keys.
[in]value_sizeSize in bytes of values.
[in]max_entriesMaximum number of entries in the map.
[in]map_flagsFlags (currently 0).
Returns
A new file descriptor that refers to the map. The caller should call _close() on the fd to close this when done. A negative value indicates an error occurred and errno was set.
Deprecated:
Use bpf_map_create() instead.
Exceptions
EINVALAn invalid argument was provided.
ENOMEMOut of memory.

◆ bpf_create_map_in_map()

int bpf_create_map_in_map ( enum bpf_map_type  map_type,
const char *  name,
int  key_size,
int  inner_map_fd,
int  max_entries,
__u32  map_flags 
)

Create a new map-in-map.

Parameters
[in]map_typeType of outer map to create.
[in]nameOptionally, the name to use for the map.
[in]key_sizeSize in bytes of keys.
[in]inner_map_fdFile descriptor of the inner map template.
[in]max_entriesMaximum number of entries in the map.
[in]map_flagsFlags (currently 0).
Returns
A new file descriptor that refers to the map. The caller should call _close() on the fd to close this when done. A negative value indicates an error occurred and errno was set.
Deprecated:
Use bpf_map_create() instead.
Exceptions
EBADFThe file descriptor was not found.
EINVALAn invalid argument was provided.
ENOMEMOut of memory.

◆ bpf_create_map_xattr()

int bpf_create_map_xattr ( const struct bpf_create_map_attr create_attr)

Create a new map.

Parameters
[in]create_attrStructure of attributes using which a map gets created.
Returns
A new file descriptor that refers to the map. The caller should call _close() on the fd to close this when done. A negative value indicates an error occurred and errno was set.
Exceptions
EINVALAn invalid argument was provided.
ENOMEMOut of memory.
Deprecated:
Use bpf_map_create() instead.

◆ bpf_load_program()

int bpf_load_program ( enum bpf_prog_type  type,
const struct bpf_insn *  insns,
size_t  insns_cnt,
const char *  license,
__u32  kern_version,
char *  log_buf,
size_t  log_buf_sz 
)

Load (but do not attach) an eBPF program from eBPF instructions supplied by the caller.

Parameters
[in]typeProgram type to use.
[in]insnsArray of eBPF instructions.
[in]insns_cntNumber of eBPF instructions in the array.
[in]licenseLicense.
[in]kern_versionKernel version.
[out]log_bufBuffer in which to write any log messages.
[in]log_buf_sizeSize in bytes of the log buffer.
Returns
File descriptor that refers to the program, or <0 on error. The caller should call _close() on the fd to close this when done.
Deprecated:
Use bpf_prog_load() instead.
Exceptions
EACCESThe program failed verification.
EINVALOne or more parameters are incorrect.
ENOMEMOut of memory.
See also
bpf_prog_load
bpf_load_program_xattr

◆ bpf_load_program_xattr()

int bpf_load_program_xattr ( const struct bpf_load_program_attr load_attr,
char *  log_buf,
size_t  log_buf_sz 
)

Load (but do not attach) an eBPF program from eBPF instructions supplied by the caller.

Parameters
[in]load_attrParameters to use to load the eBPF program.
[out]log_bufBuffer in which to write any log messages.
[in]log_buf_sizeSize in bytes of the log buffer.
Returns
File descriptor that refers to the program, or <0 on error. The caller should call _close() on the fd to close this when done.
Exceptions
EACCESThe program failed verification.
EINVALOne or more parameters are incorrect.
ENOMEMOut of memory.
Deprecated:
Use bpf_prog_load() instead.
See also
bpf_prog_load
bpf_load_program