This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-rover.git


The following commit(s) were added to refs/heads/main by this push:
     new bdd1e6a  Fix load customized BTF not take effect (#114)
bdd1e6a is described below

commit bdd1e6a677f53ba957fcac2003a57872c7c5759a
Author: caiwc <[email protected]>
AuthorDate: Mon Mar 4 14:56:50 2024 +0800

    Fix load customized BTF not take effect (#114)
---
 pkg/tools/btf/ebpf.go | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pkg/tools/btf/ebpf.go b/pkg/tools/btf/ebpf.go
index 16c3d39..71e20f3 100644
--- a/pkg/tools/btf/ebpf.go
+++ b/pkg/tools/btf/ebpf.go
@@ -18,17 +18,17 @@
 package btf
 
 import (
+       "bytes"
        "embed"
        "fmt"
        "path/filepath"
        "sync"
 
+       "github.com/cilium/ebpf"
        "github.com/cilium/ebpf/btf"
 
        "github.com/apache/skywalking-rover/pkg/logger"
        "github.com/apache/skywalking-rover/pkg/tools/operator"
-
-       "github.com/cilium/ebpf"
 )
 
 //go:embed *
@@ -73,10 +73,14 @@ func getKernelBTFAddress() (spec *btf.Spec, err error) {
 
        path := fmt.Sprintf("files/%s/%s/%s/%s.btf", distributeInfo.Name, 
distributeInfo.Version,
                distributeInfo.Architecture, uname.Release)
-       _, err = asset(path)
+       bpfObjBuff, err := asset(path)
        if err != nil {
                return nil, fmt.Errorf("could not found customized BTF file: 
%s", path)
        }
+       spec, err = btf.LoadSpecFromReader(bytes.NewReader(bpfObjBuff))
+       if err != nil {
+               return nil, fmt.Errorf("could not load customized BTF file: 
%s", path)
+       }
        return spec, nil
 }
 

Reply via email to