@@ -4,13 +4,14 @@ import (
44 "context"
55 "encoding/binary"
66 "fmt"
7- "github.com/netobserv/network-observability-operator/controllers/constants"
8- "github.com/netobserv/network-observability-operator/pkg/helper"
9- "github.com/sirupsen/logrus"
7+ "k8s.io/utils/ptr"
108
119 flowslatest "github.com/netobserv/network-observability-operator/apis/flowcollector/v1beta2"
10+ "github.com/netobserv/network-observability-operator/controllers/constants"
11+ "github.com/netobserv/network-observability-operator/pkg/helper"
1212
1313 bpfmaniov1alpha1 "github.com/bpfman/bpfman-operator/apis/v1alpha1"
14+ "github.com/sirupsen/logrus"
1415 "k8s.io/apimachinery/pkg/api/errors"
1516 v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1617 "k8s.io/klog"
@@ -23,7 +24,7 @@ const (
2324
2425// bpfmanDetachNetobserv find BpfmanApplication object with all required ebpf hooks and detaches them using bpfman manager
2526func (c * AgentController ) bpfmanDetachNetobserv (ctx context.Context ) error {
26- bpfApp := bpfmaniov1alpha1.BpfApplication {
27+ bpfApp := bpfmaniov1alpha1.ClusterBpfApplication {
2728 ObjectMeta : v1.ObjectMeta {
2829 Name : netobservApp ,
2930 },
@@ -49,7 +50,7 @@ func (c *AgentController) bpfmanDetachNetobserv(ctx context.Context) error {
4950// bpfmanAttachNetobserv Creates BpfmanApplication object with all required ebpf hooks and attaches them using bpfman manager
5051func (c * AgentController ) bpfmanAttachNetobserv (ctx context.Context , fc * flowslatest.FlowCollector ) error {
5152 var err error
52- bpfApp := bpfmaniov1alpha1.BpfApplication {
53+ bpfApp := bpfmaniov1alpha1.ClusterBpfApplication {
5354 ObjectMeta : v1.ObjectMeta {
5455 Name : netobservApp ,
5556 },
@@ -83,9 +84,7 @@ func (c *AgentController) bpfmanAttachNetobserv(ctx context.Context, fc *flowsla
8384 return err
8485}
8586
86- func prepareBpfApplication (bpfApp * bpfmaniov1alpha1.BpfApplication , fc * flowslatest.FlowCollector , netobservBCImage string ) {
87- interfaces := fc .Spec .Agent .EBPF .Interfaces
88-
87+ func prepareBpfApplication (bpfApp * bpfmaniov1alpha1.ClusterBpfApplication , fc * flowslatest.FlowCollector , netobservBCImage string ) {
8988 samplingValue := make ([]byte , 4 )
9089 dnsPortValue := make ([]byte , 2 )
9190 var enableDNSValue , enableRTTValue , enableFLowFilterValue , enableNetworkEvents , traceValue , networkEventsGroupIDValue , enablePktTranslation []byte
@@ -148,113 +147,116 @@ func prepareBpfApplication(bpfApp *bpfmaniov1alpha1.BpfApplication, fc *flowslat
148147 "enable_pkt_translation_tracking" : enablePktTranslation ,
149148 }
150149
151- bpfApp .Spec .BpfAppCommon .ByteCode = bpfmaniov1alpha1.BytecodeSelector {
152- Image : & bpfmaniov1alpha1.BytecodeImage {
150+ bpfApp .Spec .BpfAppCommon .ByteCode = bpfmaniov1alpha1.ByteCodeSelector {
151+ Image : & bpfmaniov1alpha1.ByteCodeImage {
153152 Url : netobservBCImage ,
154153 ImagePullPolicy : bpfmaniov1alpha1 .PullIfNotPresent ,
155154 },
156155 }
157- bpfApp .Spec .Programs = []bpfmaniov1alpha1.BpfApplicationProgram {
156+ bpfApp .Spec .Programs = []bpfmaniov1alpha1.ClBpfApplicationProgram {
158157 {
158+ Name : "tcx_ingress_flow_parse" ,
159159 Type : bpfmaniov1alpha1 .ProgTypeTCX ,
160- TCX : & bpfmaniov1alpha1.TcxProgramInfo {
161- BpfProgramCommon : bpfmaniov1alpha1.BpfProgramCommon {
162- BpfFunctionName : "tcx_ingress_flow_parse" ,
160+ TCX : & bpfmaniov1alpha1.ClTcxProgramInfo {
161+ Links : []bpfmaniov1alpha1.ClTcxAttachInfo {
162+ {
163+ InterfaceSelector : bpfmaniov1alpha1.InterfaceSelector {InterfaceAutoDiscovery : ptr .To (true )},
164+ Direction : bpfmaniov1alpha1 .TCIngress ,
165+ },
163166 },
164- InterfaceSelector : bpfmaniov1alpha1.InterfaceSelector {Interfaces : & interfaces },
165- Direction : "ingress" ,
166167 },
167168 },
168169 {
170+ Name : "tcx_egress_flow_parse" ,
169171 Type : bpfmaniov1alpha1 .ProgTypeTCX ,
170- TCX : & bpfmaniov1alpha1.TcxProgramInfo {
171- BpfProgramCommon : bpfmaniov1alpha1.BpfProgramCommon {
172- BpfFunctionName : "tcx_egress_flow_parse" ,
172+ TCX : & bpfmaniov1alpha1.ClTcxProgramInfo {
173+ Links : []bpfmaniov1alpha1.ClTcxAttachInfo {
174+ {
175+ InterfaceSelector : bpfmaniov1alpha1.InterfaceSelector {InterfaceAutoDiscovery : ptr .To (true )},
176+ Direction : bpfmaniov1alpha1 .TCEgress ,
177+ },
173178 },
174- InterfaceSelector : bpfmaniov1alpha1.InterfaceSelector {Interfaces : & interfaces },
175- Direction : "egress" ,
176179 },
177180 },
178181 }
179182
180183 if helper .IsFlowRTTEnabled (& fc .Spec .Agent .EBPF ) {
181- bpfApp .Spec .Programs = append (bpfApp .Spec .Programs , []bpfmaniov1alpha1.BpfApplicationProgram {
184+ bpfApp .Spec .Programs = append (bpfApp .Spec .Programs , []bpfmaniov1alpha1.ClBpfApplicationProgram {
182185 {
186+ Name : "tcp_rcv_fentry" ,
183187 Type : bpfmaniov1alpha1 .ProgTypeFentry ,
184- Fentry : & bpfmaniov1alpha1.FentryProgramInfo {
185- BpfProgramCommon : bpfmaniov1alpha1.BpfProgramCommon {
186- BpfFunctionName : "tcp_rcv_fentry " ,
188+ FEntry : & bpfmaniov1alpha1.ClFentryProgramInfo {
189+ ClFentryLoadInfo : bpfmaniov1alpha1.ClFentryLoadInfo {
190+ Function : "tcp_rcv_established " ,
187191 },
188- FunctionName : "tcp_rcv_established" ,
189- },
190- },
191- {
192- Type : bpfmaniov1alpha1 .ProgTypeKprobe ,
193- Kprobe : & bpfmaniov1alpha1.KprobeProgramInfo {
194- BpfProgramCommon : bpfmaniov1alpha1.BpfProgramCommon {
195- BpfFunctionName : "tcp_rcv_kprobe" ,
192+ Links : []bpfmaniov1alpha1.ClFentryAttachInfo {
193+ {
194+ Mode : bpfmaniov1alpha1 .Attach ,
195+ },
196196 },
197- FunctionName : "tcp_rcv_established" ,
198- RetProbe : false ,
199197 },
200198 },
201199 }... )
202200 }
203201
204202 if helper .IsNetworkEventsEnabled (& fc .Spec .Agent .EBPF ) {
205- bpfApp .Spec .Programs = append (bpfApp .Spec .Programs , []bpfmaniov1alpha1.BpfApplicationProgram {
203+ bpfApp .Spec .Programs = append (bpfApp .Spec .Programs , []bpfmaniov1alpha1.ClBpfApplicationProgram {
206204 {
205+ Name : "rh_network_events_monitoring" ,
207206 Type : bpfmaniov1alpha1 .ProgTypeKprobe ,
208- Kprobe : & bpfmaniov1alpha1.KprobeProgramInfo {
209- BpfProgramCommon : bpfmaniov1alpha1.BpfProgramCommon {
210- BpfFunctionName : "rh_network_events_monitoring" ,
207+ KProbe : & bpfmaniov1alpha1.ClKprobeProgramInfo {
208+ Links : []bpfmaniov1alpha1.ClKprobeAttachInfo {
209+ {
210+ Function : "rh_psample_sample_packet" ,
211+ },
211212 },
212- FunctionName : "rh_psample_sample_packet" ,
213- RetProbe : false ,
214213 },
215214 },
216215 }... )
217216 }
218217
219218 if helper .IsPktDropEnabled (& fc .Spec .Agent .EBPF ) {
220- bpfApp .Spec .Programs = append (bpfApp .Spec .Programs , []bpfmaniov1alpha1.BpfApplicationProgram {
219+ bpfApp .Spec .Programs = append (bpfApp .Spec .Programs , []bpfmaniov1alpha1.ClBpfApplicationProgram {
221220 {
221+ Name : "kfree_skb" ,
222222 Type : bpfmaniov1alpha1 .ProgTypeTracepoint ,
223- Tracepoint : & bpfmaniov1alpha1.TracepointProgramInfo {
224- BpfProgramCommon : bpfmaniov1alpha1.BpfProgramCommon {
225- BpfFunctionName : "kfree_skb" ,
223+ TracePoint : & bpfmaniov1alpha1.ClTracepointProgramInfo {
224+ Links : []bpfmaniov1alpha1.ClTracepointAttachInfo {
225+ {
226+ Name : "skb/kfree_skb" ,
227+ },
226228 },
227- Names : []string {"skb/kfree_skb" },
228229 },
229230 },
230231 }... )
231232 }
232233
233234 if helper .IsPacketTranslationEnabled (& fc .Spec .Agent .EBPF ) {
234- bpfApp .Spec .Programs = append (bpfApp .Spec .Programs , []bpfmaniov1alpha1.BpfApplicationProgram {
235+ bpfApp .Spec .Programs = append (bpfApp .Spec .Programs , []bpfmaniov1alpha1.ClBpfApplicationProgram {
235236 {
237+ Name : "track_nat_manip_pkt" ,
236238 Type : bpfmaniov1alpha1 .ProgTypeKprobe ,
237- Kprobe : & bpfmaniov1alpha1.KprobeProgramInfo {
238- BpfProgramCommon : bpfmaniov1alpha1.BpfProgramCommon {
239- BpfFunctionName : "track_nat_manip_pkt" ,
239+ KProbe : & bpfmaniov1alpha1.ClKprobeProgramInfo {
240+ Links : []bpfmaniov1alpha1.ClKprobeAttachInfo {
241+ {
242+ Function : "nf_nat_manip_pkt" ,
243+ },
240244 },
241- FunctionName : "nf_nat_manip_pkt" ,
242- RetProbe : false ,
243245 },
244246 },
245247 }... )
246248 }
247249}
248250
249- func (c * AgentController ) deleteBpfApplication (ctx context.Context , bpfApp * bpfmaniov1alpha1.BpfApplication ) error {
251+ func (c * AgentController ) deleteBpfApplication (ctx context.Context , bpfApp * bpfmaniov1alpha1.ClusterBpfApplication ) error {
250252 klog .Info ("Deleting BpfApplication Object" )
251253 return c .Delete (ctx , bpfApp )
252254}
253255
254- func (c * AgentController ) createBpfApplication (ctx context.Context , bpfApp * bpfmaniov1alpha1.BpfApplication ) error {
256+ func (c * AgentController ) createBpfApplication (ctx context.Context , bpfApp * bpfmaniov1alpha1.ClusterBpfApplication ) error {
255257 return c .CreateOwned (ctx , bpfApp )
256258}
257259
258- func (c * AgentController ) updateBpfApplication (ctx context.Context , bpfApp * bpfmaniov1alpha1.BpfApplication ) error {
260+ func (c * AgentController ) updateBpfApplication (ctx context.Context , bpfApp * bpfmaniov1alpha1.ClusterBpfApplication ) error {
259261 return c .UpdateOwned (ctx , bpfApp , bpfApp )
260262}
0 commit comments