{"repo":"tw4452852/zbpf","free":true,"listed":false,"github":"https://github.com/tw4452852/zbpf","clone":"git clone https://github.com/tw4452852/zbpf.git","description":"Writing eBPF in Zig","language":"Zig","stars":277,"topics":["bpf","ebpf","zig","tracing"],"license":"GPL-3.0","category":"analytics","readme_excerpt":"zbpf Writing eBPF in Zig. Thanks to Zig's comptime and BTF, we can equip eBPF with strong type system both at comptime and runtime! Notable advantages when writing eBPF program with zbpf Different available methods based on the type of program's context Suppose you want to trace the kernel function path listxattr, and here's its prototype: As you can see, it has 4 input parameters and return type is ssize t . With ctx = bpf.Kprobe{.name = \"path listxattr\"}.Ctx() , you could retrieve the input parameter with ctx.arg0() , ctx.arg1() , ctx.arg2() and ctx.arg3() respectively, and return value with ctx.ret() . the type will be consistent with the above prototype. If you try to access a non-existing parameter, e.g. ctx.arg4() , you will get a compilation error. This also applies to syscall with bpf.Ksyscall , tracepoint with bpf.Tracepoint and fentry with bpf.Fentry . No more tedious error handling When writing in C, you always have to check the error conditions (the return value of the helper function, pointer validation, ...) With zbpf , you won't care about the these cases, we handle it under the hood for you, just focus on the business logic. The following are some examples: - bpf.Map takes care BPF map's update and delete error. - bpf.PerfEventArray handles event output failure. - bpf.RingBuffer also handles space reservation. - bpf.Xdp validates the pointer for you. If some error happens, you could get all the information (file, line number, return value ...) you need to debu","default_branch":null,"files":null,"tree":[],"storefront":"/r/tw4452852","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/tw4452852/zbpf/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}