-
Notifications
You must be signed in to change notification settings - Fork 706
Support for eBPF based port forwarding #3067
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
Conversation
pkg/guestagent/guestagent_linux.go
Outdated
Check failure
Code scanning / CodeQL
Incorrect conversion between integer types High
strconv.Atoi
pkg/guestagent/guestagent_linux.go
Outdated
Check failure
Code scanning / CodeQL
Incorrect conversion between integer types High
strconv.Atoi
cc0d0c9
to
6683a1b
Compare
Signed-off-by: Balaji Vijayakumar <kuttibalaji.v6@gmail.com>
Needs rebase |
What's the current status? |
Am facing issues with kubernetes when I last worked. Not able to derive a common solution there as they are removing all entries and recreating iptables. If we use kube api for kubernetes similarly we will have to do for others as well. Then this ebpf overall will be useful only for guest agent binds |
Duplicating the comments about the current state of the PR
Originally posted by @balajiv113 in #4021 (comment)
Originally posted by @jandubois in #4021 (comment)
Originally posted by @balajiv113 in #4021 (comment)
Originally posted by @AkihiroSuda in #4021 (comment) |
github.com/Microsoft/go-winio v0.6.2 | ||
github.com/apparentlymart/go-cidr v1.1.0 | ||
github.com/balajiv113/fd v0.0.0-20230330094840-143eec500f3e | ||
github.com/balajiv113/trackport v0.0.0-20250102132841-d36c7896b3ee |
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 binary blobs such as https://github.com/balajiv113/trackport/blob/main/pkg/internal/bpftracker/bpf_arm64_bpfel.o have to be removed
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.
Those are actually needed it will be embedded in go logics
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 compile them from source in the Lima repo?
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.
Yes yes that's the ultimate goal after it's all good.
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.
I will clean up stuff and verify it again and see if all still holds good.
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.
It might be even fine to just execute the bpftrace
command to stimulate the ticker, if the go build
stuff is too complicated
lima/cmd/lima-guestagent/daemon_linux.go
Lines 57 to 63 in 7459f45
newTicker := func() (<-chan time.Time, func()) { | |
// TODO: use an equivalent of `bpftrace -e 'tracepoint:syscalls:sys_*_bind { printf("tick\n"); }')`, | |
// without depending on `bpftrace` binary. | |
// The agent binary will need CAP_BPF file cap. | |
ticker := time.NewTicker(tick) | |
return ticker.C, ticker.Stop | |
} |
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.
We can do that as a temp solution.
If we use ebpf then i wanted to avoid parsing the proc file again. As this will add further delay only in forwarding. But identifying ip and ports just by using bpftrace its hard. we need multiple variations. That's where using celium helped to write down our logics
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.
But identifying ip and ports just by using bpftrace its hard. we need multiple variations.
This sounds like it is not really a generic solution and requires custom rules for each container runtime.
I wonder how much latency parsing the proc file is adding; maybe it is not noticeable?
As long as we manage to close the port forwarding before a new container can reopen the port, we should be fine. I guess we can do some stress-testing to see how it works.
if !ok { | ||
return | ||
} | ||
logrus.Debug("tick!") |
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.
To simplify https://github.com/balajiv113/trackport/tree/main/pkg/internal/bpftracker , can we keep the existing collectEvent()
for now, and use eBPF only for stimulating the ticker on kretprobe of bind(2)
?
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.
Yes yes will do that.
I wanted to purely use eBPF because fentry and fexit will wait for the eBPF logic to complete.
So I wanted to verify if the UDP forwarding issue is resolved in that case
Alternative PR |
Improve port forwarding by using ebpf
Note: Test run. Locally it works. Wanted to confirm with all jobs