Skip to content

Commit 47b2801

Browse files
authored
Merge pull request #408 from msherif1234/intf-discovery
Add interfaces discovery to bpf agent process
2 parents 34be33b + 41072f2 commit 47b2801

File tree

145 files changed

+22866
-62
lines changed

Some content is hidden

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

145 files changed

+22866
-62
lines changed

apis/v1alpha1/cluster_tc_program_types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type ClTcAttachInfo struct {
3737
// program. If Containers is not specified, the BPF program will be attached
3838
// in the root network namespace.
3939
// +optional
40-
Containers *ClContainerSelector `json:"containers"`
40+
Containers *ClContainerSelector `json:"containers,omitempty"`
4141

4242
// direction specifies the direction of traffic the tc program should
4343
// attach to for a given network device.
@@ -49,13 +49,14 @@ type ClTcAttachInfo struct {
4949
// from 0 to 1000 where lower values have higher precedence.
5050
// +kubebuilder:validation:Minimum=0
5151
// +kubebuilder:validation:Maximum=1000
52-
Priority int32 `json:"priority"`
52+
// +optional
53+
Priority int32 `json:"priority,omitempty"`
5354

5455
// proceedOn allows the user to call other tc programs in chain on this exit code.
5556
// Multiple values are supported by repeating the parameter.
5657
// +optional
5758
// +kubebuilder:default:={Pipe,DispatcherReturn}
58-
ProceedOn []TcProceedOnValue `json:"proceedOn"`
59+
ProceedOn []TcProceedOnValue `json:"proceedOn,omitempty"`
5960
}
6061

6162
type ClTcProgramInfoState struct {

apis/v1alpha1/cluster_tcx_program_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type ClTcxAttachInfo struct {
3434
// program. If Containers is not specified, the BPF program will be attached
3535
// in the root network namespace.
3636
// +optional
37-
Containers *ClContainerSelector `json:"containers"`
37+
Containers *ClContainerSelector `json:"containers,omitempty"`
3838

3939
// direction specifies the direction of traffic the tcx program should
4040
// attach to for a given network device.
@@ -46,7 +46,8 @@ type ClTcxAttachInfo struct {
4646
// from 0 to 1000 where lower values have higher precedence.
4747
// +kubebuilder:validation:Minimum=0
4848
// +kubebuilder:validation:Maximum=1000
49-
Priority int32 `json:"priority"`
49+
// +optional
50+
Priority int32 `json:"priority,omitempty"`
5051
}
5152

5253
type ClTcxProgramInfoState struct {

apis/v1alpha1/cluster_xdp_program_types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,21 @@ type ClXdpAttachInfo struct {
3737
// program. If Containers is not specified, the BPF program will be attached
3838
// in the root network namespace.
3939
// +optional
40-
Containers *ClContainerSelector `json:"containers"`
40+
Containers *ClContainerSelector `json:"containers,omitempty"`
4141

4242
// priority specifies the priority of the bpf program in relation to
4343
// other programs of the same type with the same attach point. It is a value
4444
// from 0 to 1000 where lower values have higher precedence.
4545
// +kubebuilder:validation:Minimum=0
4646
// +kubebuilder:validation:Maximum=1000
47-
Priority int32 `json:"priority"`
47+
// +optional
48+
Priority int32 `json:"priority,omitempty"`
4849

4950
// proceedOn allows the user to call other xdp programs in chain on this exit code.
5051
// Multiple values are supported by repeating the parameter.
5152
// +optional
5253
// +kubebuilder:default:={Pass,DispatcherReturn}
53-
ProceedOn []XdpProceedOnValue `json:"proceedOn"`
54+
ProceedOn []XdpProceedOnValue `json:"proceedOn,omitempty"`
5455
}
5556

5657
type ClXdpProgramInfoState struct {

apis/v1alpha1/shared_types.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,32 @@ import (
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
)
2323

24+
type InterfaceDiscovery struct {
25+
// interfaceAutoDiscovery when enabled, the agent process monitors the creation and deletion of interfaces,
26+
// automatically attaching eBPF hooks to newly discovered interfaces in both directions.
27+
//+kubebuilder:default:=false
28+
// +optional
29+
InterfaceAutoDiscovery *bool `json:"interfaceAutoDiscovery,omitempty"`
30+
31+
// excludeInterfaces contains the interface names that are excluded from interface discovery
32+
// it is matched as a case-sensitive string.
33+
//+kubebuilder:default:={"lo"}
34+
//+optional
35+
ExcludeInterfaces []string `json:"excludeInterfaces,omitempty"`
36+
}
37+
2438
// InterfaceSelector defines interface to attach to.
2539
// +kubebuilder:validation:MaxProperties=1
2640
// +kubebuilder:validation:MinProperties=1
2741
type InterfaceSelector struct {
42+
// discoveryConfig allow configuring interface discovery functionality,
43+
// +optional
44+
InterfacesDiscoveryConfig *InterfaceDiscovery `json:"interfacesDiscoveryConfig,omitempty"`
45+
2846
// interfaces refers to a list of network interfaces to attach the BPF
2947
// program to.
3048
// +optional
31-
Interfaces *[]string `json:"interfaces,omitempty"`
49+
Interfaces []string `json:"interfaces,omitempty"`
3250

3351
// primaryNodeInterface to attach BPF program to the primary interface on the node. Only 'true' accepted.
3452
// +optional

apis/v1alpha1/tc_program_types.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ type TcAttachInfo struct {
3232

3333
// containers identify the set of containers in which to attach the eBPF
3434
// program.
35-
Containers ContainerSelector `json:"containers"`
35+
// +optional
36+
Containers ContainerSelector `json:"containers,omitempty"`
3637

3738
// direction specifies the direction of traffic the tc program should
3839
// attach to for a given network device.
@@ -44,13 +45,14 @@ type TcAttachInfo struct {
4445
// from 0 to 1000 where lower values have higher precedence.
4546
// +kubebuilder:validation:Minimum=0
4647
// +kubebuilder:validation:Maximum=1000
47-
Priority int32 `json:"priority"`
48+
// +optional
49+
Priority int32 `json:"priority,omitempty"`
4850

4951
// proceedOn allows the user to call other tc programs in chain on this exit code.
5052
// Multiple values are supported by repeating the parameter.
5153
// +optional
5254
// +kubebuilder:default:={Pipe,DispatcherReturn}
53-
ProceedOn []TcProceedOnValue `json:"proceedOn"`
55+
ProceedOn []TcProceedOnValue `json:"proceedOn,omitempty"`
5456
}
5557

5658
type TcProgramInfoState struct {

apis/v1alpha1/tcx_program_types.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,24 @@ type TcxAttachInfoState struct {
6262
AttachInfoStateCommon `json:",inline"`
6363

6464
// interfaceName is the Interface name to attach the tc program to.
65-
InterfaceName string `json:"interfaceName"`
65+
// +optional
66+
InterfaceName string `json:"interfaceName,omitempty"`
6667

6768
// containerPid is the container pid to attach the tcx program in.
68-
ContainerPid int32 `json:"containerPid"`
69+
// +optional
70+
ContainerPid int32 `json:"containerPid,omitempty"`
6971

7072
// direction specifies the direction of traffic the tcx program should
7173
// attach to for a given network device.
7274
// +kubebuilder:validation:Enum=Ingress;Egress
73-
Direction TCDirectionType `json:"direction"`
75+
// +optional
76+
Direction TCDirectionType `json:"direction,omitempty"`
7477

7578
// priority specifies the priority of the tcx program in relation to
7679
// other programs of the same type with the same attach point. It is a value
7780
// from 0 to 1000 where lower values have higher precedence.
7881
// +kubebuilder:validation:Minimum=0
7982
// +kubebuilder:validation:Maximum=1000
80-
Priority int32 `json:"priority"`
83+
// +optional
84+
Priority int32 `json:"priority,omitempty"`
8185
}

apis/v1alpha1/xdp_program_types.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,22 @@ type XdpAttachInfo struct {
3232

3333
// containers identify the set of containers in which to attach the eBPF
3434
// program.
35-
Containers ContainerSelector `json:"containers"`
35+
// +optional
36+
Containers ContainerSelector `json:"containers,omitempty"`
3637

3738
// priority specifies the priority of the bpf program in relation to
3839
// other programs of the same type with the same attach point. It is a value
3940
// from 0 to 1000 where lower values have higher precedence.
4041
// +kubebuilder:validation:Minimum=0
4142
// +kubebuilder:validation:Maximum=1000
42-
Priority int32 `json:"priority"`
43+
// +optional
44+
Priority int32 `json:"priority,omitempty"`
4345

4446
// proceedOn allows the user to call other xdp programs in chain on this exit code.
4547
// Multiple values are supported by repeating the parameter.
4648
// +optional
4749
// +kubebuilder:default:={Pass,DispatcherReturn}
48-
ProceedOn []XdpProceedOnValue `json:"proceedOn"`
50+
ProceedOn []XdpProceedOnValue `json:"proceedOn,omitempty"`
4951
}
5052

5153
type XdpProgramInfoState struct {

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 32 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/bpfman-operator.clusterserviceversion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ metadata:
820820
capabilities: Basic Install
821821
categories: OpenShift Optional
822822
containerImage: quay.io/bpfman/bpfman-operator:latest
823-
createdAt: "2025-03-21T19:22:04Z"
823+
createdAt: "2025-03-25T15:29:54Z"
824824
description: The bpfman Operator is designed to manage eBPF programs for applications.
825825
features.operators.openshift.io/cnf: "false"
826826
features.operators.openshift.io/cni: "false"

bundle/manifests/bpfman.io_bpfapplications.yaml

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,26 @@ spec:
315315
items:
316316
type: string
317317
type: array
318+
interfacesDiscoveryConfig:
319+
description: discoveryConfig allow configuring
320+
interface discovery functionality,
321+
properties:
322+
excludeInterfaces:
323+
default:
324+
- lo
325+
description: |-
326+
excludeInterfaces contains the interface names that are excluded from interface discovery
327+
it is matched as a case-sensitive string.
328+
items:
329+
type: string
330+
type: array
331+
interfaceAutoDiscovery:
332+
default: false
333+
description: |-
334+
interfaceAutoDiscovery when enabled, the agent process monitors the creation and deletion of interfaces,
335+
automatically attaching eBPF hooks to newly discovered interfaces in both directions.
336+
type: boolean
337+
type: object
318338
primaryNodeInterface:
319339
description: primaryNodeInterface to attach BPF
320340
program to the primary interface on the node.
@@ -353,10 +373,8 @@ spec:
353373
type: string
354374
type: array
355375
required:
356-
- containers
357376
- direction
358377
- interfaceSelector
359-
- priority
360378
type: object
361379
type: array
362380
type: object
@@ -456,6 +474,26 @@ spec:
456474
items:
457475
type: string
458476
type: array
477+
interfacesDiscoveryConfig:
478+
description: discoveryConfig allow configuring
479+
interface discovery functionality,
480+
properties:
481+
excludeInterfaces:
482+
default:
483+
- lo
484+
description: |-
485+
excludeInterfaces contains the interface names that are excluded from interface discovery
486+
it is matched as a case-sensitive string.
487+
items:
488+
type: string
489+
type: array
490+
interfaceAutoDiscovery:
491+
default: false
492+
description: |-
493+
interfaceAutoDiscovery when enabled, the agent process monitors the creation and deletion of interfaces,
494+
automatically attaching eBPF hooks to newly discovered interfaces in both directions.
495+
type: boolean
496+
type: object
459497
primaryNodeInterface:
460498
description: primaryNodeInterface to attach BPF
461499
program to the primary interface on the node.
@@ -782,6 +820,26 @@ spec:
782820
items:
783821
type: string
784822
type: array
823+
interfacesDiscoveryConfig:
824+
description: discoveryConfig allow configuring
825+
interface discovery functionality,
826+
properties:
827+
excludeInterfaces:
828+
default:
829+
- lo
830+
description: |-
831+
excludeInterfaces contains the interface names that are excluded from interface discovery
832+
it is matched as a case-sensitive string.
833+
items:
834+
type: string
835+
type: array
836+
interfaceAutoDiscovery:
837+
default: false
838+
description: |-
839+
interfaceAutoDiscovery when enabled, the agent process monitors the creation and deletion of interfaces,
840+
automatically attaching eBPF hooks to newly discovered interfaces in both directions.
841+
type: boolean
842+
type: object
785843
primaryNodeInterface:
786844
description: primaryNodeInterface to attach BPF
787845
program to the primary interface on the node.
@@ -815,9 +873,7 @@ spec:
815873
type: string
816874
type: array
817875
required:
818-
- containers
819876
- interfaceSelector
820-
- priority
821877
type: object
822878
type: array
823879
type: object

0 commit comments

Comments
 (0)