From 1f29e57437c46f5e63dd83c903d5fb5a53b3f17a Mon Sep 17 00:00:00 2001 From: Mohamed Mahmoud Date: Thu, 6 Jun 2024 11:25:19 -0400 Subject: [PATCH] move bytecode to app common to be configured at the top level Signed-off-by: Mohamed Mahmoud --- apis/v1alpha1/shared_types.go | 8 ++++---- apis/v1alpha1/zz_generated.deepcopy.go | 2 +- controllers/bpfman-agent/fentry-program_test.go | 6 +++--- controllers/bpfman-agent/fexit-program_test.go | 6 +++--- controllers/bpfman-agent/kprobe-program_test.go | 6 +++--- controllers/bpfman-agent/tc-program_test.go | 12 ++++++------ controllers/bpfman-agent/tracepoint-program_test.go | 6 +++--- controllers/bpfman-agent/uprobe-program_test.go | 6 +++--- controllers/bpfman-agent/xdp-program_test.go | 6 +++--- controllers/bpfman-operator/fentry-program_test.go | 6 +++--- controllers/bpfman-operator/fexit-program_test.go | 6 +++--- controllers/bpfman-operator/kprobe-program_test.go | 6 +++--- controllers/bpfman-operator/tc-program_test.go | 6 +++--- .../bpfman-operator/tracepoint-program_test.go | 6 +++--- controllers/bpfman-operator/uprobe-program_test.go | 6 +++--- controllers/bpfman-operator/xdp-program_test.go | 6 +++--- 16 files changed, 50 insertions(+), 50 deletions(-) diff --git a/apis/v1alpha1/shared_types.go b/apis/v1alpha1/shared_types.go index 8d11eef2f..c31bd8eb4 100644 --- a/apis/v1alpha1/shared_types.go +++ b/apis/v1alpha1/shared_types.go @@ -59,10 +59,6 @@ type BpfProgramCommon struct { // program BpfFunctionName string `json:"bpffunctionname"` - // Bytecode configures where the bpf program's bytecode should be loaded - // from. - ByteCode BytecodeSelector `json:"bytecode"` - // MapOwnerSelector is used to select the loaded eBPF program this eBPF program // will share a map with. The value is a label applied to the BpfProgram to select. // The selector must resolve to exactly one instance of a BpfProgram on a given node @@ -84,6 +80,10 @@ type BpfAppCommon struct { // such things as size, endianness, alignment and packing of data structures. // +optional GlobalData map[string][]byte `json:"globaldata,omitempty"` + + // Bytecode configures where the bpf program's bytecode should be loaded + // from. + ByteCode BytecodeSelector `json:"bytecode"` } // BpfProgramStatusCommon defines the BpfProgram status diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index a763e90d8..303fb614e 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -45,6 +45,7 @@ func (in *BpfAppCommon) DeepCopyInto(out *BpfAppCommon) { (*out)[key] = outVal } } + in.ByteCode.DeepCopyInto(&out.ByteCode) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BpfAppCommon. @@ -87,7 +88,6 @@ func (in *BpfProgram) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BpfProgramCommon) DeepCopyInto(out *BpfProgramCommon) { *out = *in - in.ByteCode.DeepCopyInto(&out.ByteCode) in.MapOwnerSelector.DeepCopyInto(&out.MapOwnerSelector) } diff --git a/controllers/bpfman-agent/fentry-program_test.go b/controllers/bpfman-agent/fentry-program_test.go index c72b8bb09..7e9925ed2 100644 --- a/controllers/bpfman-agent/fentry-program_test.go +++ b/controllers/bpfman-agent/fentry-program_test.go @@ -64,13 +64,13 @@ func TestFentryProgramControllerCreate(t *testing.T) { Spec: bpfmaniov1alpha1.FentryProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, FentryProgramInfo: bpfmaniov1alpha1.FentryProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, FunctionName: functionName, }, diff --git a/controllers/bpfman-agent/fexit-program_test.go b/controllers/bpfman-agent/fexit-program_test.go index 6dbb57604..51dfb615e 100644 --- a/controllers/bpfman-agent/fexit-program_test.go +++ b/controllers/bpfman-agent/fexit-program_test.go @@ -64,13 +64,13 @@ func TestFexitProgramControllerCreate(t *testing.T) { Spec: bpfmaniov1alpha1.FexitProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, FexitProgramInfo: bpfmaniov1alpha1.FexitProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, FunctionName: functionName, }, diff --git a/controllers/bpfman-agent/kprobe-program_test.go b/controllers/bpfman-agent/kprobe-program_test.go index 2b360c693..2a315610e 100644 --- a/controllers/bpfman-agent/kprobe-program_test.go +++ b/controllers/bpfman-agent/kprobe-program_test.go @@ -67,13 +67,13 @@ func TestKprobeProgramControllerCreate(t *testing.T) { Spec: bpfmaniov1alpha1.KprobeProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, KprobeProgramInfo: bpfmaniov1alpha1.KprobeProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, FunctionName: functionName, Offset: uint64(offset), diff --git a/controllers/bpfman-agent/tc-program_test.go b/controllers/bpfman-agent/tc-program_test.go index 303a6518d..7a75fb261 100644 --- a/controllers/bpfman-agent/tc-program_test.go +++ b/controllers/bpfman-agent/tc-program_test.go @@ -66,13 +66,13 @@ func TestTcProgramControllerCreate(t *testing.T) { Spec: bpfmaniov1alpha1.TcProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, TcProgramInfo: bpfmaniov1alpha1.TcProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, InterfaceSelector: bpfmaniov1alpha1.InterfaceSelector{ Interfaces: &[]string{fakeInt}, @@ -237,13 +237,13 @@ func TestTcProgramControllerCreateMultiIntf(t *testing.T) { Spec: bpfmaniov1alpha1.TcProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, TcProgramInfo: bpfmaniov1alpha1.TcProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, InterfaceSelector: bpfmaniov1alpha1.InterfaceSelector{ Interfaces: &fakeInts, diff --git a/controllers/bpfman-agent/tracepoint-program_test.go b/controllers/bpfman-agent/tracepoint-program_test.go index 7f6bfc839..b42dfb305 100644 --- a/controllers/bpfman-agent/tracepoint-program_test.go +++ b/controllers/bpfman-agent/tracepoint-program_test.go @@ -64,13 +64,13 @@ func TestTracepointProgramControllerCreate(t *testing.T) { Spec: bpfmaniov1alpha1.TracepointProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, TracepointProgramInfo: bpfmaniov1alpha1.TracepointProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, Names: []string{tracepointName}, }, diff --git a/controllers/bpfman-agent/uprobe-program_test.go b/controllers/bpfman-agent/uprobe-program_test.go index 296184e7f..72461c857 100644 --- a/controllers/bpfman-agent/uprobe-program_test.go +++ b/controllers/bpfman-agent/uprobe-program_test.go @@ -69,13 +69,13 @@ func TestUprobeProgramControllerCreate(t *testing.T) { Spec: bpfmaniov1alpha1.UprobeProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, UprobeProgramInfo: bpfmaniov1alpha1.UprobeProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, FunctionName: functionName, Target: target, diff --git a/controllers/bpfman-agent/xdp-program_test.go b/controllers/bpfman-agent/xdp-program_test.go index c90702820..b77ea53cb 100644 --- a/controllers/bpfman-agent/xdp-program_test.go +++ b/controllers/bpfman-agent/xdp-program_test.go @@ -80,13 +80,13 @@ func xdpProgramControllerCreate(t *testing.T, multiInterface bool, multiConditio Spec: bpfmaniov1alpha1.XdpProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, XdpProgramInfo: bpfmaniov1alpha1.XdpProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, InterfaceSelector: bpfmaniov1alpha1.InterfaceSelector{ Interfaces: &fakeInts, diff --git a/controllers/bpfman-operator/fentry-program_test.go b/controllers/bpfman-operator/fentry-program_test.go index 2ab5fdd33..a694a6ba7 100644 --- a/controllers/bpfman-operator/fentry-program_test.go +++ b/controllers/bpfman-operator/fentry-program_test.go @@ -58,14 +58,14 @@ func fentryProgramReconcile(t *testing.T, multiCondition bool) { Spec: bpfmaniov1alpha1.FentryProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, FentryProgramInfo: bpfmaniov1alpha1.FentryProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, FunctionName: functionName, }, diff --git a/controllers/bpfman-operator/fexit-program_test.go b/controllers/bpfman-operator/fexit-program_test.go index 48913b5bd..0eb732422 100644 --- a/controllers/bpfman-operator/fexit-program_test.go +++ b/controllers/bpfman-operator/fexit-program_test.go @@ -58,14 +58,14 @@ func fexitProgramReconcile(t *testing.T, multiCondition bool) { Spec: bpfmaniov1alpha1.FexitProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, FexitProgramInfo: bpfmaniov1alpha1.FexitProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, FunctionName: functionName, }, diff --git a/controllers/bpfman-operator/kprobe-program_test.go b/controllers/bpfman-operator/kprobe-program_test.go index ce1a61a10..6740e829b 100644 --- a/controllers/bpfman-operator/kprobe-program_test.go +++ b/controllers/bpfman-operator/kprobe-program_test.go @@ -60,14 +60,14 @@ func kprobeProgramReconcile(t *testing.T, multiCondition bool) { Spec: bpfmaniov1alpha1.KprobeProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, KprobeProgramInfo: bpfmaniov1alpha1.KprobeProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, FunctionName: functionName, Offset: uint64(offset), diff --git a/controllers/bpfman-operator/tc-program_test.go b/controllers/bpfman-operator/tc-program_test.go index 737dcc99c..9acc04d1f 100644 --- a/controllers/bpfman-operator/tc-program_test.go +++ b/controllers/bpfman-operator/tc-program_test.go @@ -57,14 +57,14 @@ func TestTcProgramReconcile(t *testing.T) { Spec: bpfmaniov1alpha1.TcProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, TcProgramInfo: bpfmaniov1alpha1.TcProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, InterfaceSelector: bpfmaniov1alpha1.InterfaceSelector{ Interfaces: &[]string{fakeInt}, diff --git a/controllers/bpfman-operator/tracepoint-program_test.go b/controllers/bpfman-operator/tracepoint-program_test.go index 1efa2b8d5..3e9ce3a79 100644 --- a/controllers/bpfman-operator/tracepoint-program_test.go +++ b/controllers/bpfman-operator/tracepoint-program_test.go @@ -55,14 +55,14 @@ func TestTracepointProgramReconcile(t *testing.T) { Spec: bpfmaniov1alpha1.TracepointProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, TracepointProgramInfo: bpfmaniov1alpha1.TracepointProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, Names: []string{tracepointName}, }, diff --git a/controllers/bpfman-operator/uprobe-program_test.go b/controllers/bpfman-operator/uprobe-program_test.go index 18f3f04e1..6d169156d 100644 --- a/controllers/bpfman-operator/uprobe-program_test.go +++ b/controllers/bpfman-operator/uprobe-program_test.go @@ -58,14 +58,14 @@ func TestUprobeProgramReconcile(t *testing.T) { Spec: bpfmaniov1alpha1.UprobeProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, UprobeProgramInfo: bpfmaniov1alpha1.UprobeProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, FunctionName: functionName, Target: target, diff --git a/controllers/bpfman-operator/xdp-program_test.go b/controllers/bpfman-operator/xdp-program_test.go index 10bedf796..cd70b54b0 100644 --- a/controllers/bpfman-operator/xdp-program_test.go +++ b/controllers/bpfman-operator/xdp-program_test.go @@ -55,14 +55,14 @@ func TestXdpProgramReconcile(t *testing.T) { Spec: bpfmaniov1alpha1.XdpProgramSpec{ BpfAppCommon: bpfmaniov1alpha1.BpfAppCommon{ NodeSelector: metav1.LabelSelector{}, + ByteCode: bpfmaniov1alpha1.BytecodeSelector{ + Path: &bytecodePath, + }, }, XdpProgramInfo: bpfmaniov1alpha1.XdpProgramInfo{ BpfProgramCommon: bpfmaniov1alpha1.BpfProgramCommon{ BpfFunctionName: bpfFunctionName, - ByteCode: bpfmaniov1alpha1.BytecodeSelector{ - Path: &bytecodePath, - }, }, InterfaceSelector: bpfmaniov1alpha1.InterfaceSelector{ Interfaces: &[]string{fakeInt},