tools: Fix filtering by mount namespace
authorMauricio Vásquez <mauricio@kinvolk.io>
Fri, 16 Jul 2021 21:55:36 +0000 (16:55 -0500)
committeryonghong-song <ys114321@gmail.com>
Sat, 17 Jul 2021 18:19:48 +0000 (11:19 -0700)
The filtering by mount namespace implementation relies on the
redefinition of the "struct mnt_namespace" internal kernel structure.
The layout of this structure changed in Linux 5.11 (https://github.com/torvalds/linux/commit/1a7b8969e664d6af328f00fe6eb7aabd61a71d13),
this commit adds a conditional on the kernel version to adapt to this
change.

Signed-off-by: Mauricio Vásquez <mauricio@kinvolk.io>
src/python/bcc/containers.py

index b55e050..48c1fcc 100644 (file)
@@ -51,7 +51,10 @@ def _mntns_filter_func_writer(mntnsmap):
     * more likely to change.
     */
     struct mnt_namespace {
+    // This field was removed in https://github.com/torvalds/linux/commit/1a7b8969e664d6af328f00fe6eb7aabd61a71d13
+    #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
         atomic_t count;
+    #endif
         struct ns_common ns;
     };