Skip to content

Commit 16120a1

Browse files
authored
Merge pull request #311 from chantra/bcc_func_load_attachtype
Bcc func load attachtype for bcc > 0.24.0
2 parents 2289761 + 0e5464f commit 16120a1

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ jobs:
1717
# Use release 9 of llvm etc. - later versions have an unfixed
1818
# bug on Ubuntu:
1919
# https://github.com/iovisor/bcc/issues/2915
20-
sudo apt-get -y install bison build-essential cmake flex git libelf-dev libfl-dev libedit-dev libllvm9 llvm-9-dev libclang-9-dev python zlib1g-dev
20+
sudo apt-get -y install bison build-essential cmake flex git libelf-dev libfl-dev libedit-dev libllvm11 llvm-11-dev libclang-cpp11-dev libclang-common-11-dev libclang1-11 libclang-11-dev python zlib1g-dev
2121
pushd /tmp
22-
git clone --depth 1 --branch v0.20.0 https://github.com/iovisor/bcc.git
22+
git clone --depth 1 --branch v0.25.0 https://github.com/iovisor/bcc.git
2323
mkdir -p bcc/build; cd bcc/build
2424
# Symlink /usr/lib/llvm to avoid "Unable to find clang libraries"
2525
# The directory appears only to be created when installing the
2626
# virtual llvm-dev package.
2727
# https://github.com/iovisor/bcc/issues/492
28-
sudo ln -s /usr/lib/llvm-9 /usr/local/llvm
28+
sudo ln -s /usr/lib/llvm-11 /usr/local/llvm
2929
cmake ..
3030
make
3131
sudo make install

bcc/module.go

+24-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,29 @@ import (
3131
#cgo LDFLAGS: -lbcc
3232
#include <bcc/bcc_common.h>
3333
#include <bcc/libbpf.h>
34+
#include <bcc/bcc_version.h>
35+
36+
#ifndef LIBBCC_VERSION_GEQ
37+
#define LIBBCC_VERSION_GEQ(a, b, c) 0
38+
#endif
39+
40+
int bcc_func_load_wrapper(void *program, int prog_type, const char *name,
41+
const struct bpf_insn *insns, int prog_len,
42+
const char *license, unsigned kern_version,
43+
int log_level, char *log_buf, unsigned log_buf_size,
44+
const char *dev_name, int attach_type){
45+
46+
#if LIBBCC_VERSION_GEQ(0, 25, 0)
47+
return bcc_func_load(program, prog_type, name, insns, prog_len, license,
48+
kern_version, log_level, log_buf, log_buf_size,
49+
dev_name, attach_type);
50+
#else
51+
return bcc_func_load(program, prog_type, name, insns, prog_len, license,
52+
kern_version, log_level, log_buf, log_buf_size,
53+
dev_name);
54+
#endif
55+
}
56+
3457
*/
3558
import "C"
3659

@@ -227,7 +250,7 @@ func (bpf *Module) load(name string, progType int, logLevel, logSize uint) (int,
227250
logBuf = make([]byte, logSize)
228251
logBufP = (*C.char)(unsafe.Pointer(&logBuf[0]))
229252
}
230-
fd, err := C.bcc_func_load(bpf.p, C.int(uint32(progType)), nameCS, start, size, license, version, C.int(logLevel), logBufP, C.uint(len(logBuf)), nil)
253+
fd, err := C.bcc_func_load_wrapper(bpf.p, C.int(uint32(progType)), nameCS, start, size, license, version, C.int(logLevel), logBufP, C.uint(len(logBuf)), nil, C.int(-1))
231254
if fd < 0 {
232255
return -1, fmt.Errorf("error loading BPF program: %v", err)
233256
}

0 commit comments

Comments
 (0)