aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Kaindl <bernhardkaindl7@gmail.com>2024-05-07 22:34:32 +0200
committerGitHub <noreply@github.com>2024-05-07 13:34:32 -0700
commit77c05910b1be96467547904c837da9eab7b775a5 (patch)
tree1c64e86a91b58233133970dde47c81f50049361f
parentfef9003e2e2f29c893543d49b762dd413a352f05 (diff)
downloadbcc-77c05910b1be96467547904c837da9eab7b775a5.tar.gz
profile.py: On pre-5.7 kernels, skip pid ns mapping (fallback) (#4974)
bpf_get_ns_current_pid_tgid() is not available before Linux 5.7: When the kernel is prior to 5.7, skip pid namespace translation, as bpf_get_ns_current_pid_tgid() would not be available then. Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
-rwxr-xr-xtools/profile.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/profile.py b/tools/profile.py
index 7961550a..74259256 100755
--- a/tools/profile.py
+++ b/tools/profile.py
@@ -228,6 +228,9 @@ int do_perf_event(struct bpf_perf_event_data *ctx) {
# pid-namespace translation
try:
devinfo = os.stat("/proc/self/ns/pid")
+ version = "".join([ver.zfill(2) for ver in os.uname().release.split(".")])
+ # Need Linux >= 5.7 to have helper bpf_get_ns_current_pid_tgid() available:
+ assert(version[:4] >= "0507")
bpf_text = bpf_text.replace('USE_PIDNS', "1")
bpf_text = bpf_text.replace('PIDNS_DEV', str(devinfo.st_dev))
bpf_text = bpf_text.replace('PIDNS_INO', str(devinfo.st_ino))