Skip to content

Commit 94b2131

Browse files
committed
WIP: Initial pass at BpfApplication CRD update for load/attach split
The main change is that a separate optional list of attach points is included with each program (except for fentry and fexit programs that just include an attach boolean). Otherwise, the info is all the same. The list of attach points may be updated any time after the programs are loaded, which allows the program to be loaded before any attachments are made, and allows attachments to be added after the program has been loaded. Existing controllers have been updated to work with new CRDs, but they only work with a single attach point per program. I've updated the bpfman.io_v1alpha1_bpfapplication.yaml, but the others still have the old format and won't work with the current code. TODO: Add a per-node CRD (BpfProgram analog) to maintain the per-node state for the BpfApplication. Signed-off-by: Andre Fredette <[email protected]>
1 parent 48d744b commit 94b2131

File tree

86 files changed

+5415
-4568
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+5415
-4568
lines changed

apis/v1alpha1/bpfApplication_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ type BpfApplicationSpec struct {
138138

139139
// BpfApplicationStatus defines the observed state of BpfApplication
140140
type BpfApplicationStatus struct {
141-
BpfProgramStatusCommon `json:",inline"`
141+
BpfAppStatus `json:",inline"`
142142
}
143143

144144
// +genclient
@@ -155,8 +155,8 @@ type BpfApplication struct {
155155
metav1.TypeMeta `json:",inline"`
156156
metav1.ObjectMeta `json:"metadata,omitempty"`
157157

158-
Spec BpfApplicationSpec `json:"spec,omitempty"`
159-
Status BpfApplicationStatus `json:"status,omitempty"`
158+
Spec BpfApplicationSpec `json:"spec,omitempty"`
159+
Status BpfAppStatus `json:"status,omitempty"`
160160
}
161161

162162
// +kubebuilder:object:root=true

apis/v1alpha1/bpfNsApplication_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ type BpfNsApplication struct {
8585
metav1.ObjectMeta `json:"metadata,omitempty"`
8686

8787
Spec BpfNsApplicationSpec `json:"spec,omitempty"`
88-
Status BpfApplicationStatus `json:"status,omitempty"`
88+
Status BpfAppStatus `json:"status,omitempty"`
8989
}
9090

9191
// +kubebuilder:object:root=true

apis/v1alpha1/fentryProgram_types.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ type FentryProgram struct {
3737
metav1.TypeMeta `json:",inline"`
3838
metav1.ObjectMeta `json:"metadata,omitempty"`
3939

40-
Spec FentryProgramSpec `json:"spec"`
41-
// +optional
42-
Status FentryProgramStatus `json:"status,omitempty"`
40+
Spec FentryProgramSpec `json:"spec"`
41+
Status BpfAppStatus `json:"status,omitempty"`
4342
}
4443

4544
// FentryProgramSpec defines the desired state of FentryProgram
@@ -52,13 +51,19 @@ type FentryProgramSpec struct {
5251
// FentryProgramInfo defines the Fentry program details
5352
type FentryProgramInfo struct {
5453
BpfProgramCommon `json:",inline"`
55-
// Function to attach the fentry to.
56-
FunctionName string `json:"func_name"`
54+
FentryLoadInfo `json:",inline"`
55+
// Whether the program should be attached to the function.
56+
// This may be updated after the program has been loaded.
57+
// +optional
58+
// +kubebuilder:default=false
59+
Attach bool `json:"attach,omitempty"`
5760
}
5861

59-
// FentryProgramStatus defines the observed state of FentryProgram
60-
type FentryProgramStatus struct {
61-
BpfProgramStatusCommon `json:",inline"`
62+
// FentryLoadInfo contains the program-specific load information for Fentry
63+
// programs
64+
type FentryLoadInfo struct {
65+
// FunctionName is the name of the function to attach the Fentry program to.
66+
FunctionName string `json:"function_name"`
6267
}
6368

6469
// +kubebuilder:object:root=true

apis/v1alpha1/fexitProgram_types.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ type FexitProgram struct {
3737
metav1.TypeMeta `json:",inline"`
3838
metav1.ObjectMeta `json:"metadata,omitempty"`
3939

40-
Spec FexitProgramSpec `json:"spec"`
41-
// +optional
42-
Status FexitProgramStatus `json:"status,omitempty"`
40+
Spec FexitProgramSpec `json:"spec"`
41+
Status BpfAppStatus `json:"status,omitempty"`
4342
}
4443

4544
// FexitProgramSpec defines the desired state of FexitProgram
@@ -52,13 +51,19 @@ type FexitProgramSpec struct {
5251
// FexitProgramInfo defines the Fexit program details
5352
type FexitProgramInfo struct {
5453
BpfProgramCommon `json:",inline"`
55-
// Function to attach the fexit to.
56-
FunctionName string `json:"func_name"`
54+
FexitLoadInfo `json:",inline"`
55+
// Whether the program should be attached to the function.
56+
// This may be updated after the program has been loaded.
57+
// +optional
58+
// +kubebuilder:default=false
59+
Attach bool `json:"attach,omitempty"`
5760
}
5861

59-
// FexitProgramStatus defines the observed state of FexitProgram
60-
type FexitProgramStatus struct {
61-
BpfProgramStatusCommon `json:",inline"`
62+
// FexitLoadInfo contains the program-specific load information for Fexit
63+
// programs
64+
type FexitLoadInfo struct {
65+
// FunctionName is the name of the function to attach the Fexit program to.
66+
FunctionName string `json:"function_name"`
6267
}
6368

6469
// +kubebuilder:object:root=true

apis/v1alpha1/kprobeProgram_types.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,14 @@ type KprobeProgram struct {
3939
metav1.TypeMeta `json:",inline"`
4040
metav1.ObjectMeta `json:"metadata,omitempty"`
4141

42-
Spec KprobeProgramSpec `json:"spec"`
43-
// +optional
44-
Status KprobeProgramStatus `json:"status,omitempty"`
42+
Spec KprobeProgramSpec `json:"spec"`
43+
Status BpfAppStatus `json:"status,omitempty"`
4544
}
4645

4746
// KprobeProgramSpec defines the desired state of KprobeProgram
4847
// +kubebuilder:printcolumn:name="FunctionName",type=string,JSONPath=`.spec.func_name`
4948
// +kubebuilder:printcolumn:name="Offset",type=integer,JSONPath=`.spec.offset`
5049
// +kubebuilder:printcolumn:name="RetProbe",type=boolean,JSONPath=`.spec.retprobe`
51-
// +kubebuilder:validation:XValidation:message="offset cannot be set for kretprobes",rule="self.retprobe == false || self.offset == 0"
5250
type KprobeProgramSpec struct {
5351
KprobeProgramInfo `json:",inline"`
5452
BpfAppCommon `json:",inline"`
@@ -57,7 +55,14 @@ type KprobeProgramSpec struct {
5755
// KprobeProgramInfo defines the common fields for KprobeProgram
5856
type KprobeProgramInfo struct {
5957
BpfProgramCommon `json:",inline"`
58+
// The list of points to which the program should be attached. The list is
59+
// optional and may be udated after the bpf program has been loaded
60+
// +optional
61+
AttachPoints []KprobeAttachInfo `json:"attach_points"`
62+
}
6063

64+
// +kubebuilder:validation:XValidation:message="offset cannot be set for kretprobes",rule="self.retprobe == false || self.offset == 0"
65+
type KprobeAttachInfo struct {
6166
// Functions to attach the kprobe to.
6267
FunctionName string `json:"func_name"`
6368

@@ -73,11 +78,6 @@ type KprobeProgramInfo struct {
7378
RetProbe bool `json:"retprobe"`
7479
}
7580

76-
// KprobeProgramStatus defines the observed state of KprobeProgram
77-
type KprobeProgramStatus struct {
78-
BpfProgramStatusCommon `json:",inline"`
79-
}
80-
8181
// +kubebuilder:object:root=true
8282
// KprobeProgramList contains a list of KprobePrograms
8383
type KprobeProgramList struct {

apis/v1alpha1/shared_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ type BpfAppCommon struct {
100100
ByteCode BytecodeSelector `json:"bytecode"`
101101
}
102102

103-
// BpfProgramStatusCommon defines the BpfProgram status
104-
type BpfProgramStatusCommon struct {
103+
// BpfAppStatus defines the BpfProgram status
104+
type BpfAppStatus struct {
105105
// Conditions houses the global cluster state for the eBPFProgram. The explicit
106106
// condition types are defined internally.
107107
// +patchMergeKey=type

apis/v1alpha1/tcNsProgram_types.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type TcNsProgram struct {
4141

4242
Spec TcNsProgramSpec `json:"spec"`
4343
// +optional
44-
Status TcProgramStatus `json:"status,omitempty"`
44+
Status BpfAppStatus `json:"status,omitempty"`
4545
}
4646

4747
// TcNsProgramSpec defines the desired state of TcNsProgram
@@ -50,10 +50,16 @@ type TcNsProgramSpec struct {
5050
BpfAppCommon `json:",inline"`
5151
}
5252

53-
// TcNsProgramInfo defines the tc program details
53+
// TcProgramInfo defines the tc program details
5454
type TcNsProgramInfo struct {
5555
BpfProgramCommon `json:",inline"`
56+
// The list of points to which the program should be attached. The list is
57+
// optional and may be udated after the bpf program has been loaded
58+
// +optional
59+
AttachPoints []TcNsAttachInfo `json:"attach_points"`
60+
}
5661

62+
type TcNsAttachInfo struct {
5763
// Selector to determine the network interface (or interfaces)
5864
InterfaceSelector InterfaceSelector `json:"interfaceselector"`
5965

apis/v1alpha1/tcProgram_types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ type TcProgram struct {
4040
metav1.TypeMeta `json:",inline"`
4141
metav1.ObjectMeta `json:"metadata,omitempty"`
4242

43-
Spec TcProgramSpec `json:"spec"`
44-
// +optional
45-
Status TcProgramStatus `json:"status,omitempty"`
43+
Spec TcProgramSpec `json:"spec"`
44+
Status BpfAppStatus `json:"status,omitempty"`
4645
}
4746

4847
// +kubebuilder:validation:Enum=unspec;ok;reclassify;shot;pipe;stolen;queued;repeat;redirect;trap;dispatcher_return
@@ -57,7 +56,13 @@ type TcProgramSpec struct {
5756
// TcProgramInfo defines the tc program details
5857
type TcProgramInfo struct {
5958
BpfProgramCommon `json:",inline"`
59+
// The list of points to which the program should be attached. The list is
60+
// optional and may be udated after the bpf program has been loaded
61+
// +optional
62+
AttachPoints []TcAttachInfo `json:"attach_points"`
63+
}
6064

65+
type TcAttachInfo struct {
6166
// Selector to determine the network interface (or interfaces)
6267
InterfaceSelector InterfaceSelector `json:"interfaceselector"`
6368

@@ -87,11 +92,6 @@ type TcProgramInfo struct {
8792
ProceedOn []TcProceedOnValue `json:"proceedon"`
8893
}
8994

90-
// TcProgramStatus defines the observed state of TcProgram
91-
type TcProgramStatus struct {
92-
BpfProgramStatusCommon `json:",inline"`
93-
}
94-
9595
// +kubebuilder:object:root=true
9696
// TcProgramList contains a list of TcPrograms
9797
type TcProgramList struct {

apis/v1alpha1/tcxNsProgram_types.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type TcxNsProgram struct {
4141

4242
Spec TcxNsProgramSpec `json:"spec"`
4343
// +optional
44-
Status TcxProgramStatus `json:"status,omitempty"`
44+
Status BpfAppStatus `json:"status,omitempty"`
4545
}
4646

4747
// TcxNsProgramSpec defines the desired state of TcxNsProgram
@@ -53,12 +53,19 @@ type TcxNsProgramSpec struct {
5353
// TcxNsProgramInfo defines the TCX Ns Program details
5454
type TcxNsProgramInfo struct {
5555
BpfProgramCommon `json:",inline"`
56+
// The list of points to which the program should be attached. The list is
57+
// optional and may be udated after the bpf program has been loaded
58+
// +optional
59+
AttachPoints []TcxNsAttachInfo `json:"attach_points"`
60+
}
5661

62+
type TcxNsAttachInfo struct {
5763
// Selector to determine the network interface (or interfaces)
5864
InterfaceSelector InterfaceSelector `json:"interfaceselector"`
5965

6066
// Containers identifies the set of containers in which to attach the eBPF
61-
// program.
67+
// program. If Containers is not specified, the BPF program will be attached
68+
// in the root network namespace.
6269
Containers ContainerNsSelector `json:"containers"`
6370

6471
// Direction specifies the direction of traffic the tcx program should

apis/v1alpha1/tcxProgram_types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ type TcxProgram struct {
4040
metav1.TypeMeta `json:",inline"`
4141
metav1.ObjectMeta `json:"metadata,omitempty"`
4242

43-
Spec TcxProgramSpec `json:"spec"`
44-
// +optional
45-
Status TcxProgramStatus `json:"status,omitempty"`
43+
Spec TcxProgramSpec `json:"spec"`
44+
Status BpfAppStatus `json:"status,omitempty"`
4645
}
4746

4847
// TcxProgramSpec defines the desired state of TcxProgram
@@ -54,7 +53,13 @@ type TcxProgramSpec struct {
5453
// TcxProgramInfo defines the tc program details
5554
type TcxProgramInfo struct {
5655
BpfProgramCommon `json:",inline"`
56+
// The list of points to which the program should be attached. The list is
57+
// optional and may be udated after the bpf program has been loaded
58+
// +optional
59+
AttachPoints []TcxAttachInfo `json:"attach_points"`
60+
}
5761

62+
type TcxAttachInfo struct {
5863
// Selector to determine the network interface (or interfaces)
5964
InterfaceSelector InterfaceSelector `json:"interfaceselector"`
6065

@@ -77,11 +82,6 @@ type TcxProgramInfo struct {
7782
Priority int32 `json:"priority"`
7883
}
7984

80-
// TcxProgramStatus defines the observed state of TcxProgram
81-
type TcxProgramStatus struct {
82-
BpfProgramStatusCommon `json:",inline"`
83-
}
84-
8585
// +kubebuilder:object:root=true
8686
// TcxProgramList contains a list of TcxPrograms
8787
type TcxProgramList struct {

0 commit comments

Comments
 (0)