diff --git a/.bcc.metadata b/.bcc.metadata index 9ef710d..e3a63ae 100644 --- a/.bcc.metadata +++ b/.bcc.metadata @@ -1 +1 @@ -96882747089d093b8933456d9c7905407bde7fd9 SOURCES/bcc-0.19.0.tar.gz +896d0249470dedfabfcc9a4c8b4089a55b793277 SOURCES/bcc-0.24.0.tar.gz diff --git a/.gitignore b/.gitignore index 7fc1d6f..277ef94 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/bcc-0.19.0.tar.gz +SOURCES/bcc-0.24.0.tar.gz diff --git a/SOURCES/bcc-0.19.0-Define-missing-BPF_-macros.patch b/SOURCES/bcc-0.19.0-Define-missing-BPF_-macros.patch deleted file mode 100644 index 01d524d..0000000 --- a/SOURCES/bcc-0.19.0-Define-missing-BPF_-macros.patch +++ /dev/null @@ -1,27 +0,0 @@ -From d25f87677b554d9cbdc609c020a2baa59e442443 Mon Sep 17 00:00:00 2001 -From: Jerome Marchand -Date: Wed, 2 Jun 2021 10:57:43 +0200 -Subject: [PATCH] Define missing BPF_* macros - -We're currently missing BPF_MAP_TYPE_TASK_STORAGE. This could be -fixed by a future rebase. In the mean time, let's have a temporary -fix. - -diff --git a/introspection/bps.c b/introspection/bps.c -index 0eae675e..1108e417 100644 ---- a/introspection/bps.c -+++ b/introspection/bps.c -@@ -49,6 +49,10 @@ static const char * const prog_type_strings[] = { - [BPF_PROG_TYPE_SK_LOOKUP] = "sk_lookup", - }; - -+#ifndef BPF_MAP_TYPE_TASK_STORAGE -+#define BPF_MAP_TYPE_TASK_STORAGE (BPF_MAP_TYPE_INODE_STORAGE + 1) -+#endif -+ - static const char * const map_type_strings[] = { - [BPF_MAP_TYPE_UNSPEC] = "unspec", - [BPF_MAP_TYPE_HASH] = "hash", --- -2.31.1 - diff --git a/SOURCES/bcc-0.19.0-Fix-BPF-src_file-foo.patch b/SOURCES/bcc-0.19.0-Fix-BPF-src_file-foo.patch deleted file mode 100644 index 4154b4b..0000000 --- a/SOURCES/bcc-0.19.0-Fix-BPF-src_file-foo.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 9051043a126a838902b88d144eea1b631d2c3eef Mon Sep 17 00:00:00 2001 -From: Jerome Marchand -Date: Tue, 27 Apr 2021 15:13:12 +0200 -Subject: [PATCH] Fix BPF(src_file="foo") - -Since commit 75f20a15 ("Use string type for comparison to PATH -elements"), src_file isn't working anymore. Somehow, two wrongs -(ArgString __str__() returning a bytes object and joining a bytes and -what was supposed to be a string) did make a right. - -It fixes the following error in netqtop and deadlock: -Traceback (most recent call last): - File "/usr/share/bcc/tools/netqtop", line 207, in - b = BPF(src_file = EBPF_FILE) - File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 335, in __init__ - src_file = BPF._find_file(src_file) - File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 255, in _find_file - t = b"/".join([os.path.abspath(os.path.dirname(argv0.__str__())), filename]) -TypeError: sequence item 0: expected a bytes-like object, str found ---- - src/python/bcc/__init__.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py -index 90562cd7..eabe0a55 100644 ---- a/src/python/bcc/__init__.py -+++ b/src/python/bcc/__init__.py -@@ -252,7 +252,7 @@ DEBUG_BTF = 0x20 - if filename: - if not os.path.isfile(filename): - argv0 = ArgString(sys.argv[0]) -- t = b"/".join([os.path.abspath(os.path.dirname(argv0.__str__())), filename]) -+ t = b"/".join([os.path.abspath(os.path.dirname(argv0.__bytes__())), filename]) - if os.path.isfile(t): - filename = t - else: --- -2.30.2 - diff --git a/SOURCES/bcc-0.19.0-Fix-a-llvm-compilation-error.patch b/SOURCES/bcc-0.19.0-Fix-a-llvm-compilation-error.patch deleted file mode 100644 index e3febea..0000000 --- a/SOURCES/bcc-0.19.0-Fix-a-llvm-compilation-error.patch +++ /dev/null @@ -1,46 +0,0 @@ -From bb121e49b1a05e86c88274a89f5229b4ec6939c6 Mon Sep 17 00:00:00 2001 -From: Yonghong Song -Date: Tue, 25 May 2021 19:58:00 -0700 -Subject: [PATCH 2/2] Fix a llvm compilation error -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Current llvm trunk (https://github.com/llvm/llvm-project) -will cause the following compilation errors: - /home/yhs/work/bcc/src/cc/bcc_debug.cc: In member function ‘void ebpf::SourceDebugger::dump()’: - /home/yhs/work/bcc/src/cc/bcc_debug.cc:135:75: error: no matching function for call to - ‘llvm::MCContext::MCContext(llvm::Triple&, std::unique_ptr::pointer, - std::unique_ptr::pointer, llvm::MCObjectFileInfo*, - std::unique_ptr::pointer, std::nullptr_t)’ - MCContext Ctx(TheTriple, MAI.get(), MRI.get(), &MOFI, STI.get(), nullptr); - ^ - ...... - -This is because upstream patch https://reviews.llvm.org/D101921 -refactored MCObjectFileInfo initialization and changed MCContext -constructor signature. - -This patch fixed the issue by following the new code patterns -in https://reviews.llvm.org/D101921. ---- - src/cc/bcc_debug.cc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/cc/bcc_debug.cc b/src/cc/bcc_debug.cc -index 775c9141..97d6d95b 100644 ---- a/src/cc/bcc_debug.cc -+++ b/src/cc/bcc_debug.cc -@@ -132,7 +132,8 @@ void SourceDebugger::dump() { - T->createMCSubtargetInfo(TripleStr, "", "")); - MCObjectFileInfo MOFI; - #if LLVM_MAJOR_VERSION >= 13 -- MCContext Ctx(TheTriple, MAI.get(), MRI.get(), &MOFI, STI.get(), nullptr); -+ MCContext Ctx(TheTriple, MAI.get(), MRI.get(), STI.get(), nullptr); -+ Ctx.setObjectFileInfo(&MOFI); - MOFI.initMCObjectFileInfo(Ctx, false, false); - #else - MCContext Ctx(MAI.get(), MRI.get(), &MOFI, nullptr); --- -2.31.1 - diff --git a/SOURCES/bcc-0.19.0-Handle-renaming-of-task_struct_-state-field-on-RHEL-.patch b/SOURCES/bcc-0.19.0-Handle-renaming-of-task_struct_-state-field-on-RHEL-.patch deleted file mode 100644 index ef6ef95..0000000 --- a/SOURCES/bcc-0.19.0-Handle-renaming-of-task_struct_-state-field-on-RHEL-.patch +++ /dev/null @@ -1,110 +0,0 @@ -From c610314e8f8265317bf54ef518df48809834feba Mon Sep 17 00:00:00 2001 -From: Jerome Marchand -Date: Thu, 14 Oct 2021 12:01:01 +0200 -Subject: [PATCH] Handle renaming of task_struct_>state field on RHEL 9 - -There has been some cleanup of task_struct's state field and to catch -any place that has been missed in the conversion, it has been renamed -__state. ---- - tools/cpudist.py | 2 +- - tools/offcputime.py | 4 ++-- - tools/offwaketime.py | 4 ++-- - tools/runqlat.py | 4 ++-- - tools/runqslower.py | 4 ++-- - 5 files changed, 9 insertions(+), 9 deletions(-) - -diff --git a/tools/cpudist.py b/tools/cpudist.py -index eb04f590..ba36ba76 100755 ---- a/tools/cpudist.py -+++ b/tools/cpudist.py -@@ -101,7 +101,7 @@ int sched_switch(struct pt_regs *ctx, struct task_struct *prev) - u32 tgid = pid_tgid >> 32, pid = pid_tgid; - - #ifdef ONCPU -- if (prev->state == TASK_RUNNING) { -+ if (prev->__state == TASK_RUNNING) { - #else - if (1) { - #endif -diff --git a/tools/offcputime.py b/tools/offcputime.py -index 128c6496..b93e78d2 100755 ---- a/tools/offcputime.py -+++ b/tools/offcputime.py -@@ -205,10 +205,10 @@ thread_context = "" - thread_context = "all threads" - thread_filter = '1' - if args.state == 0: -- state_filter = 'prev->state == 0' -+ state_filter = 'prev->__state == 0' - elif args.state: - # these states are sometimes bitmask checked -- state_filter = 'prev->state & %d' % args.state -+ state_filter = 'prev->__state & %d' % args.state - else: - state_filter = '1' - bpf_text = bpf_text.replace('THREAD_FILTER', thread_filter) -diff --git a/tools/offwaketime.py b/tools/offwaketime.py -index 753eee97..722c0381 100755 ---- a/tools/offwaketime.py -+++ b/tools/offwaketime.py -@@ -254,10 +254,10 @@ int oncpu(struct pt_regs *ctx, struct task_struct *p) { - else: - thread_filter = '1' - if args.state == 0: -- state_filter = 'p->state == 0' -+ state_filter = 'p->__state == 0' - elif args.state: - # these states are sometimes bitmask checked -- state_filter = 'p->state & %d' % args.state -+ state_filter = 'p->__state & %d' % args.state - else: - state_filter = '1' - bpf_text = bpf_text.replace('THREAD_FILTER', thread_filter) -diff --git a/tools/runqlat.py b/tools/runqlat.py -index b13ff2d1..8e443c3c 100755 ---- a/tools/runqlat.py -+++ b/tools/runqlat.py -@@ -116,7 +116,7 @@ int trace_run(struct pt_regs *ctx, struct task_struct *prev) - u32 pid, tgid; - - // ivcsw: treat like an enqueue event and store timestamp -- if (prev->state == TASK_RUNNING) { -+ if (prev->__state == TASK_RUNNING) { - tgid = prev->tgid; - pid = prev->pid; - if (!(FILTER || pid == 0)) { -@@ -170,7 +170,7 @@ RAW_TRACEPOINT_PROBE(sched_switch) - u32 pid, tgid; - - // ivcsw: treat like an enqueue event and store timestamp -- if (prev->state == TASK_RUNNING) { -+ if (prev->__state == TASK_RUNNING) { - tgid = prev->tgid; - pid = prev->pid; - if (!(FILTER || pid == 0)) { -diff --git a/tools/runqslower.py b/tools/runqslower.py -index 6df98d9f..ba71e5d3 100755 ---- a/tools/runqslower.py -+++ b/tools/runqslower.py -@@ -112,7 +112,7 @@ int trace_run(struct pt_regs *ctx, struct task_struct *prev) - u32 pid, tgid; - - // ivcsw: treat like an enqueue event and store timestamp -- if (prev->state == TASK_RUNNING) { -+ if (prev->__state == TASK_RUNNING) { - tgid = prev->tgid; - pid = prev->pid; - u64 ts = bpf_ktime_get_ns(); -@@ -178,7 +178,7 @@ RAW_TRACEPOINT_PROBE(sched_switch) - long state; - - // ivcsw: treat like an enqueue event and store timestamp -- bpf_probe_read_kernel(&state, sizeof(long), (const void *)&prev->state); -+ bpf_probe_read_kernel(&state, sizeof(long), (const void *)&prev->__state); - if (state == TASK_RUNNING) { - bpf_probe_read_kernel(&tgid, sizeof(prev->tgid), &prev->tgid); - bpf_probe_read_kernel(&pid, sizeof(prev->pid), &prev->pid); --- -2.31.1 - diff --git a/SOURCES/bcc-0.19.0-Remove-APInt-APSInt-toString-std-string-variants.patch b/SOURCES/bcc-0.19.0-Remove-APInt-APSInt-toString-std-string-variants.patch deleted file mode 100644 index 161f5e3..0000000 --- a/SOURCES/bcc-0.19.0-Remove-APInt-APSInt-toString-std-string-variants.patch +++ /dev/null @@ -1,41 +0,0 @@ -From da1f8b4b8389e463e323885e402f96b3bc6ceb35 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Mon, 14 Jun 2021 12:49:43 -0700 -Subject: [PATCH] Remove APInt/APSInt toString() std::string variants - -clang 13+ has removed this in favour of a pair of llvm::toString -() helpers inside StringExtras.h to improve compile speed by avoiding -hits on header - -Signed-off-by: Khem Raj ---- - src/cc/json_map_decl_visitor.cc | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/src/cc/json_map_decl_visitor.cc b/src/cc/json_map_decl_visitor.cc -index eff4d067..53896199 100644 ---- a/src/cc/json_map_decl_visitor.cc -+++ b/src/cc/json_map_decl_visitor.cc -@@ -20,6 +20,7 @@ - #include - #include - #include -+#include - #include "common.h" - #include "table_desc.h" - -@@ -79,7 +80,11 @@ void BMapDeclVisitor::genJSONForField(FieldDecl *F) { - result_ += "["; - TraverseDecl(F); - if (const ConstantArrayType *T = dyn_cast(F->getType())) -+#if LLVM_MAJOR_VERSION >= 13 -+ result_ += ", [" + toString(T->getSize(), 10, false) + "]"; -+#else - result_ += ", [" + T->getSize().toString(10, false) + "]"; -+#endif - if (F->isBitField()) - result_ += ", " + to_string(F->getBitWidthValue(C)); - result_ += "], "; --- -2.31.1 - diff --git a/SOURCES/bcc-0.19.0-fix-llvm-compilation-errors.patch b/SOURCES/bcc-0.19.0-fix-llvm-compilation-errors.patch deleted file mode 100644 index 3c3376a..0000000 --- a/SOURCES/bcc-0.19.0-fix-llvm-compilation-errors.patch +++ /dev/null @@ -1,42 +0,0 @@ -From d74c96d9423652d4467339ee24bb6db2e5df21cb Mon Sep 17 00:00:00 2001 -From: Yonghong Song -Date: Wed, 5 May 2021 19:11:13 -0700 -Subject: [PATCH 1/2] fix llvm compilation errors - -MCContext and InitMCObjectFileInfo name/signatures -are changed due to upstream patch - https://reviews.llvm.org/D101462 -Adjust related codes in bcc_debug.cc properly to resolve -the compilation error for llvm13. - -Signed-off-by: Yonghong Song ---- - src/cc/bcc_debug.cc | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -diff --git a/src/cc/bcc_debug.cc b/src/cc/bcc_debug.cc -index 371b6ad3..775c9141 100644 ---- a/src/cc/bcc_debug.cc -+++ b/src/cc/bcc_debug.cc -@@ -128,11 +128,16 @@ void SourceDebugger::dump() { - return; - } - -+ std::unique_ptr STI( -+ T->createMCSubtargetInfo(TripleStr, "", "")); - MCObjectFileInfo MOFI; -+#if LLVM_MAJOR_VERSION >= 13 -+ MCContext Ctx(TheTriple, MAI.get(), MRI.get(), &MOFI, STI.get(), nullptr); -+ MOFI.initMCObjectFileInfo(Ctx, false, false); -+#else - MCContext Ctx(MAI.get(), MRI.get(), &MOFI, nullptr); - MOFI.InitMCObjectFileInfo(TheTriple, false, Ctx, false); -- std::unique_ptr STI( -- T->createMCSubtargetInfo(TripleStr, "", "")); -+#endif - - std::unique_ptr MCII(T->createMCInstrInfo()); - MCInstPrinter *IP = T->createMCInstPrinter(TheTriple, 0, *MAI, *MCII, *MRI); --- -2.31.1 - diff --git a/SOURCES/bcc-0.19.0-Manpages-remove-unstable-statement.patch b/SOURCES/bcc-0.24.0-Manpages-remove-unstable-statement.patch similarity index 94% rename from SOURCES/bcc-0.19.0-Manpages-remove-unstable-statement.patch rename to SOURCES/bcc-0.24.0-Manpages-remove-unstable-statement.patch index dc84ec9..7b60d98 100644 --- a/SOURCES/bcc-0.19.0-Manpages-remove-unstable-statement.patch +++ b/SOURCES/bcc-0.24.0-Manpages-remove-unstable-statement.patch @@ -1,4 +1,4 @@ -From f4e66f50d1af5b5dd0dc1dbb261f911514c465ed Mon Sep 17 00:00:00 2001 +From 6362a8e023cb53a523ab5a3d11bddcdbe05229fc Mon Sep 17 00:00:00 2001 From: Jerome Marchand Date: Tue, 6 Aug 2019 14:44:33 +0200 Subject: [PATCH] Manpages: remove unstable statement @@ -48,6 +48,7 @@ enough. man/man8/inject.8 | 4 ---- man/man8/killsnoop.8 | 2 -- man/man8/klockstat.8 | 2 -- + man/man8/kvmexit.8 | 2 -- man/man8/llcstat.8 | 2 -- man/man8/mdflush.8 | 2 -- man/man8/memleak.8 | 2 -- @@ -109,13 +110,13 @@ enough. man/man8/xfsslower.8 | 2 -- man/man8/zfsdist.8 | 2 -- man/man8/zfsslower.8 | 2 -- - 103 files changed, 208 deletions(-) + 104 files changed, 210 deletions(-) diff --git a/man/man8/argdist.8 b/man/man8/argdist.8 -index 4116cd4d..aa128d2d 100644 +index 3033571b..91f13a33 100644 --- a/man/man8/argdist.8 +++ b/man/man8/argdist.8 -@@ -188,7 +188,5 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -191,7 +191,5 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -150,10 +151,10 @@ index f8fa1850..05ed95a7 100644 Pavel Dubovitsky .SH SEE ALSO diff --git a/man/man8/biolatency.8 b/man/man8/biolatency.8 -index c303eec0..895deb31 100644 +index c13f6c8a..6beef490 100644 --- a/man/man8/biolatency.8 +++ b/man/man8/biolatency.8 -@@ -98,8 +98,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -105,8 +105,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -316,7 +317,7 @@ index a2933d7a..c1339579 100644 .SH AUTHOR Wenbo Zhang diff --git a/man/man8/cpudist.8 b/man/man8/cpudist.8 -index 6ee1f3bf..979f0451 100644 +index b5179102..a7825d64 100644 --- a/man/man8/cpudist.8 +++ b/man/man8/cpudist.8 @@ -99,8 +99,6 @@ Also look in the bcc distribution for a companion _example.txt file containing @@ -342,10 +343,10 @@ index 674be499..107ff67b 100644 Brendan Gregg .SH SEE ALSO diff --git a/man/man8/criticalstat.8 b/man/man8/criticalstat.8 -index cdd5e8ed..8f918707 100644 +index 6b1c1110..6df592a3 100644 --- a/man/man8/criticalstat.8 +++ b/man/man8/criticalstat.8 -@@ -65,8 +65,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -66,8 +66,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -407,10 +408,10 @@ index e2bc4dc8..0501460f 100644 Brendan Gregg .SH SEE ALSO diff --git a/man/man8/deadlock.8 b/man/man8/deadlock.8 -index 0be3f4ab..7300446a 100644 +index 3e7744ce..9f0f7de0 100644 --- a/man/man8/deadlock.8 +++ b/man/man8/deadlock.8 -@@ -136,7 +136,5 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -144,7 +144,5 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -548,10 +549,10 @@ index 16ce4fc0..1c7b71c1 100644 Brendan Gregg, Sasha Goldshtein .SH SEE ALSO diff --git a/man/man8/funcinterval.8 b/man/man8/funcinterval.8 -index 89a4a7b4..c9e1f31a 100755 +index 8a603998..39be3377 100755 --- a/man/man8/funcinterval.8 +++ b/man/man8/funcinterval.8 -@@ -106,8 +106,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -114,8 +114,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -561,10 +562,10 @@ index 89a4a7b4..c9e1f31a 100755 Edward Wu .SH SEE ALSO diff --git a/man/man8/funclatency.8 b/man/man8/funclatency.8 -index b82626cf..3c8e248e 100644 +index 3eef805b..22496d18 100644 --- a/man/man8/funclatency.8 +++ b/man/man8/funclatency.8 -@@ -127,8 +127,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -130,8 +130,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -600,17 +601,17 @@ index a9d18e07..876f3983 100644 Brendan Gregg .SH SEE ALSO diff --git a/man/man8/hardirqs.8 b/man/man8/hardirqs.8 -index 8e7237a9..9e6975c9 100644 +index 12ae6be5..1b38779a 100644 --- a/man/man8/hardirqs.8 +++ b/man/man8/hardirqs.8 -@@ -87,8 +87,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -88,8 +88,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux -.SH STABILITY -Unstable - in development. .SH AUTHOR - Brendan Gregg + Brendan Gregg, Hengqi Chen .SH SEE ALSO diff --git a/man/man8/inject.8 b/man/man8/inject.8 index 2ab80dbb..85b36b6e 100644 @@ -652,6 +653,18 @@ index 0a3167d1..57f9db18 100644 .SH CREDITS This tool is based on work of David Valin and his script. .SH AUTHOR +diff --git a/man/man8/kvmexit.8 b/man/man8/kvmexit.8 +index c0cb4c98..0b56cecc 100644 +--- a/man/man8/kvmexit.8 ++++ b/man/man8/kvmexit.8 +@@ -109,7 +109,5 @@ Also look in the bcc distribution for a companion _examples.txt file containing + example usage, output, and commentary for this tool. + .SH OS + Linux +-.SH STABILITY +-Unstable - in development. + .SH AUTHOR + Fei Li diff --git a/man/man8/llcstat.8 b/man/man8/llcstat.8 index 36dbed7d..2b554c46 100644 --- a/man/man8/llcstat.8 @@ -884,10 +897,10 @@ index b36a5a18..c2f0ffb4 100644 Brendan Gregg .SH SEE ALSO diff --git a/man/man8/runqslower.8 b/man/man8/runqslower.8 -index f8b5f008..c72389d7 100644 +index 55ea5bd9..dbbec5ae 100644 --- a/man/man8/runqslower.8 +++ b/man/man8/runqslower.8 -@@ -81,8 +81,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -84,8 +84,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -969,10 +982,10 @@ index ffad57c5..df80437f 100644 Jiri Olsa .SH SEE ALSO diff --git a/man/man8/sslsniff.8 b/man/man8/sslsniff.8 -index 7b945b00..b23f4c68 100644 +index df81664b..1d2749fa 100644 --- a/man/man8/sslsniff.8 +++ b/man/man8/sslsniff.8 -@@ -43,8 +43,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -86,8 +86,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -1047,10 +1060,10 @@ index d13793be..88343e14 100644 Sasha Goldshtein .SH SEE ALSO diff --git a/man/man8/tcpaccept.8 b/man/man8/tcpaccept.8 -index 603a5ca4..4e7dfc9e 100644 +index 05b79693..6dd35301 100644 --- a/man/man8/tcpaccept.8 +++ b/man/man8/tcpaccept.8 -@@ -104,8 +104,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -118,8 +118,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -1060,10 +1073,10 @@ index 603a5ca4..4e7dfc9e 100644 Brendan Gregg .SH SEE ALSO diff --git a/man/man8/tcpconnect.8 b/man/man8/tcpconnect.8 -index 55105709..7c1740a4 100644 +index 0ea84686..04952d74 100644 --- a/man/man8/tcpconnect.8 +++ b/man/man8/tcpconnect.8 -@@ -183,8 +183,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -197,8 +197,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -1073,10 +1086,10 @@ index 55105709..7c1740a4 100644 Brendan Gregg .SH SEE ALSO diff --git a/man/man8/tcpconnlat.8 b/man/man8/tcpconnlat.8 -index 9c810071..236f0fb0 100644 +index 84762b45..3771baa7 100644 --- a/man/man8/tcpconnlat.8 +++ b/man/man8/tcpconnlat.8 -@@ -111,8 +111,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -125,8 +125,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -1086,49 +1099,49 @@ index 9c810071..236f0fb0 100644 Brendan Gregg .SH SEE ALSO diff --git a/man/man8/tcpdrop.8 b/man/man8/tcpdrop.8 -index 12806472..a2e2860c 100644 +index c9b777b3..82e400eb 100644 --- a/man/man8/tcpdrop.8 +++ b/man/man8/tcpdrop.8 -@@ -65,8 +65,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing - example usage, output, and commentary for this tool. - .SH OS - Linux --.SH STABILITY --Unstable - in development. - .SH AUTHOR - Brendan Gregg - .SH SEE ALSO -diff --git a/man/man8/tcplife.8 b/man/man8/tcplife.8 -index a2419c61..a2a2550c 100644 ---- a/man/man8/tcplife.8 -+++ b/man/man8/tcplife.8 -@@ -122,8 +122,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing - example usage, output, and commentary for this tool. - .SH OS - Linux --.SH STABILITY --Unstable - in development. - .SH AUTHOR - Brendan Gregg - .SH SEE ALSO -diff --git a/man/man8/tcpretrans.8 b/man/man8/tcpretrans.8 -index 0ac82afa..04226dc6 100644 ---- a/man/man8/tcpretrans.8 -+++ b/man/man8/tcpretrans.8 @@ -83,8 +83,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux -.SH STABILITY +-Unstable - in development. + .SH AUTHOR + Brendan Gregg + .SH SEE ALSO +diff --git a/man/man8/tcplife.8 b/man/man8/tcplife.8 +index 5fb4c283..cc76d870 100644 +--- a/man/man8/tcplife.8 ++++ b/man/man8/tcplife.8 +@@ -136,8 +136,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing + example usage, output, and commentary for this tool. + .SH OS + Linux +-.SH STABILITY +-Unstable - in development. + .SH AUTHOR + Brendan Gregg + .SH SEE ALSO +diff --git a/man/man8/tcpretrans.8 b/man/man8/tcpretrans.8 +index 0b643d11..aebdab73 100644 +--- a/man/man8/tcpretrans.8 ++++ b/man/man8/tcpretrans.8 +@@ -103,8 +103,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing + example usage, output, and commentary for this tool. + .SH OS + Linux +-.SH STABILITY -Unstable - in development. .SH AUTHOR Brendan Gregg .SH SEE ALSO diff --git a/man/man8/tcprtt.8 b/man/man8/tcprtt.8 -index 729a1abb..e934102a 100644 +index 1ed32d6e..4ccf88e0 100644 --- a/man/man8/tcprtt.8 +++ b/man/man8/tcprtt.8 -@@ -78,8 +78,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -95,8 +95,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -1138,10 +1151,10 @@ index 729a1abb..e934102a 100644 zhenwei pi .SH SEE ALSO diff --git a/man/man8/tcpstates.8 b/man/man8/tcpstates.8 -index 26c7a8a1..d93c198d 100644 +index 57c40a83..1d6b8a29 100644 --- a/man/man8/tcpstates.8 +++ b/man/man8/tcpstates.8 -@@ -123,8 +123,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -137,8 +137,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -1164,10 +1177,10 @@ index 525b8082..daf41583 100644 Rodrigo Manyari .SH INSPIRATION diff --git a/man/man8/tcpsynbl.8 b/man/man8/tcpsynbl.8 -index 4dd38c8a..93c353b1 100644 +index 8557af2b..c03c5460 100644 --- a/man/man8/tcpsynbl.8 +++ b/man/man8/tcpsynbl.8 -@@ -51,8 +51,6 @@ Also look in the bcc distribution for a companion _examples.txt file +@@ -69,8 +69,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -1177,10 +1190,10 @@ index 4dd38c8a..93c353b1 100644 Brendan Gregg .SH SEE ALSO diff --git a/man/man8/tcptop.8 b/man/man8/tcptop.8 -index e636f456..633b0c93 100644 +index f4f1c3d7..013cb3d9 100644 --- a/man/man8/tcptop.8 +++ b/man/man8/tcptop.8 -@@ -113,8 +113,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -127,8 +127,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -1190,10 +1203,10 @@ index e636f456..633b0c93 100644 Brendan Gregg .SH INSPIRATION diff --git a/man/man8/tcptracer.8 b/man/man8/tcptracer.8 -index d2346c77..893604d6 100644 +index 59240f4b..331efe9a 100644 --- a/man/man8/tcptracer.8 +++ b/man/man8/tcptracer.8 -@@ -99,8 +99,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -113,8 +113,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -1228,10 +1241,10 @@ index da5edf37..f7e459da 100644 .SH AUTHOR Sasha Goldshtein diff --git a/man/man8/trace.8 b/man/man8/trace.8 -index e4f06fc7..7b68d833 100644 +index acfff58f..17aa20bc 100644 --- a/man/man8/trace.8 +++ b/man/man8/trace.8 -@@ -210,7 +210,5 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -216,7 +216,5 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -1240,10 +1253,10 @@ index e4f06fc7..7b68d833 100644 .SH AUTHOR Sasha Goldshtein diff --git a/man/man8/ttysnoop.8 b/man/man8/ttysnoop.8 -index 9f37aaa9..36eb75d1 100644 +index e2ec037f..e20feb01 100644 --- a/man/man8/ttysnoop.8 +++ b/man/man8/ttysnoop.8 -@@ -52,8 +52,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing +@@ -58,8 +58,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. .SH OS Linux @@ -1435,5 +1448,5 @@ index d1e2f9c1..31d382f6 100644 Brendan Gregg .SH SEE ALSO -- -2.30.2 +2.35.3 diff --git a/SOURCES/bcc-0.24.0-RHEL-libbpf-version-fixes.patch b/SOURCES/bcc-0.24.0-RHEL-libbpf-version-fixes.patch new file mode 100644 index 0000000..b00d20e --- /dev/null +++ b/SOURCES/bcc-0.24.0-RHEL-libbpf-version-fixes.patch @@ -0,0 +1,324 @@ +From 8f2951559127ffb93c3e36d5fc9d870768826ae9 Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Thu, 24 Mar 2022 16:08:17 +0100 +Subject: [PATCH 2/2] RHEL: libbpf version fixes + +Revert "bcc: Replace deprecated libbpf APIs" since the libbpf version +provided in RHEL 8 doesn't provide the new APIs. + +Remove BPF_MAP_TYPE_BLOOM_FILTER from bps since the libbpf version in +RHEL 8, doesn't provide bloom filter map. + +Rename btf__load_vmlinux_btf into libbpf_find_kernel_btf. The function +has been renamed upstream for naming consistency, but RHEL 8 libbpf +still uses the old name. + +Add definition of struct bpf_core_relo. +--- + introspection/bps.c | 1 - + libbpf-tools/ksnoop.c | 2 +- + src/cc/bcc_btf.cc | 73 ++++++++++++++++++++++++++++++++++++- + src/cc/libbpf.c | 84 +++++++------------------------------------ + 4 files changed, 85 insertions(+), 75 deletions(-) + +diff --git a/introspection/bps.c b/introspection/bps.c +index 232b23d4..6ec02e6c 100644 +--- a/introspection/bps.c ++++ b/introspection/bps.c +@@ -80,7 +80,6 @@ static const char * const map_type_strings[] = { + [BPF_MAP_TYPE_RINGBUF] = "ringbuf", + [BPF_MAP_TYPE_INODE_STORAGE] = "inode_storage", + [BPF_MAP_TYPE_TASK_STORAGE] = "task_storage", +- [BPF_MAP_TYPE_BLOOM_FILTER] = "bloom_filter", + }; + + #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) +diff --git a/libbpf-tools/ksnoop.c b/libbpf-tools/ksnoop.c +index 69c58403..a6ea6107 100644 +--- a/libbpf-tools/ksnoop.c ++++ b/libbpf-tools/ksnoop.c +@@ -347,7 +347,7 @@ static struct btf *get_btf(const char *name) + name && strlen(name) > 0 ? name : "vmlinux"); + + if (!vmlinux_btf) { +- vmlinux_btf = btf__load_vmlinux_btf(); ++ vmlinux_btf = libbpf_find_kernel_btf(); + if (!vmlinux_btf) { + err = -errno; + p_err("No BTF, cannot determine type info: %s", strerror(-err)); +diff --git a/src/cc/bcc_btf.cc b/src/cc/bcc_btf.cc +index 7f551ae8..c78ba823 100644 +--- a/src/cc/bcc_btf.cc ++++ b/src/cc/bcc_btf.cc +@@ -170,6 +170,77 @@ static int btf_ext_setup_line_info(struct btf_ext *btf_ext) + return btf_ext_setup_info(btf_ext, ¶m); + } + ++/* bpf_core_relo_kind encodes which aspect of captured field/type/enum value ++ * has to be adjusted by relocations. ++ */ ++enum bpf_core_relo_kind { ++ BPF_FIELD_BYTE_OFFSET = 0, /* field byte offset */ ++ BPF_FIELD_BYTE_SIZE = 1, /* field size in bytes */ ++ BPF_FIELD_EXISTS = 2, /* field existence in target kernel */ ++ BPF_FIELD_SIGNED = 3, /* field signedness (0 - unsigned, 1 - signed) */ ++ BPF_FIELD_LSHIFT_U64 = 4, /* bitfield-specific left bitshift */ ++ BPF_FIELD_RSHIFT_U64 = 5, /* bitfield-specific right bitshift */ ++ BPF_TYPE_ID_LOCAL = 6, /* type ID in local BPF object */ ++ BPF_TYPE_ID_TARGET = 7, /* type ID in target kernel */ ++ BPF_TYPE_EXISTS = 8, /* type existence in target kernel */ ++ BPF_TYPE_SIZE = 9, /* type size in bytes */ ++ BPF_ENUMVAL_EXISTS = 10, /* enum value existence in target kernel */ ++ BPF_ENUMVAL_VALUE = 11, /* enum value integer value */ ++}; ++ ++/* The minimum bpf_core_relo checked by the loader ++ * ++ * CO-RE relocation captures the following data: ++ * - insn_off - instruction offset (in bytes) within a BPF program that needs ++ * its insn->imm field to be relocated with actual field info; ++ * - type_id - BTF type ID of the "root" (containing) entity of a relocatable ++ * type or field; ++ * - access_str_off - offset into corresponding .BTF string section. String ++ * interpretation depends on specific relocation kind: ++ * - for field-based relocations, string encodes an accessed field using ++ * a sequence of field and array indices, separated by colon (:). It's ++ * conceptually very close to LLVM's getelementptr ([0]) instruction's ++ * arguments for identifying offset to a field. ++ * - for type-based relocations, strings is expected to be just "0"; ++ * - for enum value-based relocations, string contains an index of enum ++ * value within its enum type; ++ * ++ * Example to provide a better feel. ++ * ++ * struct sample { ++ * int a; ++ * struct { ++ * int b[10]; ++ * }; ++ * }; ++ * ++ * struct sample *s = ...; ++ * int x = &s->a; // encoded as "0:0" (a is field #0) ++ * int y = &s->b[5]; // encoded as "0:1:0:5" (anon struct is field #1, ++ * // b is field #0 inside anon struct, accessing elem #5) ++ * int z = &s[10]->b; // encoded as "10:1" (ptr is used as an array) ++ * ++ * type_id for all relocs in this example will capture BTF type id of ++ * `struct sample`. ++ * ++ * Such relocation is emitted when using __builtin_preserve_access_index() ++ * Clang built-in, passing expression that captures field address, e.g.: ++ * ++ * bpf_probe_read(&dst, sizeof(dst), ++ * __builtin_preserve_access_index(&src->a.b.c)); ++ * ++ * In this case Clang will emit field relocation recording necessary data to ++ * be able to find offset of embedded `a.b.c` field within `src` struct. ++ * ++ * [0] https://llvm.org/docs/LangRef.html#getelementptr-instruction ++ */ ++struct bpf_core_relo { ++ __u32 insn_off; ++ __u32 type_id; ++ __u32 access_str_off; ++ enum bpf_core_relo_kind kind; ++}; ++ + static int btf_ext_setup_core_relos(struct btf_ext *btf_ext) + { + struct btf_ext_sec_setup_param param = { +@@ -597,7 +668,7 @@ int BTF::load(uint8_t *btf_sec, uintptr_t btf_sec_size, + return -1; + } + +- if (btf__load_into_kernel(btf)) { ++ if (btf__load(btf)) { + btf__free(btf); + warning("Loading .BTF section failed\n"); + return -1; +diff --git a/src/cc/libbpf.c b/src/cc/libbpf.c +index e6403299..7410ae1a 100644 +--- a/src/cc/libbpf.c ++++ b/src/cc/libbpf.c +@@ -297,25 +297,6 @@ static uint64_t ptr_to_u64(void *ptr) + return (uint64_t) (unsigned long) ptr; + } + +-static int libbpf_bpf_map_create(struct bpf_create_map_attr *create_attr) +-{ +- LIBBPF_OPTS(bpf_map_create_opts, p); +- +- p.map_flags = create_attr->map_flags; +- p.numa_node = create_attr->numa_node; +- p.btf_fd = create_attr->btf_fd; +- p.btf_key_type_id = create_attr->btf_key_type_id; +- p.btf_value_type_id = create_attr->btf_value_type_id; +- p.map_ifindex = create_attr->map_ifindex; +- if (create_attr->map_type == BPF_MAP_TYPE_STRUCT_OPS) +- p.btf_vmlinux_value_type_id = create_attr->btf_vmlinux_value_type_id; +- else +- p.inner_map_fd = create_attr->inner_map_fd; +- +- return bpf_map_create(create_attr->map_type, create_attr->name, create_attr->key_size, +- create_attr->value_size, create_attr->max_entries, &p); +-} +- + int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit) + { + unsigned name_len = attr->name ? strlen(attr->name) : 0; +@@ -323,7 +304,7 @@ int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit) + + memcpy(map_name, attr->name, min(name_len, BPF_OBJ_NAME_LEN - 1)); + attr->name = map_name; +- int ret = libbpf_bpf_map_create(attr); ++ int ret = bpf_create_map_xattr(attr); + + if (ret < 0 && errno == EPERM) { + if (!allow_rlimit) +@@ -335,7 +316,7 @@ int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit) + rl.rlim_max = RLIM_INFINITY; + rl.rlim_cur = rl.rlim_max; + if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0) +- ret = libbpf_bpf_map_create(attr); ++ ret = bpf_create_map_xattr(attr); + } + } + +@@ -345,12 +326,12 @@ int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit) + attr->btf_fd = 0; + attr->btf_key_type_id = 0; + attr->btf_value_type_id = 0; +- ret = libbpf_bpf_map_create(attr); ++ ret = bpf_create_map_xattr(attr); + } + + if (ret < 0 && name_len && (errno == E2BIG || errno == EINVAL)) { + map_name[0] = '\0'; +- ret = libbpf_bpf_map_create(attr); ++ ret = bpf_create_map_xattr(attr); + } + + if (ret < 0 && errno == EPERM) { +@@ -363,7 +344,7 @@ int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit) + rl.rlim_max = RLIM_INFINITY; + rl.rlim_cur = rl.rlim_max; + if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0) +- ret = libbpf_bpf_map_create(attr); ++ ret = bpf_create_map_xattr(attr); + } + } + return ret; +@@ -627,47 +608,6 @@ int bpf_prog_get_tag(int fd, unsigned long long *ptag) + return 0; + } + +-static int libbpf_bpf_prog_load(const struct bpf_load_program_attr *load_attr, +- char *log_buf, size_t log_buf_sz) +-{ +- LIBBPF_OPTS(bpf_prog_load_opts, p); +- +- if (!load_attr || !log_buf != !log_buf_sz) { +- errno = EINVAL; +- return -EINVAL; +- } +- +- p.expected_attach_type = load_attr->expected_attach_type; +- switch (load_attr->prog_type) { +- case BPF_PROG_TYPE_STRUCT_OPS: +- case BPF_PROG_TYPE_LSM: +- p.attach_btf_id = load_attr->attach_btf_id; +- break; +- case BPF_PROG_TYPE_TRACING: +- case BPF_PROG_TYPE_EXT: +- p.attach_btf_id = load_attr->attach_btf_id; +- p.attach_prog_fd = load_attr->attach_prog_fd; +- break; +- default: +- p.prog_ifindex = load_attr->prog_ifindex; +- p.kern_version = load_attr->kern_version; +- } +- p.log_level = load_attr->log_level; +- p.log_buf = log_buf; +- p.log_size = log_buf_sz; +- p.prog_btf_fd = load_attr->prog_btf_fd; +- p.func_info_rec_size = load_attr->func_info_rec_size; +- p.func_info_cnt = load_attr->func_info_cnt; +- p.func_info = load_attr->func_info; +- p.line_info_rec_size = load_attr->line_info_rec_size; +- p.line_info_cnt = load_attr->line_info_cnt; +- p.line_info = load_attr->line_info; +- p.prog_flags = load_attr->prog_flags; +- +- return bpf_prog_load(load_attr->prog_type, load_attr->name, load_attr->license, +- load_attr->insns, load_attr->insns_cnt, &p); +-} +- + int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len, + char *log_buf, unsigned log_buf_size, bool allow_rlimit) + { +@@ -750,7 +690,7 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len, + attr->name = prog_name; + } + +- ret = libbpf_bpf_prog_load(attr, attr_log_buf, attr_log_buf_size); ++ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size); + + // func_info/line_info may not be supported in old kernels. + if (ret < 0 && attr->func_info && errno == EINVAL) { +@@ -761,14 +701,14 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len, + attr->line_info = NULL; + attr->line_info_cnt = 0; + attr->line_info_rec_size = 0; +- ret = libbpf_bpf_prog_load(attr, attr_log_buf, attr_log_buf_size); ++ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size); + } + + // BPF object name is not supported on older Kernels. + // If we failed due to this, clear the name and try again. + if (ret < 0 && name_len && (errno == E2BIG || errno == EINVAL)) { + prog_name[0] = '\0'; +- ret = libbpf_bpf_prog_load(attr, attr_log_buf, attr_log_buf_size); ++ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size); + } + + if (ret < 0 && errno == EPERM) { +@@ -787,7 +727,7 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len, + rl.rlim_max = RLIM_INFINITY; + rl.rlim_cur = rl.rlim_max; + if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0) +- ret = libbpf_bpf_prog_load(attr, attr_log_buf, attr_log_buf_size); ++ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size); + } + } + +@@ -805,7 +745,7 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len, + // If logging is not already enabled, enable it and do the syscall again. + if (attr->log_level == 0) { + attr->log_level = 1; +- ret = libbpf_bpf_prog_load(attr, log_buf, log_buf_size); ++ ret = bpf_load_program_xattr(attr, log_buf, log_buf_size); + } + // Print the log message and return. + bpf_print_hints(ret, log_buf); +@@ -829,7 +769,7 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len, + goto return_result; + } + tmp_log_buf[0] = 0; +- ret = libbpf_bpf_prog_load(attr, tmp_log_buf, tmp_log_buf_size); ++ ret = bpf_load_program_xattr(attr, tmp_log_buf, tmp_log_buf_size); + if (ret < 0 && errno == ENOSPC) { + // Temporary buffer size is not enough. Double it and try again. + free(tmp_log_buf); +@@ -1369,7 +1309,7 @@ int kernel_struct_has_field(const char *struct_name, const char *field_name) + struct btf *btf; + int i, ret, btf_id; + +- btf = btf__load_vmlinux_btf(); ++ btf = libbpf_find_kernel_btf(); + ret = libbpf_get_error(btf); + if (ret) + return -1; +-- +2.35.3 + diff --git a/SOURCES/bcc-0.24.0-libbpf-Allow-kernel_struct_has_field-to-reach-field-.patch b/SOURCES/bcc-0.24.0-libbpf-Allow-kernel_struct_has_field-to-reach-field-.patch new file mode 100644 index 0000000..9f58ae0 --- /dev/null +++ b/SOURCES/bcc-0.24.0-libbpf-Allow-kernel_struct_has_field-to-reach-field-.patch @@ -0,0 +1,69 @@ +From e9ae2826b8712d491362771233ed6bf21ae1a07a Mon Sep 17 00:00:00 2001 +From: Jerome Marchand +Date: Thu, 19 May 2022 16:37:40 +0200 +Subject: [PATCH 3/3] libbpf: Allow kernel_struct_has_field to reach field in + unnamed struct or union + +Some field can belong to unnamed struct or union. In C, they are +accessed as if their belong directly to the parent struct or union but +this is not the case for BTF. + +When looking for a field, kernel_struct_has_field should also look +reccursively into unnamed structs or unions. +--- + src/cc/libbpf.c | 28 ++++++++++++++++++---------- + 1 file changed, 18 insertions(+), 10 deletions(-) + +diff --git a/src/cc/libbpf.c b/src/cc/libbpf.c +index 7410ae1a..e98b8852 100644 +--- a/src/cc/libbpf.c ++++ b/src/cc/libbpf.c +@@ -1302,12 +1302,27 @@ bool bpf_has_kernel_btf(void) + return true; + } + ++static int find_member_by_name(struct btf *btf, const struct btf_type *btf_type, const char *field_name) { ++ const struct btf_member *btf_member = btf_members(btf_type); ++ int i; ++ ++ for (i = 0; i < btf_vlen(btf_type); i++, btf_member++) { ++ const char *name = btf__name_by_offset(btf, btf_member->name_off); ++ if (!strcmp(name, field_name)) { ++ return 1; ++ } else if (name[0] == '\0') { ++ if (find_member_by_name(btf, btf__type_by_id(btf, btf_member->type), field_name)) ++ return 1; ++ } ++ } ++ return 0; ++} ++ + int kernel_struct_has_field(const char *struct_name, const char *field_name) + { + const struct btf_type *btf_type; +- const struct btf_member *btf_member; + struct btf *btf; +- int i, ret, btf_id; ++ int ret, btf_id; + + btf = libbpf_find_kernel_btf(); + ret = libbpf_get_error(btf); +@@ -1321,14 +1336,7 @@ int kernel_struct_has_field(const char *struct_name, const char *field_name) + } + + btf_type = btf__type_by_id(btf, btf_id); +- btf_member = btf_members(btf_type); +- for (i = 0; i < btf_vlen(btf_type); i++, btf_member++) { +- if (!strcmp(btf__name_by_offset(btf, btf_member->name_off), field_name)) { +- ret = 1; +- goto cleanup; +- } +- } +- ret = 0; ++ ret = find_member_by_name(btf, btf_type, field_name); + + cleanup: + btf__free(btf); +-- +2.35.3 + diff --git a/SPECS/bcc.spec b/SPECS/bcc.spec index 0df2afb..b605ff2 100644 --- a/SPECS/bcc.spec +++ b/SPECS/bcc.spec @@ -8,19 +8,15 @@ %endif Name: bcc -Version: 0.19.0 -Release: 5%{?dist} +Version: 0.24.0 +Release: 2%{?dist} Summary: BPF Compiler Collection (BCC) License: ASL 2.0 URL: https://github.com/iovisor/bcc Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz Patch0: %{name}-%{version}-Manpages-remove-unstable-statement.patch -Patch1: %{name}-%{version}-Fix-BPF-src_file-foo.patch -Patch2: %{name}-%{version}-Define-missing-BPF_-macros.patch -Patch3: %{name}-%{version}-fix-llvm-compilation-errors.patch -Patch4: %{name}-%{version}-Fix-a-llvm-compilation-error.patch -Patch5: %{name}-%{version}-Remove-APInt-APSInt-toString-std-string-variants.patch -Patch6: %{name}-%{version}-Handle-renaming-of-task_struct_-state-field-on-RHEL-.patch +Patch1: %{name}-%{version}-RHEL-libbpf-version-fixes.patch +Patch2: %{name}-%{version}-libbpf-Allow-kernel_struct_has_field-to-reach-field-.patch # Arches will be included as upstream support is added and dependencies are # satisfied in the respective arches @@ -41,9 +37,9 @@ BuildRequires: ncurses-devel %if %{with lua} BuildRequires: pkgconfig(luajit) %endif -BuildRequires: libbpf-devel >= 0.0.9, libbpf-static >= 0.0.9 +BuildRequires: libbpf-devel >= 0.5.0, libbpf-static >= 0.5.0 -Requires: libbpf >= 0.0.9 +Requires: libbpf >= 0.5.0 Requires: tar Recommends: kernel-devel Recommends: %{name}-tools = %{version}-%{release} @@ -100,6 +96,7 @@ Standalone tool to run BCC tracers written in Lua %package tools Summary: Command line tools for BPF Compiler Collection (BCC) +Requires: bcc = %{version}-%{release} Requires: python3-%{name} = %{version}-%{release} Requires: python3-netaddr @@ -217,6 +214,16 @@ done %changelog +* Thu Jun 23 2022 Jerome Marchand - 0.24.0-2 +- Rebuild on libbpf 0.5.0 + +* Thu Jun 09 2022 Jerome Marchand - 0.24.0-1 +- Rebase to bcc-0.24.0 +- Rebuild on LLVM 14 + +* Mon Dec 06 2021 Jerome Marchand - 0.19.0-6 +- Add excplicit requirement in bcc-tools for rpmdiff + * Tue Nov 23 2021 Jerome Marchand - 0.19.0-5 - Handle the renaming of task_struct_>state field - Rebuild for LLVM 13