eBPF for Windows
Data Structures
libbpf_legacy.h File Reference

Go to the source code of this file.

Data Structures

struct  bpf_object_load_attr
 

Functions

Link-related functions
int bpf_set_link_xdp_fd (int ifindex, int fd, __u32 flags)
 Attach an XDP program to a given interface. More...
 
Map-related functions
struct bpf_mapbpf_map__next (const struct bpf_map *map, const struct bpf_object *obj)
 Get the next map for a given eBPF object. More...
 
struct bpf_mapbpf_map__prev (const struct bpf_map *map, const struct bpf_object *obj)
 Get the previous map for a given eBPF object. More...
 
Program-related functions
int bpf_prog_load_deprecated (const char *file, enum bpf_prog_type type, struct bpf_object **pobj, int *prog_fd)
 Load (but do not attach) eBPF maps and programs from an ELF file. More...
 
struct bpf_program * bpf_program__next (struct bpf_program *prog, const struct bpf_object *obj)
 Get the next program for a given eBPF object. More...
 
struct bpf_program * bpf_program__prev (struct bpf_program *prog, const struct bpf_object *obj)
 Get the previous eBPF program for a given eBPF object. More...
 
size_t bpf_program__size (const struct bpf_program *prog)
 Get the eBPF program size in bytes. More...
 

Object-related functions

#define bpf_object__for_each_safe(pos, tmp)
 
int bpf_object__load_xattr (struct bpf_object_load_attr *attr)
 Load all the programs in a given object. More...
 
struct bpf_object * bpf_object__next (struct bpf_object *prev)
 Get the next eBPF object opened by the calling process. More...
 
int bpf_object__unload (struct bpf_object *obj)
 Unload all the programs in a given object. More...
 

Macro Definition Documentation

◆ bpf_object__for_each_safe

#define bpf_object__for_each_safe (   pos,
  tmp 
)
Value:
for ((pos) = bpf_object__next(NULL), (tmp) = bpf_object__next(pos); (pos) != NULL; \
(pos) = (tmp), (tmp) = bpf_object__next(tmp))
#define NULL
Definition: bpf_helpers.h:48
struct bpf_object * bpf_object__next(struct bpf_object *prev)
Get the next eBPF object opened by the calling process.

Function Documentation

◆ bpf_map__next()

struct bpf_map* bpf_map__next ( const struct bpf_map map,
const struct bpf_object *  obj 
)

Get the next map for a given eBPF object.

Parameters
[in]mapPrevious map.
[in]objObject with maps.
Returns
Next map, or NULL if none.
Deprecated:
Use bpf_object__next_map() instead.
See also
bpf_map__prev

◆ bpf_map__prev()

struct bpf_map* bpf_map__prev ( const struct bpf_map map,
const struct bpf_object *  obj 
)

Get the previous map for a given eBPF object.

Parameters
[in]mapNext map.
[in]objObject with maps.
Returns
Previous map, or NULL if none.
Deprecated:
Use bpf_object__prev_map() instead.
See also
bpf_map__next

◆ bpf_object__load_xattr()

int bpf_object__load_xattr ( struct bpf_object_load_attr attr)

Load all the programs in a given object.

Parameters
[in]attrStructure with load attributes.
Return values
0The operation was successful.
<0An error occured, and errno was set.
Deprecated:
Use bpf_object__load() instead.
Exceptions
EINVALAn invalid argument was provided.
ENOMEMOut of memory.
See also
bpf_object__open
bpf_object__load_xattr
bpf_prog_load

◆ bpf_object__next()

struct bpf_object* bpf_object__next ( struct bpf_object *  prev)

Get the next eBPF object opened by the calling process.

Parameters
[in]prevPrevious object, or NULL to get the first object.
Returns
Next object, or NULL if none.
Deprecated:
Track bpf_objects in application code instead.

◆ bpf_object__unload()

int bpf_object__unload ( struct bpf_object *  obj)

Unload all the programs in a given object.

Parameters
[in]objObject with programs to be unloaded.
Return values
0The operation was successful.
<0An error occured, and errno was set.
Deprecated:
Use bpf_object__close() instead.
See also
bpf_object__load
bpf_object__load_xattr
bpf_prog_load

◆ bpf_prog_load_deprecated()

int bpf_prog_load_deprecated ( const char *  file,
enum bpf_prog_type  type,
struct bpf_object **  pobj,
int *  prog_fd 
)

Load (but do not attach) eBPF maps and programs from an ELF file.

Parameters
[in]filePath name to an ELF file.
[in]typeProgram type to use for loading eBPF programs. If BPF_PROG_TYPE_UNKNOWN, the program type is derived from the section prefix in the ELF file.
[out]pobjPointer to where to store the eBPF object loaded. The caller is expected to call bpf_object__close() to free the object.
[out]prog_fdReturns a file descriptor for the first program. The caller should not call _close() on the fd, but should instead use bpf_object__close() on the object returned.
Return values
0The operation was successful.
<0An error occured, and errno was set.
Deprecated:
Use bpf_object__open() and bpf_object__load() instead.
Exceptions
EACCESThe program failed verification.
EINVALOne or more parameters are incorrect.
ENOMEMOut of memory.
See also
bpf_load_program
bpf_load_program_xattr
bpf_object__close
bpf_program__attach

◆ bpf_program__next()

struct bpf_program* bpf_program__next ( struct bpf_program *  prog,
const struct bpf_object *  obj 
)

Get the next program for a given eBPF object.

Parameters
[in]progPrevious program, or NULL to get the first program.
[in]objObject with programs.
Returns
Next program, or NULL if none.
Deprecated:
Use bpf_object__next_program() instead.
See also
bpf_program__prev

◆ bpf_program__prev()

struct bpf_program* bpf_program__prev ( struct bpf_program *  prog,
const struct bpf_object *  obj 
)

Get the previous eBPF program for a given eBPF object.

Parameters
[in]progNext program.
[in]objObject with programs.
Returns
Previous eBPF program, or NULL if none.
Deprecated:
Use bpf_object__prev_program() instead.
See also
bpf_program__next

◆ bpf_program__size()

size_t bpf_program__size ( const struct bpf_program *  prog)

Get the eBPF program size in bytes.

Parameters
[in]progProgram.
Returns
Program size in bytes.
Deprecated:
Use bpf_program__insn_cnt() instead.

◆ bpf_set_link_xdp_fd()

int bpf_set_link_xdp_fd ( int  ifindex,
int  fd,
__u32  flags 
)

Attach an XDP program to a given interface.

Parameters
[in]ifindexThe interface index to attach to, or -1 to detach.
[in]fdFile descriptor of program to attach.
[in]flagsFlags. Use XDP_FLAGS_REPLACE to replace any program previously attached to the specified interface index.
Return values
0The operation was successful.
<0An error occured, and errno was set.
Deprecated:
Use bpf_xdp_attach() instead.
See also
bpf_program__attach_xdp
bpf_xdp_attach
bpf_xdp_detach