-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Refactor: Use interface to configure libbpf global data when loading bpf programs. #9663
base: master
Are you sure you want to change the base?
Conversation
felix/bpf/libbpf/libbpf.go
Outdated
@@ -492,6 +485,20 @@ func XDPSetGlobals( | |||
return err | |||
} | |||
|
|||
func SetGlobalData(m *Map, data interface{}) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func SetGlobalData(m *Map, data interface{}) error { | |
func SetGlobalData(m *Map, data any) error { |
felix/bpf/libbpf/libbpf.go
Outdated
func SetGlobalData(m *Map, data interface{}) error { | ||
switch v := data.(type) { | ||
case *TcGlobalData: | ||
return tcSetGlobals(m, v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not to have this function to be a method of each of the globals structs and then define an interface with that method (if need be) and call that method rather than using any and this switch?
felix/bpf/conntrack/bpf_scanner.go
Outdated
@@ -145,17 +145,17 @@ func (s *BPFProgLivenessScanner) ensureBPFExpiryProgram() (*libbpf.Obj, error) { | |||
continue | |||
} | |||
|
|||
err := libbpf.CTCleanupSetGlobals( | |||
err := libbpf.SetGlobalData( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be?
err := libbpf.SetGlobalData( | |
err := &libbpf.CTCleanupGlobalData{...}.Set(m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer doing it this way. Will update the PR shortly.
Description
We have different set of global data one for Tc programs, one for CTLB and one for conntrack cleanup when loading bpf programs. Configuring each global has a separate API. This PR provides a single API to configure global data for bpf programs.
Related issues/PRs
Todos
Release Note
Reminder for the reviewer
Make sure that this PR has the correct labels and milestone set.
Every PR needs one
docs-*
label.docs-pr-required
: This change requires a change to the documentation that has not been completed yet.docs-completed
: This change has all necessary documentation completed.docs-not-required
: This change has no user-facing impact and requires no docs.Every PR needs one
release-note-*
label.release-note-required
: This PR has user-facing changes. Most PRs should have this label.release-note-not-required
: This PR has no user-facing changes.Other optional labels:
cherry-pick-candidate
: This PR should be cherry-picked to an earlier release. For bug fixes only.needs-operator-pr
: This PR is related to install and requires a corresponding change to the operator.