-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Implement bandwidth limit on egress using tc #2
Comments
@DelusionalOptimist Please suggest if you have any better approach. |
@Revolyssup Have we considered the TC hooking capabilities that libbpfgo provides? Are they not sufficient for the use case? |
@DelusionalOptimist LGTM, I might have missed this. Lets go with this. |
Let's go! 🚀 |
@DelusionalOptimist Just to confirm few things, here is the proposal:
For later (to be carried on in separate issues after tc Egress support. Only being noted here to capture overall direction):
|
@Revolyssup based on your proposed configuration, I can picture it somewhat like below. Let me know if I'm right. rules:
- id: "restrict webserver"
ingress:
- id: "only allow port 443"
sourceIP: '*'
destinationPort: 443
<...>
# future
action: allow
priority: -20
egress:
- id: "block access to github.com"
destIP: '20.207.73.82'
destinationPort: '*'
<...>
# future
priority: 20
- id: "restrict firefox"
egress:
- id: "block access to ads.google.com"
destIP: '142.250.194.206'
destinationPort: '*'
<...>
# future
priority: -20
This sounds good and also pretty close to Kubernetes' NetworkPolicy. I think this way we can use each individual "rule block" to granularly define process level networking. A couple of things worth mentioning:
I think we can extend further to basic things like redirecting packet based on some information and so on but let's think about it later. |
@DelusionalOptimist In first iteration, will we need the interaction between xdp and tc or can they work independently on ingress and egress respectively? |
@Revolyssup My bad. I meant to cite that resource for future reference. I don't think we would need any interaction b/w the two for our current use case. |
@DelusionalOptimist What if we kept it simple and just add a Let me know if this categorization makes sense to you? |
I think I should create a draft PR from here and carry discussion there so we have something concrete to make comments on. |
@DelusionalOptimist Do you suggest we have separate maps for ingress and egress filter_rules? To avoid contention as the rules are evaluated on each entry, we would be evaluating ingress rules on egress packets. |
Quite frankly that was what I was thinking initially but I thought you wanted to keep it close to Network Policy. I'm fine either ways. |
Proposal:
TC(Traffic Control) supports multiple types of filters that can be attached to different classes inside q-disks(RTM). Since neither libbpfgo nor ebpf-go libraries support tc functionality directly due to multiple reasons listed here
We can use a separate library like go-tc to attach ebpf filters on an interface(ingress/egress) to implement bandwidth limiting on any given interface.
If the proposal sounds good, then I would like to create a draft PR on this where we can carry forward the discussion.
Some references
The text was updated successfully, but these errors were encountered: