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

Upstream cilium GetMapInfo #5

Closed
lmb opened this issue Sep 6, 2019 · 9 comments · Fixed by #27
Closed

Upstream cilium GetMapInfo #5

lmb opened this issue Sep 6, 2019 · 9 comments · Fixed by #27
Assignees

Comments

@lmb
Copy link
Collaborator

lmb commented Sep 6, 2019

Cilium has a cool function that parses map attributes from /proc: https://github.com/cilium/cilium/blob/12fe19d26afd005aa0e0e4c312f81b52af919b82/pkg/bpf/map_linux.go#L282

We should incorporate this into LoadPinnedMap, to make it work on kernels < 4.14.

@lmb
Copy link
Collaborator Author

lmb commented Oct 7, 2019

@joestringer do you think you could take a stab at this?

@joestringer
Copy link
Member

Sure, it's all just a matter of finding the time ;)

@joestringer joestringer self-assigned this Oct 7, 2019
@whl739
Copy link

whl739 commented Oct 28, 2019

@lmb
Copy link
Collaborator Author

lmb commented Oct 28, 2019

That's what LoadPinned(Map|Program) use right now. This issue is about adding a fall back for older kernels that don't have the function.

@whl739
Copy link

whl739 commented Oct 28, 2019

Got it.
But how can i use APIs like GetMapInfo or GetProgInfo, they are private in syscalls.go(for example, bpfGetMapInfoByFD).

@joestringer
Copy link
Member

@whl739 Does LoadPinnedMap() / LoadPinnedProgram() do what you want? I believe that these are effectively the higher level API for the same thing.

@whl739
Copy link

whl739 commented Oct 29, 2019

@joestringer you are right, these APIs are enough if i only want to get the map/prog.
But if i want to get more info about map/prog, such as type bpfMapInfo struct and type bpfProgInfo struct defined in syscalls.go, i didn't find any API can do that, did i miss something?

@lmb
Copy link
Collaborator Author

lmb commented Oct 29, 2019

You can use https://godoc.org/github.com/cilium/ebpf#Map.ABI to access some of the information from the syscalls. Please create a separate issue explaining what you want to achieve if that isn't enough for your use case.

@whl739
Copy link

whl739 commented Oct 29, 2019

Thanks for your kind help. I'll create a new issue.

lmb added a commit that referenced this issue Nov 4, 2019
Fall back to reading /proc/self/*/fdinfo if BPF_OBJ_GET_INFO_BY_FD is
not available on the current kernel. This should give us compatibility
to at least 4.9.

Fixes #5
lmb added a commit that referenced this issue Nov 4, 2019
Fall back to reading /proc/self/*/fdinfo if BPF_OBJ_GET_INFO_BY_FD is
not available on the current kernel. This should give us compatibility
to at least 4.9.

Fixes #5
lmb added a commit that referenced this issue Nov 5, 2019
Fall back to reading /proc/self/*/fdinfo if BPF_OBJ_GET_INFO_BY_FD is
not available on the current kernel. This should give us compatibility
to at least 4.9.

Fixes #5
lmb added a commit that referenced this issue Nov 12, 2019
Fall back to reading /proc/self/*/fdinfo if BPF_OBJ_GET_INFO_BY_FD is
not available on the current kernel. This should give us compatibility
to at least 4.9.

Fixes #5
lmb added a commit that referenced this issue Nov 13, 2019
Fall back to reading /proc/self/*/fdinfo if BPF_OBJ_GET_INFO_BY_FD is
not available on the current kernel. This should give us compatibility
to at least 4.9.

Fixes #5
lmb added a commit that referenced this issue Nov 13, 2019
Fall back to reading /proc/self/*/fdinfo if BPF_OBJ_GET_INFO_BY_FD is
not available on the current kernel. This should give us compatibility
to at least 4.9.

Fixes #5
@lmb lmb closed this as completed in #27 Nov 13, 2019
lmb added a commit that referenced this issue Nov 13, 2019
Fall back to reading /proc/self/*/fdinfo if BPF_OBJ_GET_INFO_BY_FD is
not available on the current kernel. This should give us compatibility
to at least 4.9.

Fixes #5
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 a pull request may close this issue.

3 participants