You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am writing a simple program that reads the tcp/tcp_probe tracepoint.
A common programming technique when writing BPF programs is including kernel headers to access struct definitions. Indeed, kernelscript init does usefully auto-generate bindings to certain kernel definitions.
Is there an easy way to have kernelscript additionally generate bindings to other values or kernel headers without manually copying them? For tcp/tcp_probe specifically, parsing struct sockaddr_in is relevant.
Good question! Currently kernelscript init only pulls context-related kernel structs from BTF (probably also its dependencies). Without hard-coding, it does not have knowledge to pull other related structs like struct sockaddr_in. Do you have any better ideas here?
Activity
congwang commentedon Sep 29, 2025
Good question! Currently
kernelscript initonly pulls context-related kernel structs from BTF (probably also its dependencies). Without hard-coding, it does not have knowledge to pull other related structs like struct sockaddr_in. Do you have any better ideas here?akshayknarayan commentedon Sep 29, 2025
Thanks for the clarification! I agree that pulling in related structs automatically is going to be quite hard, since tracepoint defs erase type info.
A workaround might be to generate further bindings at compile time, with a statement such as the following (extrapolated from the syntax described here: https://github.com/multikernel/kernelscript/blob/main/SPEC.md#14-unified-import-and-include-system)
congwang commentedon Sep 30, 2025
Good idea! I think that is feasible.