Advice on Using Pure Go with eBPF

171 views
Skip to first unread message

Sharon Mafgaoker

unread,
Aug 13, 2024, 6:55:30 PM8/13/24
to golang-nuts

Hey Everyone,

Nice to e-meet you all! I'm new here and kindly asking for some advice on a topic I'm exploring.

While watching Rob Pike's videos about Go, I noticed he doesn't recommend using CGO due to potential issues when changing OS/architecture.

I have an idea to read incoming IPs, perform background checks, and validate them by harnessing the power of concurrency. To analyze packets faster, I want to use eBPF. However, I haven't found a way to load Go code directly into eBPF, and it seems like CGO is the only way.

Does anyone have advice on how to use pure Go with eBPF? Any insights or alternative approaches would be greatly appreciated.

Thank you!

Best regards,
Sharon


burak serdar

unread,
Aug 13, 2024, 7:01:25 PM8/13/24
to Sharon Mafgaoker, golang-nuts
As far as I know, you cannot write ebpf code using Go. You can write C
code for ebpf filters, and then use Go to install it and interface
with it. Take a look at Cilium tools. You might also want to take a
look at https://github.com/kubeshark/tracer.
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/dcf0ea09-e65a-4215-9966-57b3caadc8f2n%40googlegroups.com.

twp...@gmail.com

unread,
Aug 14, 2024, 4:40:41 PM8/14/24
to golang-nuts
For eBPF support in Go, see https://github.com/cilium/ebpf.

AFAIK at the moment you can't compile Go to eBPF. The most promising approach is probably to adapt TinyGo to generate eBPF. There's an issue that's been open for three years with no activity: https://github.com/tinygo-org/tinygo/issues/2017.

Regards,
Tom

Mike Schinkel

unread,
Aug 14, 2024, 7:00:08 PM8/14/24
to twp...@gmail.com, GoLang Nuts Mailing List
I for one would really like to see Go or TinyGo find a way to target eBPF similar to how it can target WASM. 

-Mike

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages