15de40
From 245cc45ad45f8024c602696f58ae163d0dc745d5 Mon Sep 17 00:00:00 2001
15de40
From: Dominique Martinet <asmadeus@codewreck.org>
15de40
Date: Tue, 11 Oct 2022 22:39:28 +0900
15de40
Subject: [PATCH] update gobpf: fix compatibility with bcc v0.25.0
15de40
15de40
bcc v0.25.0 broke compatibility with bcc_func_load and requires updating
15de40
the gobpf wrapper.
15de40
15de40
Fixes: #100
15de40
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
15de40
---
15de40
 go.mod                                        |  2 +-
15de40
 go.sum                                        |  4 +--
15de40
 vendor/github.com/iovisor/gobpf/bcc/module.go | 25 ++++++++++++++++++-
15de40
 vendor/modules.txt                            |  2 +-
15de40
 4 files changed, 28 insertions(+), 5 deletions(-)
15de40
15de40
diff --git a/vendor/github.com/iovisor/gobpf/bcc/module.go b/vendor/github.com/iovisor/gobpf/bcc/module.go
15de40
index 98a1c93..67d43eb 100644
15de40
--- a/vendor/github.com/iovisor/gobpf/bcc/module.go
15de40
+++ b/vendor/github.com/iovisor/gobpf/bcc/module.go
15de40
@@ -31,6 +31,29 @@ import (
15de40
 #cgo LDFLAGS: -lbcc
15de40
 #include <bcc/bcc_common.h>
15de40
 #include <bcc/libbpf.h>
15de40
+#include <bcc/bcc_version.h>
15de40
+
15de40
+#ifndef LIBBCC_VERSION_GEQ
15de40
+#define LIBBCC_VERSION_GEQ(a, b, c) 0
15de40
+#endif
15de40
+
15de40
+int bcc_func_load_wrapper(void *program, int prog_type, const char *name,
15de40
+						  const struct bpf_insn *insns, int prog_len,
15de40
+						  const char *license, unsigned kern_version,
15de40
+						  int log_level, char *log_buf, unsigned log_buf_size,
15de40
+						  const char *dev_name, int attach_type){
15de40
+
15de40
+#if LIBBCC_VERSION_GEQ(0, 25, 0)
15de40
+    return bcc_func_load(program, prog_type, name, insns, prog_len, license,
15de40
+						 kern_version, log_level, log_buf, log_buf_size,
15de40
+						 dev_name, attach_type);
15de40
+#else
15de40
+    return bcc_func_load(program, prog_type, name, insns, prog_len, license,
15de40
+						 kern_version, log_level, log_buf, log_buf_size,
15de40
+						 dev_name);
15de40
+#endif
15de40
+}
15de40
+
15de40
 */
15de40
 import "C"
15de40
 
15de40
@@ -227,7 +250,7 @@ func (bpf *Module) load(name string, progType int, logLevel, logSize uint) (int,
15de40
 		logBuf = make([]byte, logSize)
15de40
 		logBufP = (*C.char)(unsafe.Pointer(&logBuf[0]))
15de40
 	}
15de40
-	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)
15de40
+	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))
15de40
 	if fd < 0 {
15de40
 		return -1, fmt.Errorf("error loading BPF program: %v", err)
15de40
 	}