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

WIP: Add interfaces discovery to bpf agent process #408

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

msherif1234
Copy link
Contributor

No description provided.

@msherif1234 msherif1234 marked this pull request as draft March 6, 2025 12:51
Copy link

codecov bot commented Mar 6, 2025

Codecov Report

Attention: Patch coverage is 10.27397% with 131 lines in your changes missing coverage. Please review.

Project coverage is 31.16%. Comparing base (a43ea20) to head (2df77e6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
controllers/bpfman-agent/cl_application_program.go 0.00% 29 Missing ⚠️
controllers/bpfman-agent/cl_tc_program.go 14.28% 16 Missing and 2 partials ⚠️
controllers/bpfman-agent/cl_tcx_program.go 14.28% 16 Missing and 2 partials ⚠️
controllers/bpfman-agent/common.go 5.26% 17 Missing and 1 partial ⚠️
controllers/bpfman-agent/ns_application_program.go 0.00% 18 Missing ⚠️
cmd/bpfman-agent/main.go 0.00% 9 Missing ⚠️
controllers/bpfman-agent/ns_tc_program.go 27.27% 6 Missing and 2 partials ⚠️
controllers/bpfman-agent/ns_tcx_program.go 27.27% 6 Missing and 2 partials ⚠️
apis/v1alpha1/zz_generated.deepcopy.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #408      +/-   ##
==========================================
- Coverage   31.69%   31.16%   -0.53%     
==========================================
  Files          66       66              
  Lines        7794     7919     +125     
==========================================
- Hits         2470     2468       -2     
- Misses       5097     5215     +118     
- Partials      227      236       +9     
Flag Coverage Δ
unittests 31.16% <10.27%> (-0.53%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@msherif1234 msherif1234 force-pushed the intf-discovery branch 3 times, most recently from 88ce99a to 3e82264 Compare March 7, 2025 13:48
@@ -80,53 +84,63 @@ type ClBpfApplicationProgram struct {

// xdp defines the desired state of the application's XdpPrograms.
// +unionMember
// +kubebuilder:validation:MinItems:=1
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work? They're all optional, and only one can be set, so they can't all have a minimum of 1 item at the same time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the existing validation takes care of it. Type is required, and then based on the type, one of the programInfo members needs to be set.

// automatically attaching eBPF hooks to newly discovered interfaces in both directions.
//+kubebuilder:default:=false
// +optional
AutoDiscovery bool `json:"autoDiscovery"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be called something like "InterfaceAutoDiscovery" to make it clear that it applies to interfaces. Also, will you need some additional configuration interfaces to ignore, or interface name patterns?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes we need interface list to ignore at min we can get fancy with regex matching later but I think for GA we need to enable it and make sure the interface is not in the ignore list

// +optional
XDPInfo *ClXdpProgramInfo `json:"xdpInfo,omitempty"`
XDPInfo []ClXdpProgramInfo `json:"xdpInfo,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you changing these to slices? As it is currently, the ClBpfApplicationProgram struct represents a single program of one of the types, and then []Programs in ClBpfApplicationSpec contains the list of programs in the application.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah scratch that no need to list here we have interface lists in each type will revert that

Copy link
Contributor

Choose a reason for hiding this comment

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

That could be done, but it would be a redesign of the existing model and logic. Currently, each program has a list of links that define where it will be attached. The interface-related programs have an Interface selector. I was thinking that we would extend the interface selector with an "auto-discover" option. Alternatively, it could be a separate entry in Cl*AttachInfo. Then, rather having to spell out each interface in the selector, it would trigger the auto-discovery process to figure it out. Then, the auto-discovery process would be responsible for populating some entries in Links []Cl*AttachInfoState. We'd need to identify which of these Link entries came from the standard Interface selector, and which came from the auto-discovery because they'd need to be processed a little differently. Alternatively, we could have another slice called AutoLinks []Cl*AttachInfoState for the links managed by auto discovery.

Copy link
Contributor

Choose a reason for hiding this comment

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

One way or another, I think the auto-discovery process will need to be able to populate a list of links for xdp, tc, and tcx programs based on the interfaces discovered. For each interface discovered, we will need a single link for each program that needs to be attached to the given interface.

@msherif1234 msherif1234 force-pushed the intf-discovery branch 5 times, most recently from cbc0cd8 to ea9ef1e Compare March 7, 2025 21:15
@anfredette
Copy link
Contributor

This looks good to me with the modifications. As a reminder, we'll need to implement #411 before you can attach the programs.

@msherif1234 msherif1234 force-pushed the intf-discovery branch 6 times, most recently from 2df77e6 to 8bc95d1 Compare March 10, 2025 17:33
Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
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.

2 participants