rust-bpf / rust-bcc

user-friendly rust bindings for the bpf compiler collection
MIT License
475 stars 54 forks source link

Add load_func support and allow setting the debug level #144

Closed javierhonduco closed 4 years ago

javierhonduco commented 4 years ago

This PR adds support for loading BPF programs via load_func, which is used in BPF tail-calls programs. See the commits' messages for more context on this and when it is useful. It also adds support to select the very handy BCC debug level.

We add the bitflags crate to have a nicer way of dealing with the debug flags, and modify one of the error codes to be cleaner, and add expose BpfProgType in the crate's root.

We could migrate the current log_level and other calls that take a debug / log level, to the more type-safe BccDebug in another PR :smile:

Test plan

Added some more smoke tests for these new features, and ran them with Vagrind. Also tried this new feature in a project I am currently porting from a Python BCC driver.

javierhonduco commented 4 years ago

Addressed feedback (+ minor style nit that cargo fmt did not autofix, weird!).

:crossed_fingers: CI passes