Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btf: fix NewHandleFromID for kernel modules #729

Merged
merged 4 commits into from
Jul 14, 2022
Merged

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented Jul 5, 2022

btf: add split kmod BTF test

Use HandleIterator to find vmlinux and the first loaded module, and
attempt to parse the split BTF.

This requires exporting HandleInfo since we use external tests.

btf: add HandleIterator

Add an iterator for BTF objects / handles. The API is the same as MapIterator.

Used to test loading kmod split BTF from a BTF ID in a subsequent commit.

btf: rename info.go to handle.go

btf: fix NewHandleFromID for kernel modules

Kernel modules only expose split BTF when queried via BPF_OBJ_GET_INFO_BY_FD. This
causes NewHandleFromID to fail for kmod BTF, since the function attempts to inflate
types.

Avoid inflating types in NewHandleFromID and change Handle.Spec to accept a base
Spec to allow decoding types from modules.

This is a breaking change.

Updates #705

@lmb lmb requested review from brb and ti-mo July 5, 2022 16:44
@lmb lmb force-pushed the kmod-split-btf branch 2 times, most recently from b53e0ae to 430bc48 Compare July 7, 2022 10:55
btf/handle.go Show resolved Hide resolved
lmb added 4 commits July 8, 2022 10:52
Kernel modules only expose split BTF when queried via BPF_OBJ_GET_INFO_BY_FD. This
causes NewHandleFromID to fail for kmod BTF, since the function attempts to inflate
types.

Avoid inflating types in NewHandleFromID and change Handle.Spec to accept a base
Spec to allow decoding types from modules.

This is a breaking change.

Updates cilium#705
Add an iterator for BTF objects / handles. The API is the same as MapIterator.

Used to test loading kmod split BTF from a BTF ID in a subsequent commit.
Use HandleIterator to find vmlinux and the first loaded module, and
attempt to parse the split BTF.

This requires exporting HandleInfo since we use external tests.
@lmb lmb force-pushed the kmod-split-btf branch from 430bc48 to d7712b9 Compare July 8, 2022 10:53
@lmb lmb merged commit bf69929 into cilium:master Jul 14, 2022
@lmb lmb deleted the kmod-split-btf branch July 14, 2022 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant