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

link: RawTracepoint and Iter link information #506

Open
mehrdadrad opened this issue Nov 26, 2021 · 3 comments
Open

link: RawTracepoint and Iter link information #506

mehrdadrad opened this issue Nov 26, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@mehrdadrad
Copy link
Contributor

LoadPinnedLink doesn't expose RawLinkInfo like LoadPinnedRawLink (deprecated). The RawLinkInfo already has type, id and programID fields and we can add more type-specific information later to this structure like ifindex for XDP, attach_type for tracing/cgroup/netns/iter etc.
Any thoughts?

@lmb
Copy link
Collaborator

lmb commented Nov 26, 2021

You're right, the same problem applies to RawLink.UpdateArgs. As a workaround you can assert that the Link implements an interface:

interface {
    Info() (*RawLinkInfo, error)
}

There are a couple of options to fix this:

  1. Add Info() (*RawLinkInfo, error) to Link. This is a problem for BPF link types that have custom metadata like bpf_iter_link_info. For those we probably want something like Info() (*IterInfo, error) with IterInfo embedding RawLinkInfo. With Info() part of the interface this becomes impossible.
  2. Add structs like NetNsInfo for all link types we currently have defined, and export the currently unexported link types. Then the user can simply assert link.(*Iter).Info() which embeds a RawLinkInfo. Downside: there is no way to get the RawLinkInfo for a generic Link without type asserting it.
  3. Add a struct Info which contains all the possible metadata. Access to individual fields would have to happen via getters like ProgramInfo.MapIDs. Then we can add Info() (*Info, error) to Link.

Needs some experimentation, but I think the third one seems simplest / the one with the least amount of drawbacks. We can even make it somewhat backwards compatible by aliasing NetNsInfo to Info.

@mehrdadrad
Copy link
Contributor Author

@lmb Actually I tried to add type-specific information and expose all link_info last weekend and I just cleaned up the code and added it as draft pull request #509 please review and let me know what do you think.

@mehrdadrad mehrdadrad self-assigned this Dec 8, 2021
@lmb
Copy link
Collaborator

lmb commented Dec 17, 2021

Most of the link types now have info thanks to @mehrdadrad's PR. The two missing ones are RawTracepointInfo and IterInfo since they contain strings.

@lmb lmb assigned lmb and unassigned mehrdadrad Dec 17, 2021
@ti-mo ti-mo changed the title link: LoadPinnedLink doesn't expose link information link: RawTracepoint and Iter link information Jan 21, 2022
@ti-mo ti-mo added the enhancement New feature or request label Jan 21, 2022
@lmb lmb removed their assignment Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants