Skip to content

Commit 547a146

Browse files
authored
Add peerCIDR flow filtering support (#147)
Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
1 parent 4174600 commit 547a146

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

res/flow-capture.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ spec:
5353
"destination_port": 0, "port": 0, "source_port_range": "",
5454
"source_ports": "", "destination_port_range": "",
5555
"destination_ports": "", "port_range": "", "ports": "",
56-
"icmp_type": 0, "icmp_code": 0, "peer_ip": "", "action": "Accept",
56+
"icmp_type": 0, "icmp_code": 0, "peer_ip": "", "peer_cidr": "", action": "Accept",
5757
"tcp_flags": "", "drops": false }
5858
]
5959
- name: EXPORT

res/packet-capture.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ spec:
3939
"destination_port": 0, "port": 0, "source_port_range": "",
4040
"source_ports": "", "destination_port_range": "",
4141
"destination_ports": "", "port_range": "", "ports": "",
42-
"icmp_type": 0, "icmp_code": 0, "peer_ip": "", "action": "Accept",
42+
"icmp_type": 0, "icmp_code": 0, "peer_ip": "", "peer_cidr": "", "action": "Accept",
4343
"tcp_flags": "", "drops": false }
4444
]
4545
- name: EXPORT

scripts/functions.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ function filters_usage {
372372
echo " --icmp_type: filter ICMP type (default: n/a)"
373373
echo " --icmp_code: filter ICMP code (default: n/a)"
374374
echo " --peer_ip: filter peer IP (default: n/a)"
375+
echo " --peer_cidr: filter peer CIDR (default: n/a)"
375376
echo " --drops: filter flows with only dropped packets (default: false)"
376377
echo " --regexes: filter flows using regex (default: n/a)"
377378
}
@@ -516,6 +517,9 @@ function edit_manifest() {
516517
"filter_peer_ip")
517518
"$YQ_BIN" e --inplace " .spec.template.spec.containers[0].env[] |= select(.name == \"FLOW_FILTER_RULES\").value |=(fromjson | map(.peer_ip = \"$2\")| tostring)" "$3"
518519
;;
520+
"filter_peer_cidr")
521+
"$YQ_BIN" e --inplace " .spec.template.spec.containers[0].env[] |= select(.name == \"FLOW_FILTER_RULES\").value |=(fromjson | map(.peer_cidr = \"$2\")| tostring)" "$3"
522+
;;
519523
"filter_action")
520524
"$YQ_BIN" e --inplace " .spec.template.spec.containers[0].env[] |= select(.name == \"FLOW_FILTER_RULES\").value |=(fromjson | map(.action = \"$2\")| tostring)" "$3"
521525
;;
@@ -730,6 +734,9 @@ function check_args_and_apply() {
730734
--peer_ip) # Peer IP
731735
edit_manifest "filter_peer_ip" "$value" "$2"
732736
;;
737+
--peer_cidr) # Peer CIDR
738+
edit_manifest "filter_peer_cidr" "$value" "$2"
739+
;;
733740
--action) # Filter action
734741
if [[ "$value" == "Accept" || "$value" == "Reject" ]]; then
735742
edit_manifest "filter_action" "$value" "$2"

0 commit comments

Comments
 (0)