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, internal: generate full linkinfo for union subtypes #1359

Merged
merged 3 commits into from
Mar 22, 2024

Conversation

rgo3
Copy link
Contributor

@rgo3 rgo3 commented Feb 23, 2024

The current generic abstraction of bpf_link_info makes it harder to implement features like #1295. Instead of splitting LinkInfo into a generic part and having extra structs to represent the fields of union members in bpf_link_info, with this PR we generate the full LinkInfo struct for each member the union in bpf_link_info.

@rgo3 rgo3 changed the title Linkinfo per union member link, internal: generate full linkinfo for union subtypes Feb 23, 2024
@@ -355,32 +353,68 @@ func (l *RawLink) Info() (*Info, error) {
var extra interface{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum, so the idea is to run the link info syscall twice, first to get the link info type and second to read it into specific type?

could we just store the link type, like to have Link interface function that returns that? seems wasteful to do 2 same syscalls just to get it into convenient type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rgo3 @lmb I updated the missed counts interface changes #1295 on top of this change, still need to update the tetragon code on top of that, but so far looks good

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can move the info.Type specific code from this function to new Info() methods on the concrete link types, like you did with KprobeMulti.Info() before. Then the only caller of RawLink.Info() is wrapRawLink which only really cares about info.Type anyways. This way Info() only does a single call in the common case (caveat: sometimes we need two calls anyways to retrieve buffer sizes, etc.).

We can make that change in this PR, or as a follow up, or once you've landed your kprobe missed count changes. Up to you and @rgo3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would having separate Info() methods on all concrete link types as well look in practice when loading a pinned link from bpffs and get specific information from it?

  1. Load pinned link
  2. Call generic Info method
  3. Check type of returned object that satisfies the Link interface
  4. Assert concrete link type
  5. Call type dependent Info method

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds right to me. 1-4 happen behind the scenes in LoadPinnedLink. 5 happens when a user does KprobeMulti.Info().

@lmb
Copy link
Collaborator

lmb commented Mar 21, 2024

@olsajiri I think @rgo3 is head deep in IPSec work, when do you need this?

@rgo3
Copy link
Contributor Author

rgo3 commented Mar 21, 2024

I've talked to @olsajiri yesterday that I would take a look today. I think the fastest solution would be merging this PR, jiri can base his work on top and then I look into refactoring after? That we we enable Jiri to continue and I get a little more time 😁
If you agree I can rebase this PR and get it ready.

@lmb
Copy link
Collaborator

lmb commented Mar 21, 2024

SGTM

rgo3 added 3 commits March 21, 2024 19:02
This defines the extra LinkInfo types directly in pkg link instead of
relying on the generated types in pkg internal/sys.
This is a preparatory commit as the next commit changes how we generate
extra LinkInfo types.

Signed-off-by: Robin Gögge <r.goegge@isovalent.com>
Signed-off-by: Robin Gögge <r.goegge@isovalent.com>
Signed-off-by: Robin Gögge <r.goegge@isovalent.com>
@rgo3 rgo3 force-pushed the linkinfo-per-union-member branch from b3c7c48 to 52685fb Compare March 21, 2024 18:02
@rgo3 rgo3 marked this pull request as ready for review March 22, 2024 08:47
@rgo3 rgo3 requested review from mmat11 and a team as code owners March 22, 2024 08:47
@rgo3
Copy link
Contributor Author

rgo3 commented Mar 22, 2024

Rebased on top of the netkit changes and did the same refactoring needed for that link type, otherwise no changes.

@lmb
Copy link
Collaborator

lmb commented Mar 22, 2024

Thanks 🙏

@lmb lmb merged commit 6f21619 into cilium:main Mar 22, 2024
15 checks passed
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.

4 participants