Skip to content

Commit

Permalink
Fix load customized BTF not take effect (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
caiwc authored Mar 4, 2024
1 parent 6bbd39a commit bdd1e6a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/tools/btf/ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit bdd1e6a

Please sign in to comment.