dynatrace-oss / nettracer-bpf

This module allows 3rd party solutions (including Dynatrace OneAgent) to offer event driven monitoring of network traffic on Linux/Unix kernels.
Apache License 2.0
28 stars 5 forks source link

Feature/apm 319515 fix bpf load on older kernels #5

Closed pijuszczyk closed 3 years ago

pijuszczyk commented 3 years ago

In this pull request I'm introducing checking of the kernel version running on the host so that loading of BPF kprobes can be done successfully on kernels < 5.0 without compiling NetTracer on a host with the same kernel version. I also add a simple version check to confirm that we're on a sufficiently new kernel (>= 4.15) on NetTracer's side. The changes are tested using unit tests, for which I had to create a new subproject - bpf_generic previously didn't have any tests and so no tests subproject, that's why. To make everything introduced as clean as possible, I've also slightly modified directory structure for libnettracer (made it more flat) to improve consistency in the project, and added a small tests CMake/make target wrapper to allow a cleaner Makefile.

pijuszczyk commented 3 years ago

It took some time and effort but I've managed to overhaul the way helper functions for getting kernel version are located and tested. As a byproduct, I've also created a small mock for system calls and IO.

I've also deleted the return statement in version >= 4.15 check.

pijuszczyk commented 3 years ago

I've applied fixup commits, merging now