Skip to content

Commit 8916c67

Browse files
ebpf-library/libbpf/userspace: Add bpf_object and bpf_program pages
This commit adds pages for the libbpf `bpf_object__*` and `bpf_program__*` functions. We also updated the libbpf reference and golang tooling. Signed-off-by: Dylan Reimerink <[email protected]>
1 parent e29425f commit 8916c67

File tree

93 files changed

+3612
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3612
-93
lines changed

.aspell.en.pws

+7
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ kretprobe
4545
kretprobes
4646
uprobe
4747
uprobes
48+
uretprobe
49+
retprobe
4850
Fprobes
4951
fprobe
5052
ftrace
@@ -125,18 +127,21 @@ NUMA
125127
IMM
126128
GPL
127129
MPL
130+
USDT
128131
accessor
129132
accessors
130133
centric
131134
enum
132135
enums
133136
relocation
134137
relocations
138+
fetchable
135139
signable
136140
signedness
137141
typedefs
138142
accumulatively
139143
untrusted
144+
unlinked
140145
inlined
141146
lifecycle
142147
nginx
@@ -158,6 +163,7 @@ dereferenced
158163
dereferencing
159164
dereferences
160165
incrementing
166+
decrementing
161167
misprediction
162168
sleepable
163169
endian
@@ -195,6 +201,7 @@ observability
195201
bytecode
196202
crypto
197203
cryptographic
204+
cryptographically
198205
benchmarking
199206
benchmarked
200207
Decrypt

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ UIDGID := $(shell stat -c '%u:%g' ${REPODIR})
66
IMAGE := ghcr.io/isovalent/ebpf-docs
77
VERSION := $(shell cat ${REPODIR}/tools/image-version)
88

9+
GOLANG := 1.24.1
10+
911
PROD := false
1012
GH_TOKEN := ""
1113

@@ -48,12 +50,12 @@ serve:
4850

4951
.PHONY: build-spellcheck
5052
build-spellcheck:
51-
docker run --rm -v "${REPODIR}:/docs" -w /docs golang:latest bash -c \
53+
docker run --rm -v "${REPODIR}:/docs" -w /docs golang:${GOLANG} bash -c \
5254
"CGO_ENABLED=0 go build -buildvcs=false -o /docs/tools/bin/spellcheck /docs/tools/spellcheck/."
5355

5456
.PHONY: build-gen-tools
5557
build-gen-tools:
56-
docker run --rm -v "${REPODIR}:/docs" -w /docs golang:latest bash -c \
58+
docker run --rm -v "${REPODIR}:/docs" -w /docs golang:${GOLANG} bash -c \
5759
"CGO_ENABLED=0 go build -buildvcs=false -o /docs/tools/bin/libbpf-tag-gen /docs/tools/libbpf-tag-gen/. && \
5860
CGO_ENABLED=0 go build -buildvcs=false -o /docs/tools/bin/helper-ref-gen /docs/tools/helper-ref-gen/. && \
5961
CGO_ENABLED=0 go build -buildvcs=false -o /docs/tools/bin/feature-gen /docs/tools/feature-gen/. && \
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,96 @@
11
- [index](index.md)
2+
- BPF Object functions
3+
- [`bpf_object__open`](bpf_object__open.md)
4+
- [`bpf_object__open_file`](bpf_object__open_file.md)
5+
- [`bpf_object__open_mem`](bpf_object__open_mem.md)
6+
- [`bpf_object__load`](bpf_object__load.md)
7+
- [`bpf_object__close`](bpf_object__close.md)
8+
- [`bpf_object__pin_maps`](bpf_object__pin_maps.md)
9+
- [`bpf_object__unpin_maps`](bpf_object__unpin_maps.md)
10+
- [`bpf_object__pin_programs`](bpf_object__pin_programs.md)
11+
- [`bpf_object__unpin_programs`](bpf_object__unpin_programs.md)
12+
- [`bpf_object__pin`](bpf_object__pin.md)
13+
- [`bpf_object__unpin`](bpf_object__unpin.md)
14+
- [`bpf_object__name`](bpf_object__name.md)
15+
- [`bpf_object__kversion`](bpf_object__kversion.md)
16+
- [`bpf_object__set_kversion`](bpf_object__set_kversion.md)
17+
- [`bpf_object__token_fd`](bpf_object__token_fd.md)
18+
- [`bpf_object__btf`](bpf_object__btf.md)
19+
- [`bpf_object__btf_fd`](bpf_object__btf_fd.md)
20+
- [`bpf_object__find_program_by_name`](bpf_object__find_program_by_name.md)
21+
- BPF Skeleton functions
22+
- [`bpf_object__open_skeleton`](bpf_object__open_skeleton.md)
23+
- [`bpf_object__load_skeleton`](bpf_object__load_skeleton.md)
24+
- [`bpf_object__attach_skeleton`](bpf_object__attach_skeleton.md)
25+
- [`bpf_object__detach_skeleton`](bpf_object__detach_skeleton.md)
26+
- [`bpf_object__destroy_skeleton`](bpf_object__destroy_skeleton.md)
27+
- [`bpf_object__open_subskeleton`](bpf_object__open_subskeleton.md)
28+
- [`bpf_object__destroy_subskeleton`](bpf_object__destroy_subskeleton.md)
29+
- [`bpf_object__gen_loader`](bpf_object__gen_loader.md)
30+
- [`bpf_object__next_program`](bpf_object__next_program.md)
31+
- [`bpf_object__prev_program`](bpf_object__prev_program.md)
32+
- [`bpf_object__find_map_by_name`](bpf_object__find_map_by_name.md)
33+
- [`bpf_object__find_map_fd_by_name`](bpf_object__find_map_fd_by_name.md)
34+
- [`bpf_object__next_map`](bpf_object__next_map.md)
35+
- [`bpf_object__prev_map`](bpf_object__prev_map.md)
36+
- BPF Program functions
37+
- [`bpf_program__set_ifindex`](bpf_program__set_ifindex.md)
38+
- [`bpf_program__name`](bpf_program__name.md)
39+
- [`bpf_program__section_name`](bpf_program__section_name.md)
40+
- [`bpf_program__autoload`](bpf_program__autoload.md)
41+
- [`bpf_program__set_autoload`](bpf_program__set_autoload.md)
42+
- [`bpf_program__autoattach`](bpf_program__autoattach.md)
43+
- [`bpf_program__set_autoattach`](bpf_program__set_autoattach.md)
44+
- [`bpf_program__insns`](bpf_program__insns.md)
45+
- [`bpf_program__set_insns`](bpf_program__set_insns.md)
46+
- [`bpf_program__insn_cnt`](bpf_program__insn_cnt.md)
47+
- [`bpf_program__fd`](bpf_program__fd.md)
48+
- [`bpf_program__pin`](bpf_program__pin.md)
49+
- [`bpf_program__unpin`](bpf_program__unpin.md)
50+
- [`bpf_program__unload`](bpf_program__unload.md)
51+
- Program attach functions
52+
- [`bpf_program__attach`](bpf_program__attach.md)
53+
- [`bpf_program__attach_perf_event`](bpf_program__attach_perf_event.md)
54+
- [`bpf_program__attach_perf_event_opts`](bpf_program__attach_perf_event_opts.md)
55+
- [`bpf_program__attach_kprobe`](bpf_program__attach_kprobe.md)
56+
- [`bpf_program__attach_kprobe_opts`](bpf_program__attach_kprobe_opts.md)
57+
- [`bpf_program__attach_kprobe_multi_opts`](bpf_program__attach_kprobe_multi_opts.md)
58+
- [`bpf_program__attach_uprobe_multi`](bpf_program__attach_uprobe_multi.md)
59+
- [`bpf_program__attach_ksyscall`](bpf_program__attach_ksyscall.md)
60+
- [`bpf_program__attach_uprobe`](bpf_program__attach_uprobe.md)
61+
- [`bpf_program__attach_uprobe_opts`](bpf_program__attach_uprobe_opts.md)
62+
- [`bpf_program__attach_usdt`](bpf_program__attach_usdt.md)
63+
- [`bpf_program__attach_tracepoint`](bpf_program__attach_tracepoint.md)
64+
- [`bpf_program__attach_tracepoint_opts`](bpf_program__attach_tracepoint_opts.md)
65+
- [`bpf_program__attach_raw_tracepoint`](bpf_program__attach_raw_tracepoint.md)
66+
- [`bpf_program__attach_raw_tracepoint_opts`](bpf_program__attach_raw_tracepoint_opts.md)
67+
- [`bpf_program__attach_trace`](bpf_program__attach_trace.md)
68+
- [`bpf_program__attach_trace_opts`](bpf_program__attach_trace_opts.md)
69+
- [`bpf_program__attach_lsm`](bpf_program__attach_lsm.md)
70+
- [`bpf_program__attach_cgroup`](bpf_program__attach_cgroup.md)
71+
- [`bpf_program__attach_netns`](bpf_program__attach_netns.md)
72+
- [`bpf_program__attach_sockmap`](bpf_program__attach_sockmap.md)
73+
- [`bpf_program__attach_xdp`](bpf_program__attach_xdp.md)
74+
- [`bpf_program__attach_freplace`](bpf_program__attach_freplace.md)
75+
- [`bpf_program__attach_netfilter`](bpf_program__attach_netfilter.md)
76+
- [`bpf_program__attach_tcx`](bpf_program__attach_tcx.md)
77+
- [`bpf_program__attach_netkit`](bpf_program__attach_netkit.md)
78+
- [`bpf_program__attach_iter`](bpf_program__attach_iter.md)
79+
- [`bpf_program__type`](bpf_program__type.md)
80+
- [`bpf_program__set_type`](bpf_program__set_type.md)
81+
- [`bpf_program__set_expected_attach_type`](bpf_program__set_expected_attach_type.md)
82+
- [`bpf_program__flags`](bpf_program__flags.md)
83+
- [`bpf_program__set_flags`](bpf_program__set_flags.md)
84+
- [`bpf_program__log_level`](bpf_program__log_level.md)
85+
- [`bpf_program__set_log_level`](bpf_program__set_log_level.md)
86+
- [`bpf_program__log_buf`](bpf_program__log_buf.md)
87+
- [`bpf_program__set_log_buf`](bpf_program__set_log_buf.md)
88+
- [`bpf_program__set_attach_target`](bpf_program__set_attach_target.md)
89+
- [`bpf_program__expected_attach_type`](bpf_program__expected_attach_type.md)
290
- Misc libbpf functions
391
- [`libbpf_major_version`](libbpf_major_version.md)
492
- [`libbpf_minor_version`](libbpf_minor_version.md)
593
- [`libbpf_strerror`](libbpf_strerror.md)
94+
- Legacy APIs
95+
- [`bpf_program__get_type`](bpf_program__get_type.md)
96+
- [`bpf_program__get_expected_attach_type`](bpf_program__get_expected_attach_type.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: "Libbpf userspace function 'bpf_object__attach_skeleton'"
3+
description: "This page documents the 'bpf_object__attach_skeleton' libbpf userspace function, including its definition, usage, and examples."
4+
---
5+
# Libbpf userspace function `bpf_object__attach_skeleton`
6+
7+
<!-- [LIBBPF_TAG] -->
8+
[:octicons-tag-24: 0.0.7](https://github.com/libbpf/libbpf/releases/tag/v0.0.7)
9+
<!-- [/LIBBPF_TAG] -->
10+
11+
Auto attach the programs in a skeleton to hooks in the kernel.
12+
13+
## Definition
14+
15+
`#!c int bpf_object__attach_skeleton(struct bpf_object_skeleton *s);`
16+
17+
**Parameters**
18+
19+
- `s`: The skeleton to attach
20+
21+
## Usage
22+
23+
This function is typically not called directly but via the generated `<name>__attach` function. This function will auto attach any programs in the skeleton that can be auto attached (based on the section they are in). However, this is optional, and you have more control if you manually attach program.
24+
25+
### Example
26+
27+
!!! example "Docs could be improved"
28+
This part of the docs is incomplete, contributions are very welcome
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: "Libbpf userspace function 'bpf_object__btf'"
3+
description: "This page documents the 'bpf_object__btf' libbpf userspace function, including its definition, usage, and examples."
4+
---
5+
# Libbpf userspace function `bpf_object__btf`
6+
7+
<!-- [LIBBPF_TAG] -->
8+
[:octicons-tag-24: 0.0.2](https://github.com/libbpf/libbpf/releases/tag/v0.0.2)
9+
<!-- [/LIBBPF_TAG] -->
10+
11+
Returns the BTF of the BPF object.
12+
13+
## Definition
14+
15+
`#!c struct btf *bpf_object__btf(const struct bpf_object *obj);`
16+
17+
**Parameter**
18+
19+
- `obj`: Pointer to a valid BPF object
20+
21+
**Returns**
22+
23+
A pointer to the BTF of the BPF object; `NULL` if the BPF object has no BTF.
24+
25+
## Usage
26+
27+
!!! example "Docs could be improved"
28+
This part of the docs is incomplete, contributions are very welcome
29+
30+
### Example
31+
32+
!!! example "Docs could be improved"
33+
This part of the docs is incomplete, contributions are very welcome
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: "Libbpf userspace function 'bpf_object__btf_fd'"
3+
description: "This page documents the 'bpf_object__btf_fd' libbpf userspace function, including its definition, usage, and examples."
4+
---
5+
# Libbpf userspace function `bpf_object__btf_fd`
6+
7+
<!-- [LIBBPF_TAG] -->
8+
[:octicons-tag-24: 0.0.1](https://github.com/libbpf/libbpf/releases/tag/v0.0.1)
9+
<!-- [/LIBBPF_TAG] -->
10+
11+
Returns the file descriptor of the BTF loaded into the kernel for a given BPF object.
12+
13+
## Definition
14+
15+
`#!c int bpf_object__btf_fd(const struct bpf_object *obj);`
16+
17+
**Parameters**
18+
19+
- `obj`: Pointer to a valid BPF object
20+
21+
**Returns**
22+
23+
The file descriptor of the BTF loaded into the kernel for the BPF object, or `-1` if the BPF object has no BTF or the BTF has not yet been loaded into the kernel.
24+
25+
## Usage
26+
27+
!!! example "Docs could be improved"
28+
This part of the docs is incomplete, contributions are very welcome
29+
30+
### Example
31+
32+
!!! example "Docs could be improved"
33+
This part of the docs is incomplete, contributions are very welcome
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: "Libbpf userspace function 'bpf_object__close'"
3+
description: "This page documents the 'bpf_object__close' libbpf userspace function, including its definition, usage, and examples."
4+
---
5+
# Libbpf userspace function `bpf_object__close`
6+
7+
<!-- [LIBBPF_TAG] -->
8+
[:octicons-tag-24: 0.0.1](https://github.com/libbpf/libbpf/releases/tag/v0.0.1)
9+
<!-- [/LIBBPF_TAG] -->
10+
11+
closes a BPF object and releases all resources.
12+
13+
## Definition
14+
15+
`#!c void bpf_object__close(struct bpf_object *obj);`
16+
17+
**Parameters**
18+
19+
- `obj`: Pointer to a valid BPF object
20+
21+
## Usage
22+
23+
!!! example "Docs could be improved"
24+
This part of the docs is incomplete, contributions are very welcome
25+
26+
### Example
27+
28+
!!! example "Docs could be improved"
29+
This part of the docs is incomplete, contributions are very welcome
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: "Libbpf userspace function 'bpf_object__destroy_skeleton'"
3+
description: "This page documents the 'bpf_object__destroy_skeleton' libbpf userspace function, including its definition, usage, and examples."
4+
---
5+
# Libbpf userspace function `bpf_object__destroy_skeleton`
6+
7+
<!-- [LIBBPF_TAG] -->
8+
[:octicons-tag-24: 0.0.7](https://github.com/libbpf/libbpf/releases/tag/v0.0.7)
9+
<!-- [/LIBBPF_TAG] -->
10+
11+
Detach all loaded BPF programs of the skeleton, and free any resources of the skeleton.
12+
13+
## Definition
14+
15+
`#!c void bpf_object__destroy_skeleton(struct bpf_object_skeleton *s);`
16+
17+
## Usage
18+
19+
!!! example "Docs could be improved"
20+
This part of the docs is incomplete, contributions are very welcome
21+
22+
### Example
23+
24+
!!! example "Docs could be improved"
25+
This part of the docs is incomplete, contributions are very welcome
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: "Libbpf userspace function 'bpf_object__destroy_subskeleton'"
3+
description: "This page documents the 'bpf_object__destroy_subskeleton' libbpf userspace function, including its definition, usage, and examples."
4+
---
5+
# Libbpf userspace function `bpf_object__destroy_subskeleton`
6+
7+
<!-- [LIBBPF_TAG] -->
8+
[:octicons-tag-24: 0.8.0](https://github.com/libbpf/libbpf/releases/tag/v0.8.0)
9+
<!-- [/LIBBPF_TAG] -->
10+
11+
Destroy a sub-skeleton.
12+
13+
## Definition
14+
15+
`#!c void bpf_object__destroy_subskeleton(struct bpf_object_subskeleton *s);`
16+
17+
## Usage
18+
19+
This function destroys the resources associated with a sub-skeleton. It does not detach programs.
20+
21+
### Example
22+
23+
!!! example "Docs could be improved"
24+
This part of the docs is incomplete, contributions are very welcome
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: "Libbpf userspace function 'bpf_object__detach_skeleton'"
3+
description: "This page documents the 'bpf_object__detach_skeleton' libbpf userspace function, including its definition, usage, and examples."
4+
---
5+
# Libbpf userspace function `bpf_object__detach_skeleton`
6+
7+
<!-- [LIBBPF_TAG] -->
8+
[:octicons-tag-24: 0.0.7](https://github.com/libbpf/libbpf/releases/tag/v0.0.7)
9+
<!-- [/LIBBPF_TAG] -->
10+
11+
Detach currently attached programs of the skeleton from the kernel.
12+
13+
## Definition
14+
15+
`#!c void bpf_object__detach_skeleton(struct bpf_object_skeleton *s);`
16+
17+
**Parameters**
18+
19+
- `s`: The skeleton to detach
20+
21+
## Usage
22+
23+
!!! example "Docs could be improved"
24+
This part of the docs is incomplete, contributions are very welcome
25+
26+
### Example
27+
28+
!!! example "Docs could be improved"
29+
This part of the docs is incomplete, contributions are very welcome

0 commit comments

Comments
 (0)