You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NETOBSERV-1617: reuse flow filter capability with pcap feature (#359)
* NETOBSERV-1617: reuse flow filter capability with pcap feature
rename all flow filters to just filter to allow reuse the same configs
modify pca to use filter config
update userspace, examples and doc
Signed-off-by: Mohamed Mahmoud <[email protected]>
* Allow sampling configs to be applied for PCA
Signed-off-by: Mohamed Mahmoud <[email protected]>
---------
Signed-off-by: Mohamed Mahmoud <[email protected]>
logrus.Info("[PCA] NetObserv eBPF Agent instantiated without filters to identify packets. All packets will be captured. This might cause reduced performance.")
Flow rule-base filtering is a method to control the flow of packets cached in the eBPF flows table based on certain configuration
5
+
Rule-base filtering is a method to control the flow of packets cached in the eBPF flows table based on certain configuration
6
6
7
-
## Flow filter rule configuration
7
+
## Filter rule configuration
8
8
9
-
The Flow filter rule consists of two parts mandatory and optional parameters.
9
+
The filter rule consists of two parts mandatory and optional parameters.
10
10
11
11
### Mandatory parameters
12
12
13
-
-`FLOW_FILTER_IP_CIDR` - IP address and CIDR mask for the flow filter rule, supports IPv4 and IPv6 address format.
13
+
-`FILTER_IP_CIDR` - IP address and CIDR mask for the flow filter rule, supports IPv4 and IPv6 address format.
14
14
If wanted to match against any IP, user can use `0.0.0.0/0` or `::/0` for IPv4 and IPv6 respectively.
15
-
-`FLOW_FILTER_ACTION` - Action to be taken for the flow filter rule. Possible values are `Accept` and `Reject`.
16
-
- For the matching rule with `Accept` action this flow will be allowed to be cached in eBPF table, with updated global metric `FlowFilterAcceptCounter`.
17
-
- For the matching rule with `Reject` action this flow will not be cached in eBPF table, with updated global metric `FlowFilterRejectCounter`.
15
+
-`FILTER_ACTION` - Action to be taken for the flow filter rule. Possible values are `Accept` and `Reject`.
16
+
- For the matching rule with `Accept` action this flow will be allowed to be cached in eBPF table, with updated global metric `FilterAcceptCounter`.
17
+
- For the matching rule with `Reject` action this flow will not be cached in eBPF table, with updated global metric `FilterRejectCounter`.
18
18
- If the rule is not matched, based on the configured action if its `Accept` the flow will not be cached in eBPF table,
19
-
if the action is `Reject` then the flow will be cached in the eBPF table and a global metric `FlowFilterNoMatchCounter` will be updated.
19
+
if the action is `Reject` then the flow will be cached in the eBPF table and a global metric `FilterNoMatchCounter` will be updated.
20
20
21
21
### Optional parameters
22
22
23
-
-`FLOW_FILTER_DIRECTION` - Direction of the flow filter rule. Possible values are `Ingress` and `Egress`.
24
-
-`FLOW_FILTER_PROTOCOL` - Protocol of the flow filter rule. Possible values are `TCP`, `UDP`, `SCTP`, `ICMP`, `ICMPv6`.
25
-
-`FLOW_FILTER_SOURCE_PORT` - Single Source port of the flow filter rule.
26
-
-`FLOW_FILTER_SOURCE_PORT_RANGE` - Source port range of the flow filter rule. using "80-100" format.
27
-
-`FLOW_FILTER_DESTINATION_PORT` - Single Destination port of the flow filter rule.
28
-
-`FLOW_FILTER_DESTINATION_PORT_RANGE` - Destination port range of the flow filter rule. using "80-100" format.
29
-
-`FLOW_FILTER_PORT` - Single L4 port of the flow filter rule, can be either source or destination port.
30
-
-`FLOW_FILTER_PORT_RANGE` - L4 port range of the flow filter rule. using "80-100" format can be either source or destination ports range.
31
-
-`FLOW_FILTER_ICMP_TYPE` - ICMP type of the flow filter rule.
32
-
-`FLOW_FILTER_ICMP_CODE` - ICMP code of the flow filter rule.
33
-
-`FLOW_FILTER_PEER_IP` - Specific Peer IP address of the flow filter rule.
23
+
-`FILTER_DIRECTION` - Direction of the flow filter rule. Possible values are `Ingress` and `Egress`.
24
+
-`FILTER_PROTOCOL` - Protocol of the flow filter rule. Possible values are `TCP`, `UDP`, `SCTP`, `ICMP`, `ICMPv6`.
25
+
-`FILTER_SOURCE_PORT` - Single Source port of the flow filter rule.
26
+
-`FILTER_SOURCE_PORT_RANGE` - Source port range of the flow filter rule. using "80-100" format.
27
+
-`FILTER_DESTINATION_PORT` - Single Destination port of the flow filter rule.
28
+
-`FILTER_DESTINATION_PORT_RANGE` - Destination port range of the flow filter rule. using "80-100" format.
29
+
-`FILTER_PORT` - Single L4 port of the flow filter rule, can be either source or destination port.
30
+
-`FILTER_PORT_RANGE` - L4 port range of the flow filter rule. using "80-100" format can be either source or destination ports range.
31
+
-`FILTER_ICMP_TYPE` - ICMP type of the flow filter rule.
32
+
-`FILTER_ICMP_CODE` - ICMP code of the flow filter rule.
33
+
-`FILTER_PEER_IP` - Specific Peer IP address of the flow filter rule.
34
34
35
35
Note:
36
-
- for L4 ports configuration you can use either single port config options or the range but not both.
37
-
- use either specific src and/or dst ports or the generic port config that works for both direction.
36
+
- for L4 ports configuration, you can use either single port config options or the range but not both.
37
+
- use either specific src and/or dst ports or the generic port config that works for both directions.
38
38
39
39
## How does Flow Filtering work
40
40
41
-
### Flow Filter and CIDR Matching
41
+
### Filter and CIDR Matching
42
42
43
43
The flow filter examines incoming or outgoing packets and attempts to match the source IP address or the destination IP address
44
-
of each packet against a CIDR range specified in the `FLOW_FILTER_IP_CIDR` parameter.
44
+
of each packet against a CIDR range specified in the `FILTER_IP_CIDR` parameter.
45
45
If the packet's source or destination IP address falls within the specified CIDR range, the filter takes action based on the configured rules.
46
46
This action could involve allowing the packet to be cached in an eBPF flow table or blocking it.
47
47
48
-
### Matching Specific Endpoints with `FLOW_FILTER_PEER_IP`
48
+
### Matching Specific Endpoints with `FILTER_PEER_IP`
49
49
50
-
The `FLOW_FILTER_PEER_IP` parameter specifies the IP address of a specific endpoint.
50
+
The `FILTER_PEER_IP` parameter specifies the IP address of a specific endpoint.
51
51
Depending on whether the traffic is ingress (incoming) or egress (outgoing), this IP address is used to further refine
52
52
the filtering process:
53
-
- In ingress traffic filtering, the `FLOW_FILTER_PEER_IP` is used to match against the destination IP address of the packet.
53
+
- In ingress traffic filtering, the `FILTER_PEER_IP` is used to match against the destination IP address of the packet.
54
54
After the initial CIDR matching, the filter then narrows down the scope to packets destined for a specific endpoint
55
55
specified by `FLOW_FILTER_PEER_IP`.
56
-
- In egress traffic filtering, the `FLOW_FILTER_PEER_IP` is used to match against the source IP address of the packet.
56
+
- In egress traffic filtering, the `FILTER_PEER_IP` is used to match against the source IP address of the packet.
57
57
After the initial CIDR matching, the filter narrows down the scope to packets originating from a specific endpoint
58
-
specified by `FLOW_FILTER_PEER_IP`.
58
+
specified by `FILTER_PEER_IP`.
59
59
60
-
### How to finetune the flow filter rule configuration?
60
+
### How to fine-tune the flow filter rule configuration?
61
61
62
62
We have many configuration options available for the flow filter rule configuration, but we can use them in combination to achieve the desired
63
-
flow filter rule configuration. Let's use some examples to understand how to finetune the flow filter rule configuration.
63
+
flow filter rule configuration. Let's use some examples to understand how to fine-tune the flow filter rule configuration.
64
64
65
65
#### Use-case 1:
66
66
67
67
Filter k8s service traffic to specific POD IP endpoint.
68
-
For example if we wanted to filter in incoming k8s service traffic coming from source `172.210.150.100` for `SCTP` protocol,
69
-
on specific dport range 80-100, and targeting specific POD IP endpoint at `10.10.10.10` we can use the following configuration:
68
+
For example, if we wanted to filter in incoming k8s service traffic coming from source `172.210.150.100` for `SCTP` protocol,
69
+
on specific dport range 80–100, and targeting specific POD IP endpoint at `10.10.10.10` we can use the following configuration:
70
70
71
71
```shell
72
-
FLOW_FILTER_IP_CIDR=172.210.150.1/24
73
-
FLOW_FILTER_ACTION=Accept
74
-
FLOW_FILTER_PROTOCOL=SCTP
75
-
FLOW_FILTER_DIRECTION=Ingress
76
-
FLOW_FILTER_DESTINATION_PORT_RANGE=80-100
77
-
FLOW_FILTER_PEER_IP=10.10.10.10
72
+
FILTER_IP_CIDR=172.210.150.1/24
73
+
FILTER_ACTION=Accept
74
+
FILTER_PROTOCOL=SCTP
75
+
FILTER_DIRECTION=Ingress
76
+
FILTER_DESTINATION_PORT_RANGE=80-100
77
+
FILTER_PEER_IP=10.10.10.10
78
78
```
79
79
80
80
#### Use-case 2:
@@ -83,12 +83,12 @@ Users wanted to see flows after EgressIP feature is configured with EgressIP `19
83
83
to any cluster's outside addresses (destinations is unknown or don't care), so they can use the following configuration:
84
84
85
85
```shell
86
-
FLOW_FILTER_IP_CIDR=0.0.0.0/0
87
-
FLOW_FILTER_ACTION=Accept
88
-
FLOW_FILTER_PROTOCOL=TCP
89
-
FLOW_FILTER_DIRECTION=Egress
90
-
FLOW_FILTER_SOURCE_PORT=100
91
-
FLOW_FILTER_PEER_IP=192.168.127.12
86
+
FILTER_IP_CIDR=0.0.0.0/0
87
+
FILTER_ACTION=Accept
88
+
FILTER_PROTOCOL=TCP
89
+
FILTER_DIRECTION=Egress
90
+
FILTER_SOURCE_PORT=100
91
+
FILTER_PEER_IP=192.168.127.12
92
92
```
93
93
94
94
#### Use-case 3:
@@ -97,22 +97,22 @@ OpenShift ovn kubernetes CNI uses `169.254.169.1-4` as masquerade addresses when
97
97
I am not interested in capturing any those packets, so I can use the following configuration:
98
98
99
99
```shell
100
-
FLOW_FILTER_IP_CIDR=169.254.169.1/24
101
-
FLOW_FILTER_ACTION=Reject
102
-
FLOW_FILTER_DIRECTION=Ingress
100
+
FILTER_IP_CIDR=169.254.169.1/24
101
+
FILTER_ACTION=Reject
102
+
FILTER_DIRECTION=Ingress
103
103
```
104
104
105
105
#### Use-case 4:
106
106
107
-
We have case where ping traffic is going between PODA `1.1.1.10` to PODB in different node `1.2.1.10` for that we can use the following configuration:
107
+
We have a case where ping traffic is going between PODA `1.1.1.10` to PODB in different node `1.2.1.10` for that we can use the following configuration:
108
108
109
109
```shell
110
-
FLOW_FILTER_IP_CIDR=1.1.1.10/32
111
-
FLOW_FILTER_ACTION=Accept
112
-
FLOW_FILTER_DIRECTION=Ingress
113
-
FLOW_FILTER_PROTOCOL=ICMP
114
-
FLOW_FILTER_PEER_IP=1.2.1.10
115
-
FLOW_FILTER_ICMP_TYPE=8
110
+
FILTER_IP_CIDR=1.1.1.10/32
111
+
FILTER_ACTION=Accept
112
+
FILTER_DIRECTION=Ingress
113
+
FILTER_PROTOCOL=ICMP
114
+
FILTER_PEER_IP=1.2.1.10
115
+
FILTER_ICMP_TYPE=8
116
116
```
117
117
118
118
#### Use-case 5:
@@ -121,9 +121,9 @@ We wanted to filter in `curl` request and response for TCP flow going from PODA
0 commit comments