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

liuhan 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 e0b9db7  Upgrade Go and eBPF library (#65)
e0b9db7 is described below

commit e0b9db7a305d4b6fdc88bfe16511c24f76fa1af5
Author: mrproliu <[email protected]>
AuthorDate: Tue Dec 6 11:12:56 2022 +0800

    Upgrade Go and eBPF library (#65)
---
 .github/workflows/rover.yaml                       |  4 +-
 CHANGES.md                                         |  1 +
 docker/Dockerfile.base                             |  2 +-
 docs/en/guides/compile/how-to-compile.md           |  2 +-
 go.mod                                             |  6 +--
 go.sum                                             | 17 ++-------
 pkg/config/config.go                               |  8 ++--
 pkg/config/env_override.go                         | 12 ++----
 pkg/config/env_override_test.go                    |  7 +---
 pkg/core/backend/client.go                         |  3 +-
 pkg/process/finders/kubernetes/registry.go         |  3 +-
 pkg/process/finders/scanner/finder.go              |  2 +-
 pkg/profiling/task/base/config.go                  |  5 ++-
 .../task/network/analyze/base/tcpresolver.go       |  3 +-
 .../analyze/layer7/protocols/http1/builder.go      |  4 +-
 .../analyze/layer7/protocols/http1/metrics.go      |  4 +-
 pkg/profiling/task/network/bpf/bpf.go              |  2 +-
 pkg/profiling/task/network/bpf/linker.go           | 42 ++++++++++-----------
 pkg/profiling/task/offcpu/runner.go                |  6 +--
 pkg/profiling/task/oncpu/runner.go                 |  4 +-
 pkg/tools/btf/ebpf.go                              | 43 ++++++++--------------
 pkg/tools/elf/elf.go                               |  2 +-
 scripts/build/lint.mk                              |  2 +-
 test/e2e/cases/profiling/offcpu/golang/file.go     |  2 +-
 24 files changed, 78 insertions(+), 108 deletions(-)

diff --git a/.github/workflows/rover.yaml b/.github/workflows/rover.yaml
index e43c120..ce0fdbe 100644
--- a/.github/workflows/rover.yaml
+++ b/.github/workflows/rover.yaml
@@ -25,10 +25,10 @@ jobs:
     runs-on: ubuntu-latest
     timeout-minutes: 30
     steps:
-      - name: Set up Go 1.17
+      - name: Set up Go 1.18
         uses: actions/setup-go@v2
         with:
-          go-version: 1.17
+          go-version: 1.18
       - name: Check out code into the Go module directory
         uses: actions/checkout@v2
         with:
diff --git a/CHANGES.md b/CHANGES.md
index a19d9e1..073d815 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,7 @@ Release Notes.
 #### Features
 * Enhancing the render context for the Kubernetes process.
 * Simplify the logic of network protocol analysis.
+* Upgrade Go library to `1.18`, eBPF library to `0.9.3`.
 
 #### Bug Fixes
 
diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base
index e2f0e3f..759c17e 100644
--- a/docker/Dockerfile.base
+++ b/docker/Dockerfile.base
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-FROM golang:1.17
+FROM golang:1.18
 
 RUN apt update && \
     git clone --depth 1 --branch v0.8.0 https://github.com/libbpf/libbpf.git 
&& \
diff --git a/docs/en/guides/compile/how-to-compile.md 
b/docs/en/guides/compile/how-to-compile.md
index f9aee78..a92c822 100644
--- a/docs/en/guides/compile/how-to-compile.md
+++ b/docs/en/guides/compile/how-to-compile.md
@@ -2,7 +2,7 @@
 
 ## Go version
 
-Go version `1.17` or higher is supported for compilation.
+Go version `1.18` or higher is supported for compilation.
 
 ## Platform
 
diff --git a/go.mod b/go.mod
index 82974a6..386e71b 100644
--- a/go.mod
+++ b/go.mod
@@ -1,9 +1,9 @@
 module github.com/apache/skywalking-rover
 
-go 1.17
+go 1.18
 
 require (
-       github.com/cilium/ebpf v0.8.1
+       github.com/cilium/ebpf v0.9.3
        github.com/docker/go-units v0.5.0
        github.com/google/uuid v1.3.0
        github.com/hashicorp/go-multierror v1.1.1
@@ -17,7 +17,7 @@ require (
        github.com/zekroTJA/timedmap v1.4.0
        golang.org/x/arch v0.0.0-20220722155209-00200b7164a7
        golang.org/x/net v0.0.0-20220722155237-a158d28d115b
-       golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab
+       golang.org/x/sys v0.3.0
        google.golang.org/grpc v1.44.0
        k8s.io/api v0.23.5
        k8s.io/apimachinery v0.23.5
diff --git a/go.sum b/go.sum
index 5d1bff8..05c1c9b 100644
--- a/go.sum
+++ b/go.sum
@@ -83,8 +83,8 @@ github.com/cespare/xxhash/v2 v2.1.2/go.mod 
h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
 github.com/chzyer/logex v1.1.10/go.mod 
h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
 github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod 
h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
 github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod 
h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
-github.com/cilium/ebpf v0.8.1 h1:bLSSEbBLqGPXxls55pGr5qWZaTqcmfDJHhou7t254ao=
-github.com/cilium/ebpf v0.8.1/go.mod 
h1:f5zLIM0FSNuAkSyLAN7X+Hy6yznlF1mNiWUMfxMtrgk=
+github.com/cilium/ebpf v0.9.3 h1:5KtxXZU+scyERvkJMEm16TbScVvuuMrlhPly78ZMbSc=
+github.com/cilium/ebpf v0.9.3/go.mod 
h1:w27N4UjpaQ9X/DGrSugxUG+H+NhgntDuPb5lCzxCn8A=
 github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod 
h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
 github.com/circonus-labs/circonusllhist v0.1.3/go.mod 
h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
 github.com/client9/misspell v0.3.4/go.mod 
h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
@@ -128,7 +128,6 @@ github.com/fatih/color v1.13.0/go.mod 
h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYF
 github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod 
h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
 github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod 
h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
 github.com/frankban/quicktest v1.14.0 
h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss=
-github.com/frankban/quicktest v1.14.0/go.mod 
h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og=
 github.com/fsnotify/fsnotify v1.4.7/go.mod 
h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
 github.com/fsnotify/fsnotify v1.4.9/go.mod 
h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
 github.com/fsnotify/fsnotify v1.5.1 
h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
@@ -243,7 +242,6 @@ github.com/gorilla/websocket v1.4.2/go.mod 
h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
 github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod 
h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod 
h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
 github.com/hashicorp/consul/api v1.11.0/go.mod 
h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M=
-github.com/hashicorp/consul/api v1.12.0/go.mod 
h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0=
 github.com/hashicorp/consul/sdk v0.8.0/go.mod 
h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms=
 github.com/hashicorp/errwrap v1.0.0 
h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
 github.com/hashicorp/errwrap v1.0.0/go.mod 
h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@@ -302,7 +300,6 @@ github.com/kr/logfmt 
v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB
 github.com/kr/pretty v0.1.0/go.mod 
h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 github.com/kr/pretty v0.2.0/go.mod 
h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
 github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
-github.com/kr/pretty v0.3.0/go.mod 
h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
 github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
 github.com/kr/text v0.1.0/go.mod 
h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -388,11 +385,9 @@ github.com/prometheus/procfs v0.0.8/go.mod 
h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx
 github.com/rogpeppe/fastuuid v1.2.0/go.mod 
h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
 github.com/rogpeppe/go-internal v1.3.0/go.mod 
h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
 github.com/rogpeppe/go-internal v1.6.1 
h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
-github.com/rogpeppe/go-internal v1.6.1/go.mod 
h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
 github.com/russross/blackfriday/v2 v2.1.0/go.mod 
h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod 
h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
 github.com/sagikazarmark/crypt v0.3.0/go.mod 
h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig=
-github.com/sagikazarmark/crypt v0.4.0/go.mod 
h1:ALv2SRj7GxYV4HO9elxH9nS6M9gW+xDNxqmyJ6RfDFM=
 github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod 
h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
 github.com/shirou/gopsutil v3.21.11+incompatible 
h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
 github.com/shirou/gopsutil v3.21.11+incompatible/go.mod 
h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
@@ -650,16 +645,15 @@ golang.org/x/sys 
v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab 
h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
+golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod 
h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod 
h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 
h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
@@ -771,7 +765,6 @@ google.golang.org/api v0.57.0/go.mod 
h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdr
 google.golang.org/api v0.59.0/go.mod 
h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU=
 google.golang.org/api v0.61.0/go.mod 
h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I=
 google.golang.org/api v0.62.0/go.mod 
h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw=
-google.golang.org/api v0.63.0/go.mod 
h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo=
 google.golang.org/appengine v1.1.0/go.mod 
h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
 google.golang.org/appengine v1.4.0/go.mod 
h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
 google.golang.org/appengine v1.5.0/go.mod 
h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
@@ -872,7 +865,6 @@ google.golang.org/grpc v1.39.1/go.mod 
h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnD
 google.golang.org/grpc v1.40.0/go.mod 
h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
 google.golang.org/grpc v1.40.1/go.mod 
h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
 google.golang.org/grpc v1.42.0/go.mod 
h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
-google.golang.org/grpc v1.43.0/go.mod 
h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
 google.golang.org/grpc v1.44.0 h1:weqSxi/TMs1SqFRMHCtBgXRs8k3X39QIDEZ0pRcttUg=
 google.golang.org/grpc v1.44.0/go.mod 
h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
 google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod 
h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
@@ -942,7 +934,6 @@ k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod 
h1:jPW/WVKK9YHAvNhRxK0md/
 k8s.io/utils v0.0.0-20211116205334-6203023598ed 
h1:ck1fRPWPJWsMd8ZRFsWc6mh/zHp5fZ/shhbrgPUxDAE=
 k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod 
h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
 rsc.io/binaryregexp v0.2.0/go.mod 
h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
-rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
 rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
 rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
 sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 
h1:fD1pz4yfdADVNfFmcP2aBEtudwUQ1AlLnRBALr33v3s=
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 65d0205..3514f9a 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -19,7 +19,7 @@ package config
 
 import (
        "bytes"
-       "io/ioutil"
+       "os"
        "path/filepath"
 
        "github.com/spf13/viper"
@@ -35,7 +35,7 @@ func Load(file string) (*Config, error) {
        if err != nil {
                return nil, err
        }
-       content, err := ioutil.ReadFile(absolutePath)
+       content, err := os.ReadFile(absolutePath)
        if err != nil {
                return nil, err
        }
@@ -46,9 +46,7 @@ func Load(file string) (*Config, error) {
        }
 
        // env replace
-       if err := overrideEnv(v); err != nil {
-               return nil, err
-       }
+       overrideEnv(v)
 
        return &Config{conf: v}, nil
 }
diff --git a/pkg/config/env_override.go b/pkg/config/env_override.go
index be8a925..e64b973 100644
--- a/pkg/config/env_override.go
+++ b/pkg/config/env_override.go
@@ -24,19 +24,13 @@ import (
        "github.com/spf13/viper"
 )
 
-const EnvRegularExpression = "\\${(?P<ENV>[_A-Z0-9]+):(?P<DEF>.*)}"
-
-func overrideEnv(v *viper.Viper) error {
-       envRegex, err := regexp.Compile(EnvRegularExpression)
-       if err != nil {
-               return err
-       }
+var EnvRegularRegex = regexp.MustCompile(`\${(?P<ENV>[_A-Z0-9]+):(?P<DEF>.*)}`)
 
+func overrideEnv(v *viper.Viper) {
        keys := v.AllKeys()
        for _, key := range keys {
-               overrideConfig(v, key, envRegex)
+               overrideConfig(v, key, EnvRegularRegex)
        }
-       return nil
 }
 
 func overrideConfig(v *viper.Viper, key string, envRegex *regexp.Regexp) {
diff --git a/pkg/config/env_override_test.go b/pkg/config/env_override_test.go
index df8a79d..cedc256 100644
--- a/pkg/config/env_override_test.go
+++ b/pkg/config/env_override_test.go
@@ -19,7 +19,6 @@ package config
 
 import (
        "bytes"
-       "io/ioutil"
        "os"
        "reflect"
        "testing"
@@ -93,7 +92,7 @@ func TestOverrideEnv(t *testing.T) {
                        // load config
                        v := viper.New()
                        v.SetConfigType("yaml")
-                       content, err := ioutil.ReadFile(tt.file)
+                       content, err := os.ReadFile(tt.file)
                        if err != nil {
                                t.Fatalf("read config file error: %v", err)
                        }
@@ -102,9 +101,7 @@ func TestOverrideEnv(t *testing.T) {
                        }
 
                        // environment override
-                       if err := overrideEnv(v); err != nil {
-                               t.Fatalf("override environment failure: %v", 
err)
-                       }
+                       overrideEnv(v)
 
                        // verify result
                        realSettings := v.AllSettings()
diff --git a/pkg/core/backend/client.go b/pkg/core/backend/client.go
index 2890413..993071b 100644
--- a/pkg/core/backend/client.go
+++ b/pkg/core/backend/client.go
@@ -22,7 +22,6 @@ import (
        "crypto/tls"
        "crypto/x509"
        "fmt"
-       "io/ioutil"
        "os"
 
        "google.golang.org/grpc"
@@ -123,7 +122,7 @@ func configTLS(conf *Config) (tc *tls.Config, tlsErr error) 
{
        tlsConfig := new(tls.Config)
        tlsConfig.Renegotiation = tls.RenegotiateNever
        tlsConfig.InsecureSkipVerify = conf.InsecureSkipVerify
-       caPem, err := ioutil.ReadFile(conf.CaPemPath)
+       caPem, err := os.ReadFile(conf.CaPemPath)
        if err != nil {
                return nil, err
        }
diff --git a/pkg/process/finders/kubernetes/registry.go 
b/pkg/process/finders/kubernetes/registry.go
index eaaa0f0..52169aa 100644
--- a/pkg/process/finders/kubernetes/registry.go
+++ b/pkg/process/finders/kubernetes/registry.go
@@ -18,7 +18,6 @@
 package kubernetes
 
 import (
-       "strings"
        "time"
 
        "k8s.io/apimachinery/pkg/labels"
@@ -128,7 +127,7 @@ func chooseServiceName(a, b string) string {
                return b
        }
        // ascii compare
-       if strings.Compare(a, b) < 0 {
+       if a < b {
                return a
        }
        return b
diff --git a/pkg/process/finders/scanner/finder.go 
b/pkg/process/finders/scanner/finder.go
index 758171c..81648d0 100644
--- a/pkg/process/finders/scanner/finder.go
+++ b/pkg/process/finders/scanner/finder.go
@@ -234,7 +234,7 @@ func (p *ProcessFinder) agentFindProcesses() 
([]base.DetectedProcess, error) {
 
                // modify time + recent > now
                // means the metadata file is acceptable
-               if 
!metadataFile.ModTime().Add(p.conf.Agent.ProcessStatusRefreshPeriodDuration).After(time.Now())
 {
+               if 
metadataFile.ModTime().Add(p.conf.Agent.ProcessStatusRefreshPeriodDuration).Before(time.Now())
 {
                        continue
                }
 
diff --git a/pkg/profiling/task/base/config.go 
b/pkg/profiling/task/base/config.go
index 2b89e0d..e8c83a4 100644
--- a/pkg/profiling/task/base/config.go
+++ b/pkg/profiling/task/base/config.go
@@ -18,6 +18,7 @@
 package base
 
 import (
+       "errors"
        "fmt"
        "time"
 
@@ -89,7 +90,7 @@ func (c *TaskConfig) stringNotEmpty(err error, value, message 
string) error {
                return err
        }
        if value == "" {
-               return fmt.Errorf(message)
+               return errors.New(message)
        }
        return nil
 }
@@ -99,7 +100,7 @@ func (c *TaskConfig) biggerThan(err error, value, needs int, 
message string) err
                return err
        }
        if value <= needs {
-               return fmt.Errorf(message)
+               return errors.New(message)
        }
        return nil
 }
diff --git a/pkg/profiling/task/network/analyze/base/tcpresolver.go 
b/pkg/profiling/task/network/analyze/base/tcpresolver.go
index dc27cd8..2af0e6e 100644
--- a/pkg/profiling/task/network/analyze/base/tcpresolver.go
+++ b/pkg/profiling/task/network/analyze/base/tcpresolver.go
@@ -20,7 +20,6 @@ package base
 import (
        "encoding/binary"
        "fmt"
-       "io/ioutil"
        "net"
        "os"
        "regexp"
@@ -66,7 +65,7 @@ func foundAddressByFile(s *SocketPair, exitedError error, 
filename, inode string
        if s != nil {
                return s, nil
        }
-       data, err := ioutil.ReadFile(filename)
+       data, err := os.ReadFile(filename)
        if err != nil {
                return nil, multierror.Append(exitedError, err)
        }
diff --git 
a/pkg/profiling/task/network/analyze/layer7/protocols/http1/builder.go 
b/pkg/profiling/task/network/analyze/layer7/protocols/http1/builder.go
index 733919b..a55ae5f 100644
--- a/pkg/profiling/task/network/analyze/layer7/protocols/http1/builder.go
+++ b/pkg/profiling/task/network/analyze/layer7/protocols/http1/builder.go
@@ -81,7 +81,7 @@ func (h *BufferAnalyzer) handleUnknown(event *list.List, 
element *list.Element,
        if curEvent.MsgType != base.SocketMessageTypeUnknown {
                return false, nil, nil
        }
-       if h.unknownEventBuffer == nil {
+       if h.unknownEventBuffer == base2.SocketDataBuffer(nil) {
                // maybe the unknown type is response, so clean the context
                if !curEvent.IsStart() {
                        h.cleanContext()
@@ -206,7 +206,7 @@ func (h *BufferAnalyzer) resetStartResponse(element 
*list.Element, curEvent *bas
 }
 
 func (h *BufferAnalyzer) tryingToAnalyzeTheUnknown(events *list.List, curEvent 
*base2.SocketDataUploadEvent) (req, resp base2.SocketDataBuffer) {
-       if h.unknownEventBuffer == nil {
+       if h.unknownEventBuffer == base2.SocketDataBuffer(nil) {
                return nil, nil
        }
        // length not enough
diff --git 
a/pkg/profiling/task/network/analyze/layer7/protocols/http1/metrics.go 
b/pkg/profiling/task/network/analyze/layer7/protocols/http1/metrics.go
index 334dcea..5756206 100644
--- a/pkg/profiling/task/network/analyze/layer7/protocols/http1/metrics.go
+++ b/pkg/profiling/task/network/analyze/layer7/protocols/http1/metrics.go
@@ -119,7 +119,9 @@ func (u *URIMetrics) appendMetrics(traffic 
*base.ProcessTraffic,
 
        collections = u.buildMetrics(collections, prefix, "request_counter", 
labels, url, traffic, u.RequestCounter)
        for status, counter := range u.StatusCounter {
-               statusLabels := append(labels, &v3.Label{Name: "code", Value: 
fmt.Sprintf("%d", status)})
+               statusLabels := make([]*v3.Label, len(labels))
+               copy(statusLabels, labels)
+               statusLabels = append(statusLabels, &v3.Label{Name: "code", 
Value: fmt.Sprintf("%d", status)})
                collections = u.buildMetrics(collections, prefix, 
"response_status_counter", statusLabels, url, traffic, counter)
        }
 
diff --git a/pkg/profiling/task/network/bpf/bpf.go 
b/pkg/profiling/task/network/bpf/bpf.go
index 2181f09..4544176 100644
--- a/pkg/profiling/task/network/bpf/bpf.go
+++ b/pkg/profiling/task/network/bpf/bpf.go
@@ -25,7 +25,7 @@ import (
 
 // $BPF_CLANG and $BPF_CFLAGS are set by the Makefile.
 // nolint
-//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target bpfel -cc 
$BPF_CLANG -cflags $BPF_CFLAGS bpf 
$REPO_ROOT/bpf/profiling/network/netmonitor.c -- -I$REPO_ROOT/bpf/include 
-D__TARGET_ARCH_x86
+//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -no-global-types 
-target bpfel -cc $BPF_CLANG -cflags $BPF_CFLAGS bpf 
$REPO_ROOT/bpf/profiling/network/netmonitor.c -- -I$REPO_ROOT/bpf/include 
-D__TARGET_ARCH_x86
 
 type Loader struct {
        *Linker
diff --git a/pkg/profiling/task/network/bpf/linker.go 
b/pkg/profiling/task/network/bpf/linker.go
index e406fdf..b1969a9 100644
--- a/pkg/profiling/task/network/bpf/linker.go
+++ b/pkg/profiling/task/network/bpf/linker.go
@@ -43,7 +43,7 @@ var log = logger.GetLogger("profiling", "task", "network", 
"bpf")
 
 const defaultSymbolPrefix = "sys_"
 
-type LinkFunc func(symbol string, prog *ebpf.Program) (link.Link, error)
+type LinkFunc func(symbol string, prog *ebpf.Program, opts 
*link.KprobeOptions) (link.Link, error)
 type RingBufferReader func(data interface{})
 
 var syscallPrefix string
@@ -103,7 +103,7 @@ func (m *Linker) AddLink(linkF LinkFunc, p *ebpf.Program, 
trySymbolNames ...stri
        var err error
        var realSym string
        for _, n := range trySymbolNames {
-               lk, err = linkF(n, p)
+               lk, err = linkF(n, p, nil)
                if err == nil {
                        realSym = n
                        break
@@ -123,7 +123,7 @@ func (m *Linker) AddSysCall(call string, enter, exit 
*ebpf.Program) {
 }
 
 func (m *Linker) AddSysCallWithKProbe(call string, linkK LinkFunc, p 
*ebpf.Program) {
-       kprobe, err := linkK(syscallPrefix+call, p)
+       kprobe, err := linkK(syscallPrefix+call, p, nil)
 
        if err != nil {
                m.errors = multierror.Append(m.errors, fmt.Errorf("could not 
attach syscall with %s: %v", "sys_"+call, err))
@@ -134,7 +134,7 @@ func (m *Linker) AddSysCallWithKProbe(call string, linkK 
LinkFunc, p *ebpf.Progr
 }
 
 func (m *Linker) AddTracePoint(sys, name string, p *ebpf.Program) {
-       l, e := link.Tracepoint(sys, name, p)
+       l, e := link.Tracepoint(sys, name, p, nil)
        if e != nil {
                m.errors = multierror.Append(m.errors, fmt.Errorf("open %s 
error: %v", name, e))
        } else {
@@ -229,9 +229,9 @@ func (u *UProbeExeFile) AddLinkWithType(symbol string, 
enter bool, p *ebpf.Progr
        }
 }
 
-func (u *UProbeExeFile) addLinkWithType0(symbol string, enter bool, p 
*ebpf.Program, customizeOffset uint64) (link.Link, error) {
+func (u *UProbeExeFile) addLinkWithType0(symbol string, enter bool, p 
*ebpf.Program, customizeAddress uint64) (link.Link, error) {
        // check already linked
-       uprobeIdentity := fmt.Sprintf("%s_%s_%t_%d", u.addr, symbol, enter, 
customizeOffset)
+       uprobeIdentity := fmt.Sprintf("%s_%s_%t_%d", u.addr, symbol, enter, 
customizeAddress)
        if u.linker.linkedUProbes[uprobeIdentity] {
                log.Debugf("the uprobe already attached, so ignored. file: %s, 
symbol: %s, type: %s", u.addr, symbol,
                        u.parseEnterOrExitString(enter))
@@ -247,9 +247,9 @@ func (u *UProbeExeFile) addLinkWithType0(symbol string, 
enter bool, p *ebpf.Prog
        }
 
        var opts *link.UprobeOptions
-       if customizeOffset > 0 {
+       if customizeAddress > 0 {
                opts = &link.UprobeOptions{
-                       Offset: customizeOffset,
+                       Address: customizeAddress,
                }
        }
        return fun(symbol, p, opts)
@@ -287,16 +287,16 @@ func (u *UProbeExeFile) addGoExitLink0(symbol string, p 
*ebpf.Program, elfFile *
                return nil, fmt.Errorf("reading symbol data error: %v", err)
        }
 
-       // find the base offset
-       targetBaseOffset := 
elfFile.FindBaseOffsetForAttach(targetSymbol.Location)
-       if targetBaseOffset == 0 {
-               return nil, fmt.Errorf("could not found the symbol base 
address")
+       // find the base addresses
+       targetBaseAddress := 
elfFile.FindBaseAddressForAttach(targetSymbol.Location)
+       if targetBaseAddress == 0 {
+               return nil, fmt.Errorf("could not found the symbol base 
addresses")
        }
 
-       // based on the base offset and symbol data buffer
+       // based on the base addresses and symbol data buffer
        // calculate all RET addresses
        // https://github.com/iovisor/bcc/issues/1320#issuecomment-407927542
-       var offsets []uint64
+       var addresses []uint64
        for i := 0; i < int(targetSymbol.Size); {
                inst, err := x86asm.Decode(buffer[i:], 64)
                if err != nil {
@@ -304,25 +304,25 @@ func (u *UProbeExeFile) addGoExitLink0(symbol string, p 
*ebpf.Program, elfFile *
                }
 
                if inst.Op == x86asm.RET {
-                       offsets = append(offsets, targetBaseOffset+uint64(i))
+                       addresses = append(addresses, 
targetBaseAddress+uint64(i))
                }
 
                i += inst.Len
        }
 
-       if len(offsets) == 0 {
-               return nil, fmt.Errorf("could not found any return offsets")
+       if len(addresses) == 0 {
+               return nil, fmt.Errorf("could not found any return addresses")
        }
-       log.Debugf("found reuturn offsets of the symbol, symbol: %s, size: %d", 
symbol, len(offsets))
+       log.Debugf("found reuturn addresses of the symbol, symbol: %s, size: 
%d", symbol, len(addresses))
 
        var result []link.Link
-       for _, offset := range offsets {
-               l, err := u.addLinkWithType0(symbol, true, p, offset)
+       for _, address := range addresses {
+               l, err := u.addLinkWithType0(symbol, true, p, address)
                if err != nil {
                        return nil, err
                }
                result = append(result, l)
-               log.Debugf("attach to the return probe of the go program, 
symbol: %s, offset: %d", symbol, offset)
+               log.Debugf("attach to the return probe of the go program, 
symbol: %s, addresses: %d", symbol, address)
        }
        return result, nil
 }
diff --git a/pkg/profiling/task/offcpu/runner.go 
b/pkg/profiling/task/offcpu/runner.go
index 938b579..85a8f9b 100644
--- a/pkg/profiling/task/offcpu/runner.go
+++ b/pkg/profiling/task/offcpu/runner.go
@@ -41,7 +41,7 @@ import (
 
 // $BPF_CLANG and $BPF_CFLAGS are set by the Makefile.
 // nolint
-//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target bpfel -cc 
$BPF_CLANG -cflags $BPF_CFLAGS bpf $REPO_ROOT/bpf/profiling/offcpu.c -- 
-I$REPO_ROOT/bpf/include -D__TARGET_ARCH_x86
+//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -no-global-types 
-target bpfel -cc $BPF_CLANG -cflags $BPF_CFLAGS bpf 
$REPO_ROOT/bpf/profiling/offcpu.c -- -I$REPO_ROOT/bpf/include 
-D__TARGET_ARCH_x86
 
 var log = logger.GetLogger("profiling", "task", "offcpu")
 
@@ -102,7 +102,7 @@ func (r *Runner) Run(ctx context.Context, notify 
base.ProfilingRunningSuccessNot
        funcName := "do_finish_task_switch"
        replacedPid := false
        for i, ins := range spec.Programs[funcName].Instructions {
-               if ins.Reference == "MONITOR_PID" {
+               if ins.Reference() == "MONITOR_PID" {
                        spec.Programs[funcName].Instructions[i].Constant = 
int64(r.pid)
                        spec.Programs[funcName].Instructions[i].Offset = 0
                        replacedPid = true
@@ -116,7 +116,7 @@ func (r *Runner) Run(ctx context.Context, notify 
base.ProfilingRunningSuccessNot
        }
        r.bpf = &objs
 
-       kprobe, err := link.Kprobe("finish_task_switch", 
objs.DoFinishTaskSwitch)
+       kprobe, err := link.Kprobe("finish_task_switch", 
objs.DoFinishTaskSwitch, nil)
        if err != nil {
                return fmt.Errorf("link to finish task swtich failure: %v", err)
        }
diff --git a/pkg/profiling/task/oncpu/runner.go 
b/pkg/profiling/task/oncpu/runner.go
index 8ada923..d55ea1c 100644
--- a/pkg/profiling/task/oncpu/runner.go
+++ b/pkg/profiling/task/oncpu/runner.go
@@ -41,7 +41,7 @@ import (
 
 // $BPF_CLANG and $BPF_CFLAGS are set by the Makefile.
 // nolint
-//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -target bpfel -cc 
$BPF_CLANG -cflags $BPF_CFLAGS bpf $REPO_ROOT/bpf/profiling/oncpu.c -- 
-I$REPO_ROOT/bpf/include
+//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -no-global-types 
-target bpfel -cc $BPF_CLANG -cflags $BPF_CFLAGS bpf 
$REPO_ROOT/bpf/profiling/oncpu.c -- -I$REPO_ROOT/bpf/include
 
 var log = logger.GetLogger("profiling", "task", "oncpu")
 
@@ -114,7 +114,7 @@ func (r *Runner) Run(ctx context.Context, notify 
base.ProfilingRunningSuccessNot
        funcName := "do_perf_event"
        replacedPid := false
        for i, ins := range spec.Programs[funcName].Instructions {
-               if ins.Reference == "MONITOR_PID" {
+               if ins.Reference() == "MONITOR_PID" {
                        spec.Programs[funcName].Instructions[i].Constant = 
int64(r.pid)
                        spec.Programs[funcName].Instructions[i].Offset = 0
                        replacedPid = true
diff --git a/pkg/tools/btf/ebpf.go b/pkg/tools/btf/ebpf.go
index f44e7d6..16c3d39 100644
--- a/pkg/tools/btf/ebpf.go
+++ b/pkg/tools/btf/ebpf.go
@@ -18,12 +18,13 @@
 package btf
 
 import (
-       "bytes"
        "embed"
        "fmt"
        "path/filepath"
        "sync"
 
+       "github.com/cilium/ebpf/btf"
+
        "github.com/apache/skywalking-rover/pkg/logger"
        "github.com/apache/skywalking-rover/pkg/tools/operator"
 
@@ -34,61 +35,49 @@ import (
 var assets embed.FS
 
 var (
-       customizedBTFData []byte
-       findBTFOnce       sync.Once
+       spec        *btf.Spec
+       findBTFOnce sync.Once
 
        log = logger.GetLogger("tools", "btf")
 )
 
 func GetEBPFCollectionOptionsIfNeed() *ebpf.CollectionOptions {
        findBTFOnce.Do(func() {
-               btfPath, isCustomizedBTF, err := getKernelBTFAddress()
+               readSpec, err := getKernelBTFAddress()
                if err != nil {
                        log.Warnf("found BTF failure: %v", err)
                        return
                }
 
-               if !isCustomizedBTF {
-                       return
-               }
-               d, err := asset(btfPath)
-               if err != nil {
-                       log.Warnf("could not found the customized BTF file: 
%s", btfPath)
-                       return
-               }
-               customizedBTFData = d
+               spec = readSpec
        })
 
-       if customizedBTFData == nil {
-               return nil
-       }
-
-       return &ebpf.CollectionOptions{Programs: ebpf.ProgramOptions{TargetBTF: 
bytes.NewReader(customizedBTFData)}}
+       return &ebpf.CollectionOptions{Programs: 
ebpf.ProgramOptions{KernelTypes: spec}}
 }
 
 // getKernelBTFAddress means get the kernel BTF file path
-func getKernelBTFAddress() (btfPath string, isCustomizedBTF bool, err error) {
-       path, err := ExistKernelBTF()
+func getKernelBTFAddress() (spec *btf.Spec, err error) {
+       spec, err = btf.LoadKernelSpec()
        if err == nil {
-               return path, false, nil
+               return spec, nil
        }
 
        distributeInfo, err := operator.GetDistributionInfo()
        if err != nil {
-               return "", false, fmt.Errorf("could not load the system 
distribute info: %v", err)
+               return nil, fmt.Errorf("could not load the system distribute 
info: %v", err)
        }
        uname, err := operator.GetOSUname()
        if err != nil {
-               return "", false, fmt.Errorf("could not load the uname info: 
%v", err)
+               return nil, fmt.Errorf("could not load the uname info: %v", err)
        }
 
-       btfPath = fmt.Sprintf("files/%s/%s/%s/%s.btf", distributeInfo.Name, 
distributeInfo.Version,
+       path := fmt.Sprintf("files/%s/%s/%s/%s.btf", distributeInfo.Name, 
distributeInfo.Version,
                distributeInfo.Architecture, uname.Release)
-       _, err = asset(btfPath)
+       _, err = asset(path)
        if err != nil {
-               return "", true, fmt.Errorf("could not found customized BTF 
file: %s", btfPath)
+               return nil, fmt.Errorf("could not found customized BTF file: 
%s", path)
        }
-       return btfPath, true, nil
+       return spec, nil
 }
 
 func asset(file string) ([]byte, error) {
diff --git a/pkg/tools/elf/elf.go b/pkg/tools/elf/elf.go
index 57ece5d..b6fd466 100644
--- a/pkg/tools/elf/elf.go
+++ b/pkg/tools/elf/elf.go
@@ -93,7 +93,7 @@ func (f *File) ReadSymbolData(section string, offset, size 
uint64) ([]byte, erro
        return buffer, nil
 }
 
-func (f *File) FindBaseOffsetForAttach(symbolLocation uint64) uint64 {
+func (f *File) FindBaseAddressForAttach(symbolLocation uint64) uint64 {
        for _, prog := range f.realFile.Progs {
                if prog.Type != elf.PT_LOAD || (prog.Flags&elf.PF_X) == 0 {
                        continue
diff --git a/scripts/build/lint.mk b/scripts/build/lint.mk
index 12f2324..0f65588 100644
--- a/scripts/build/lint.mk
+++ b/scripts/build/lint.mk
@@ -19,7 +19,7 @@
 GO_LINT = $(GO_PATH)/bin/golangci-lint
 
 linter:
-       $(GO_LINT) version || curl -sfL 
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh 
-s -- -b $(GO_PATH)/bin v1.39.0
+       $(GO_LINT) version || curl -sfL 
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh 
-s -- -b $(GO_PATH)/bin v1.50.0
 
 .PHONY: lint
 lint: linter generate
diff --git a/test/e2e/cases/profiling/offcpu/golang/file.go 
b/test/e2e/cases/profiling/offcpu/golang/file.go
index 128f183..f7255b1 100644
--- a/test/e2e/cases/profiling/offcpu/golang/file.go
+++ b/test/e2e/cases/profiling/offcpu/golang/file.go
@@ -24,7 +24,7 @@ import (
 func main() {
        d1 := []byte("e2e-test")
        for {
-               err := os.WriteFile("/tmp/skywalking-rover-e2e-test", d1, 0600)
+               err := os.WriteFile("/tmp/skywalking-rover-e2e-test", d1, 0o600)
                if err != nil {
                        fmt.Printf("error: %v", err)
                        break

Reply via email to