Skip to content

Commit

Permalink
Add packet drop filtering API
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamed Mahmoud <[email protected]>
  • Loading branch information
msherif1234 committed Oct 1, 2024
1 parent 0de6d49 commit 7edaf2c
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apis/flowcollector/v1beta1/flowcollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ type EBPFFlowFilter struct {
// ICMPCode defines the ICMP code to filter flows by.
// +optional
ICMPCode *int `json:"icmpCode,omitempty"`

// `pktDrops`, to filter flows with packet drops
// +optional
PktDrops *bool `json:"pktDrops,omitempty"`
}

// `FlowCollectorEBPF` defines a FlowCollector that uses eBPF to collect the flows information
Expand Down
2 changes: 2 additions & 0 deletions apis/flowcollector/v1beta1/zz_generated.conversion.go

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

5 changes: 5 additions & 0 deletions apis/flowcollector/v1beta1/zz_generated.deepcopy.go

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

4 changes: 4 additions & 0 deletions apis/flowcollector/v1beta2/flowcollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ type EBPFFlowFilter struct {
// `icmpType`, for ICMP traffic, defines the ICMP type to filter flows by.
// +optional
ICMPType *int `json:"icmpType,omitempty"`

// `pktDrops`, to filter flows with packet drops
// +optional
PktDrops *bool `json:"pktDrops,omitempty"`
}

// `FlowCollectorEBPF` defines a FlowCollector that uses eBPF to collect the flows information
Expand Down
5 changes: 5 additions & 0 deletions apis/flowcollector/v1beta2/zz_generated.deepcopy.go

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

8 changes: 8 additions & 0 deletions bundle/manifests/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ spec:
PeerIP defines the IP address to filter flows by.
Example: 10.10.10.10
type: string
pktDrops:
description: '`pktDrops`, to filter flows with packet
drops'
type: boolean
ports:
anyOf:
- type: integer
Expand Down Expand Up @@ -3792,6 +3796,10 @@ spec:
`peerIP` defines the IP address to filter flows by.
Example: `10.10.10.10`.
type: string
pktDrops:
description: '`pktDrops`, to filter flows with packet
drops'
type: boolean
ports:
anyOf:
- type: integer
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ spec:
PeerIP defines the IP address to filter flows by.
Example: 10.10.10.10
type: string
pktDrops:
description: '`pktDrops`, to filter flows with packet drops'
type: boolean
ports:
anyOf:
- type: integer
Expand Down Expand Up @@ -3499,6 +3502,9 @@ spec:
`peerIP` defines the IP address to filter flows by.
Example: `10.10.10.10`.
type: string
pktDrops:
description: '`pktDrops`, to filter flows with packet drops'
type: boolean
ports:
anyOf:
- type: integer
Expand Down
4 changes: 4 additions & 0 deletions controllers/ebpf/agent_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const (
envFilterICMPCode = "FILTER_ICMP_CODE"
envFilterPeerIPAddress = "FILTER_PEER_IP"
envFilterTCPFlags = "FILTER_TCP_FLAGS"
envFilterPktDrops = "FILTER_DROPS"
envListSeparator = ","
)

Expand Down Expand Up @@ -573,6 +574,9 @@ func (c *AgentController) configureFlowFilter(filter *flowslatest.EBPFFlowFilter
})
}

if filter.PktDrops != nil && *filter.PktDrops {
config = append(config, corev1.EnvVar{Name: envFilterPktDrops, Value: "true"})
}
return config
}

Expand Down
14 changes: 14 additions & 0 deletions docs/FlowCollector.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,13 @@ To filter two ports, use a "port1,port2" in string format. For example, `ports:
Example: 10.10.10.10<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>pktDrops</b></td>
<td>boolean</td>
<td>
`pktDrops`, to filter flows with packet drops<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>ports</b></td>
<td>int or string</td>
Expand Down Expand Up @@ -7911,6 +7918,13 @@ To filter two ports, use a "port1,port2" in string format. For example, `ports:
Example: `10.10.10.10`.<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>pktDrops</b></td>
<td>boolean</td>
<td>
`pktDrops`, to filter flows with packet drops<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>ports</b></td>
<td>int or string</td>
Expand Down

0 comments on commit 7edaf2c

Please sign in to comment.