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

move global data and node selector out of the bpfcommon data struct #17

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions apis/v1alpha1/fentryProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,20 @@ type FentryProgram struct {
// FentryProgramSpec defines the desired state of FentryProgram
// +kubebuilder:printcolumn:name="FunctionName",type=string,JSONPath=`.spec.func_name`
type FentryProgramSpec struct {
BpfProgramCommon `json:",inline"`
FentryProgramInfo `json:",inline"`
BpfAppCommon `json:",inline"`
}

// FentryProgramInfo defines the Fentry program details
type FentryProgramInfo struct {
BpfProgramCommon `json:",inline"`
// Function to attach the fentry to.
FunctionName string `json:"func_name"`
}

// FentryProgramStatus defines the observed state of FentryProgram
type FentryProgramStatus struct {
// Conditions houses the global cluster state for the FentryProgram. The explicit
// condition types are defined internally.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
BpfProgramStatusCommon `json:",inline"`
}

// +kubebuilder:object:root=true
Expand Down
15 changes: 7 additions & 8 deletions apis/v1alpha1/fexitProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,20 @@ type FexitProgram struct {
// FexitProgramSpec defines the desired state of FexitProgram
// +kubebuilder:printcolumn:name="FunctionName",type=string,JSONPath=`.spec.func_name`
type FexitProgramSpec struct {
BpfProgramCommon `json:",inline"`
FexitProgramInfo `json:",inline"`
BpfAppCommon `json:",inline"`
}

// FexitProgramInfo defines the Fexit program details
type FexitProgramInfo struct {
BpfProgramCommon `json:",inline"`
// Function to attach the fexit to.
FunctionName string `json:"func_name"`
}

// FexitProgramStatus defines the observed state of FexitProgram
type FexitProgramStatus struct {
// Conditions houses the global cluster state for the FexitProgram. The explicit
// condition types are defined internally.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
BpfProgramStatusCommon `json:",inline"`
}

// +kubebuilder:object:root=true
Expand Down
14 changes: 7 additions & 7 deletions apis/v1alpha1/kprobeProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ type KprobeProgram struct {
// +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"`
}

// KprobeProgramInfo defines the common fields for KprobeProgram
type KprobeProgramInfo struct {
BpfProgramCommon `json:",inline"`

// Functions to attach the kprobe to.
Expand All @@ -73,13 +79,7 @@ type KprobeProgramSpec struct {

// KprobeProgramStatus defines the observed state of KprobeProgram
type KprobeProgramStatus struct {
// Conditions houses the global cluster state for the KprobeProgram. The explicit
// condition types are defined internally.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
BpfProgramStatusCommon `json:",inline"`
}

// +kubebuilder:object:root=true
Expand Down
38 changes: 26 additions & 12 deletions apis/v1alpha1/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,10 @@ type BpfProgramCommon struct {
// program
BpfFunctionName string `json:"bpffunctionname"`

// NodeSelector allows the user to specify which nodes to deploy the
// bpf program to. This field must be specified, to select all nodes
// use standard metav1.LabelSelector semantics and make it empty.
NodeSelector metav1.LabelSelector `json:"nodeselector"`

// Bytecode configures where the bpf program's bytecode should be loaded
// from.
ByteCode BytecodeSelector `json:"bytecode"`

// GlobalData allows the user to to set global variables when the program is loaded
// with an array of raw bytes. This is a very low level primitive. The caller
// is responsible for formatting the byte string appropriately considering
// such things as size, endianness, alignment and packing of data structures.
// +optional
GlobalData map[string][]byte `json:"globaldata,omitempty"`

// 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
Expand All @@ -83,6 +71,32 @@ type BpfProgramCommon struct {
MapOwnerSelector metav1.LabelSelector `json:"mapownerselector"`
}

// BpfAppCommon defines the common attributes for all BpfApp programs
type BpfAppCommon struct {
// NodeSelector allows the user to specify which nodes to deploy the
// bpf program to. This field must be specified, to select all nodes
// use standard metav1.LabelSelector semantics and make it empty.
NodeSelector metav1.LabelSelector `json:"nodeselector"`

// GlobalData allows the user to set global variables when the program is loaded
// with an array of raw bytes. This is a very low level primitive. The caller
// is responsible for formatting the byte string appropriately considering
// such things as size, endianness, alignment and packing of data structures.
// +optional
GlobalData map[string][]byte `json:"globaldata,omitempty"`
}

// BpfProgramStatusCommon defines the BpfProgram status
type BpfProgramStatusCommon struct {
// Conditions houses the global cluster state for the eBPFProgram. The explicit
// condition types are defined internally.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
}

// PullPolicy describes a policy for if/when to pull a container image
// +kubebuilder:validation:Enum=Always;Never;IfNotPresent
type PullPolicy string
Expand Down
14 changes: 7 additions & 7 deletions apis/v1alpha1/tcProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ type TcProceedOnValue string

// TcProgramSpec defines the desired state of TcProgram
type TcProgramSpec struct {
TcProgramInfo `json:",inline"`
BpfAppCommon `json:",inline"`
}

// TcProgramInfo defines the tc program details
type TcProgramInfo struct {
BpfProgramCommon `json:",inline"`

// Selector to determine the network interface (or interfaces)
Expand Down Expand Up @@ -77,13 +83,7 @@ type TcProgramSpec struct {

// TcProgramStatus defines the observed state of TcProgram
type TcProgramStatus struct {
// Conditions houses the global cluster state for the TcProgram. The explicit
// condition types are defined internally.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
BpfProgramStatusCommon `json:",inline"`
}

// +kubebuilder:object:root=true
Expand Down
14 changes: 7 additions & 7 deletions apis/v1alpha1/tracepointProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ type TracepointProgram struct {
// TracepointProgramSpec defines the desired state of TracepointProgram
// +kubebuilder:printcolumn:name="TracePoint",type=string,JSONPath=`.spec.name`
type TracepointProgramSpec struct {
TracepointProgramInfo `json:",inline"`
BpfAppCommon `json:",inline"`
}

// TracepointProgramInfo defines the Tracepoint program details
type TracepointProgramInfo struct {
BpfProgramCommon `json:",inline"`

// Names refers to the names of kernel tracepoints to attach the
Expand All @@ -54,13 +60,7 @@ type TracepointProgramSpec struct {

// TracepointProgramStatus defines the observed state of TracepointProgram
type TracepointProgramStatus struct {
// Conditions houses the global cluster state for the TracepointProgram. The explicit
// condition types are defined internally.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
BpfProgramStatusCommon `json:",inline"`
}

// +kubebuilder:object:root=true
Expand Down
14 changes: 7 additions & 7 deletions apis/v1alpha1/uprobeProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ type UprobeProgram struct {
// +kubebuilder:printcolumn:name="RetProbe",type=boolean,JSONPath=`.spec.retprobe`
// +kubebuilder:printcolumn:name="Pid",type=integer,JSONPath=`.spec.pid`
type UprobeProgramSpec struct {
UprobeProgramInfo `json:",inline"`
BpfAppCommon `json:",inline"`
}

// UprobeProgramInfo contains the information about the uprobe program
type UprobeProgramInfo struct {
BpfProgramCommon `json:",inline"`

// Function to attach the uprobe to.
Expand Down Expand Up @@ -89,13 +95,7 @@ type UprobeProgramSpec struct {

// UprobeProgramStatus defines the observed state of UprobeProgram
type UprobeProgramStatus struct {
// Conditions houses the global cluster state for the UprobeProgram. The explicit
// condition types are defined internally.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
BpfProgramStatusCommon `json:",inline"`
}

// +kubebuilder:object:root=true
Expand Down
15 changes: 7 additions & 8 deletions apis/v1alpha1/xdpProgram_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ type XdpProceedOnValue string

// XdpProgramSpec defines the desired state of XdpProgram
type XdpProgramSpec struct {
BpfProgramCommon `json:",inline"`
XdpProgramInfo `json:",inline"`
BpfAppCommon `json:",inline"`
}

// XdpProgramInfo defines the common fields for all XdpProgram types
type XdpProgramInfo struct {
BpfProgramCommon `json:",inline"`
// Selector to determine the network interface (or interfaces)
InterfaceSelector InterfaceSelector `json:"interfaceselector"`

Expand All @@ -72,13 +77,7 @@ type XdpProgramSpec struct {

// XdpProgramStatus defines the observed state of XdpProgram
type XdpProgramStatus struct {
// Conditions houses the global cluster state for the XdpProgram. The explicit
// condition types are defined internally.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
BpfProgramStatusCommon `json:",inline"`
}

// +kubebuilder:object:root=true
Expand Down
Loading
Loading