-
Notifications
You must be signed in to change notification settings - Fork 254
feat: update iptables monitor with ipv6 and bpf map reading capabilities #3948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the azure-iptables-monitor with IPv6 support and BPF map monitoring capabilities. The monitor can now detect unexpected iptables rules in both IPv4 and IPv6 tables, and can track blocked iptables rule attempts via a pinned BPF map.
Key changes:
- Adds IPv6 iptables monitoring with separate allowlist configuration directory
- Implements BPF map reading to track blocked iptables rule attempts and generate events when blocks increase
- Updates the Kubernetes label name to follow Azure conventions
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
iptables_monitor.go | Core implementation adding IPv6 support, BPF map monitoring, and label name update |
iptables_monitor_test.go | Updates test to match new function signature with config path parameter |
go.mod | Adds cilium/ebpf dependency for BPF map functionality |
README.md | Documents new command-line flags and updated label name |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]> Signed-off-by: Alexander <[email protected]>
/azp run Azure Container Networking PR |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the event description, let's add an explanation indicating that eBPF host routing is enabled. The user may not immediately have context on why iptables rules are being blocked. We could also link aka.ms/acnsperformance
azure-iptables-monitor/README.md
Outdated
- The `-events` flag enables Kubernetes event creation for rule violations. Default: `false` | ||
- The `-ipv6` flag enables IPv6 ip6tables monitoring using the IPv6 allowlists. Default: `false` | ||
- The `-checkMap` flag enables checking the pinned bpf map specified in mapPath for increases. Default: `false` | ||
- The `-mapPath` flag species the pinned bpf map path to check. Default: `/block-iptables/iptables_block_event_counter` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can it be /azure-block-iptables/iptables_block_event_counter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default uses the path specified here: https://github.com/Azure/azure-container-networking/blob/master/bpf-prog/azure-block-iptables/pkg/bpfprogram/program.go#L20 . In any case, the bpf map is on the vm and needs to be mounted to the container, and that mount can be at any location on the container. The mount location is specific to the container with the iptables monitor image. The mapPath
is configurable as well if we need to change it later.
5. The program will set the `user-iptables-rules` label to `true` on the specified ciliumnode resource if unexpected rules are found, or `false` if all rules match expected patterns. Proper RBAC is required for patching (patch for ciliumnodes, create for events, get for nodes). | ||
5. The program will set the `kubernetes.azure.com/user-iptables-rules` label to `true` on the specified ciliumnode resource if unexpected rules are found, or `false` if all rules match expected patterns. Proper RBAC is required for patching (patch for ciliumnodes, create for events, get for nodes). | ||
|
||
6. The program will also send out an event if the bpf map value specified increases between checks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also specify how often the program check for increases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The increases are checked based on -interval
, unless you mean you would like a second configurable interval option for checking the map?
- The `-events` flag enables Kubernetes event creation for rule violations. Default: `false` | ||
- The `-ipv6` flag enables IPv6 ip6tables monitoring using the IPv6 allowlists. Default: `false` | ||
- The `-checkMap` flag enables checking the pinned bpf map specified in mapPath for increases. Default: `false` | ||
- The `-mapPath` flag species the pinned bpf map path to check. Default: `/block-iptables/iptables_block_event_counter` | ||
- The program must be in a k8s environment and `NODE_NAME` must be a set environment variable with the current node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why NODE_NAME is required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to create events for the current node the program is running on-- the field needs to be passed in for the program to know about it.
Reason for Change:
Adds two new capabilities to azure-iptables-monitor:
Issue Fixed:
See above
Requirements:
Notes:
Tested on a cilium dualstack cluster