Skip to content

Commit

Permalink
Make existing controllers work with new CRDs
Browse files Browse the repository at this point in the history
Limitation: They only work with a single attach point per program.

Signed-off-by: Andre Fredette <[email protected]>
  • Loading branch information
anfredette committed Dec 10, 2024
1 parent aa91d11 commit 0531a5f
Show file tree
Hide file tree
Showing 72 changed files with 2,387 additions and 2,001 deletions.
4 changes: 2 additions & 2 deletions apis/v1alpha1/bpfapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ type BpfApplication struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec BpfApplicationSpec `json:"spec,omitempty"`
Status BpfApplicationStatus `json:"status,omitempty"`
Spec BpfApplicationSpec `json:"spec,omitempty"`
Status BpfAppStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
9 changes: 5 additions & 4 deletions apis/v1alpha1/fentryProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ type FentryProgram struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec FentryProgramSpec `json:"spec"`
Spec FentryProgramSpec `json:"spec"`
Status BpfAppStatus `json:"status,omitempty"`
}

// FentryProgramSpec defines the desired state of FentryProgram
Expand All @@ -51,11 +52,11 @@ type FentryProgramSpec struct {
type FentryProgramInfo struct {
BpfProgramCommon `json:",inline"`
FentryLoadInfo `json:",inline"`
// Whether the program should be attached to the function.
// This may be updated after the program has been loaded.
// Whether the program should be attached to the function.
// This may be updated after the program has been loaded.
// +optional
// +kubebuilder:default=false
attach bool `json:"attach,omitempty"`
Attach bool `json:"attach,omitempty"`
}

// FentryLoadInfo contains the program-specific load information for Fentry
Expand Down
5 changes: 3 additions & 2 deletions apis/v1alpha1/fexitProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ type FexitProgram struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec FexitProgramSpec `json:"spec"`
Spec FexitProgramSpec `json:"spec"`
Status BpfAppStatus `json:"status,omitempty"`
}

// FexitProgramSpec defines the desired state of FexitProgram
Expand All @@ -55,7 +56,7 @@ type FexitProgramInfo struct {
// This may be updated after the program has been loaded.
// +optional
// +kubebuilder:default=false
attach bool `json:"attach,omitempty"`
Attach bool `json:"attach,omitempty"`
}

// FexitLoadInfo contains the program-specific load information for Fexit
Expand Down
5 changes: 3 additions & 2 deletions apis/v1alpha1/kprobeProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ type KprobeProgram struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec KprobeProgramSpec `json:"spec"`
Spec KprobeProgramSpec `json:"spec"`
Status BpfAppStatus `json:"status,omitempty"`
}

// KprobeProgramSpec defines the desired state of KprobeProgram
// +kubebuilder:printcolumn:name="FunctionName",type=string,JSONPath=`.spec.func_name`
// +kubebuilder:printcolumn:name="Offset",type=integer,JSONPath=`.spec.offset`
// +kubebuilder:printcolumn:name="RetProbe",type=boolean,JSONPath=`.spec.retprobe`
// +kubebuilder:validation:XValidation:message="offset cannot be set for kretprobes",rule="self.retprobe == false || self.offset == 0"
type KprobeProgramSpec struct {
KprobeProgramInfo `json:",inline"`
BpfAppCommon `json:",inline"`
Expand All @@ -61,6 +61,7 @@ type KprobeProgramInfo struct {
AttachPoints []KprobeAttachInfo `json:"attach_points"`
}

// +kubebuilder:validation:XValidation:message="offset cannot be set for kretprobes",rule="self.retprobe == false || self.offset == 0"
type KprobeAttachInfo struct {
// Functions to attach the kprobe to.
FunctionName string `json:"func_name"`
Expand Down
3 changes: 0 additions & 3 deletions apis/v1alpha1/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ type BpfAppCommon struct {
// Bytecode configures where the bpf program's bytecode should be loaded
// from.
ByteCode BytecodeSelector `json:"bytecode"`

// Status of the BpfApp
Status BpfAppStatus `json:"status,omitempty"`
}

// BpfAppStatus defines the BpfProgram status
Expand Down
3 changes: 2 additions & 1 deletion apis/v1alpha1/tcProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ type TcProgram struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec TcProgramSpec `json:"spec"`
Spec TcProgramSpec `json:"spec"`
Status BpfAppStatus `json:"status,omitempty"`
}

// +kubebuilder:validation:Enum=unspec;ok;reclassify;shot;pipe;stolen;queued;repeat;redirect;trap;dispatcher_return
Expand Down
3 changes: 2 additions & 1 deletion apis/v1alpha1/tcxProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ type TcxProgram struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec TcxProgramSpec `json:"spec"`
Spec TcxProgramSpec `json:"spec"`
Status BpfAppStatus `json:"status,omitempty"`
}

// TcxProgramSpec defines the desired state of TcxProgram
Expand Down
3 changes: 2 additions & 1 deletion apis/v1alpha1/tracepointProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ type TracepointProgram struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec TracepointProgramSpec `json:"spec"`
Spec TracepointProgramSpec `json:"spec"`
Status BpfAppStatus `json:"status,omitempty"`
}

// TracepointProgramSpec defines the desired state of TracepointProgram
Expand Down
3 changes: 2 additions & 1 deletion apis/v1alpha1/uprobeProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ type UprobeProgram struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec UprobeProgramSpec `json:"spec"`
Spec UprobeProgramSpec `json:"spec"`
Status BpfAppStatus `json:"status,omitempty"`
}

// UprobeProgramSpec defines the desired state of UprobeProgram
Expand Down
3 changes: 2 additions & 1 deletion apis/v1alpha1/xdpProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ type XdpProgram struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec XdpProgramSpec `json:"spec"`
Spec XdpProgramSpec `json:"spec"`
Status BpfAppStatus `json:"status,omitempty"`
}

// +kubebuilder:validation:Enum=aborted;drop;pass;tx;redirect;dispatcher_return
Expand Down
9 changes: 8 additions & 1 deletion apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 63 additions & 41 deletions bundle/manifests/bpfman-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,73 +23,95 @@ metadata:
"programs": [
{
"kprobe": {
"bpffunctionname": "kprobe_counter",
"func_name": "try_to_wake_up",
"offset": 0,
"retprobe": false
"attach_points": [
{
"func_name": "try_to_wake_up",
"offset": 0,
"retprobe": false
}
],
"bpffunctionname": "kprobe_counter"
},
"type": "Kprobe"
},
{
"tracepoint": {
"bpffunctionname": "tracepoint_kill_recorder",
"names": [
"syscalls/sys_enter_kill"
]
"attach_points": [
{
"name": "syscalls/sys_enter_kill"
}
],
"bpffunctionname": "tracepoint_kill_recorder"
},
"type": "Tracepoint"
},
{
"tc": {
"bpffunctionname": "stats",
"direction": "ingress",
"interfaceselector": {
"primarynodeinterface": true
},
"priority": 55
"attach_points": [
{
"direction": "ingress",
"interfaceselector": {
"primarynodeinterface": true
},
"priority": 55
}
],
"bpffunctionname": "stats"
},
"type": "TC"
},
{
"tcx": {
"bpffunctionname": "tcx_stats",
"direction": "ingress",
"interfaceselector": {
"primarynodeinterface": true
},
"priority": 500
"attach_points": [
{
"direction": "ingress",
"interfaceselector": {
"primarynodeinterface": true
},
"priority": 500
}
],
"bpffunctionname": "tcx_stats"
},
"type": "TCX"
},
{
"type": "Uprobe",
"uprobe": {
"bpffunctionname": "uprobe_counter",
"containers": {
"containernames": [
"bpfman",
"bpfman-agent"
],
"namespace": "bpfman",
"pods": {
"matchLabels": {
"name": "bpfman-daemon"
}
"attach_points": [
{
"containers": {
"containernames": [
"bpfman",
"bpfman-agent"
],
"namespace": "bpfman",
"pods": {
"matchLabels": {
"name": "bpfman-daemon"
}
}
},
"func_name": "malloc",
"retprobe": false,
"target": "libc"
}
},
"func_name": "malloc",
"retprobe": false,
"target": "libc"
],
"bpffunctionname": "uprobe_counter"
}
},
{
"type": "XDP",
"xdp": {
"bpffunctionname": "xdp_stats",
"interfaceselector": {
"primarynodeinterface": true
},
"priority": 55
"attach_points": [
{
"interfaceselector": {
"primarynodeinterface": true
},
"priority": 55
}
],
"bpffunctionname": "xdp_stats"
}
}
]
Expand Down Expand Up @@ -307,7 +329,7 @@ metadata:
capabilities: Basic Install
categories: OpenShift Optional
containerImage: quay.io/bpfman/bpfman-operator:latest
createdAt: "2024-12-06T14:27:05Z"
createdAt: "2024-12-10T22:10:31Z"
features.operators.openshift.io/cnf: "false"
features.operators.openshift.io/cni: "false"
features.operators.openshift.io/csi: "true"
Expand Down
Loading

0 comments on commit 0531a5f

Please sign in to comment.