Skip to content

Commit

Permalink
Enhanced kernel: Build 2 series of eBPF objects(kernel ver. <5.13 & >…
Browse files Browse the repository at this point in the history
…=5.13) and load eBPF dynamically when Kmesh starts up

Signed-off-by: talon <[email protected]>
  • Loading branch information
tacslon authored and kmesh-bot committed Sep 30, 2024
1 parent a49b6e8 commit f90febf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/bpf/bpf_kmesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (

"kmesh.net/kmesh/bpf/kmesh/bpf2go"
"kmesh.net/kmesh/daemon/options"
"kmesh.net/kmesh/pkg/utils"
)

type BpfTracePoint struct {
Expand Down Expand Up @@ -103,7 +104,11 @@ func (sc *BpfTracePoint) loadKmeshTracePointObjects() (*ebpf.CollectionSpec, err
opts ebpf.CollectionOptions
)

spec, err = bpf2go.LoadKmeshTracePoint()
if utils.KernelVersionLowerThan5_13() {
spec, err = bpf2go.LoadKmeshTracePointCompat()
} else {
spec, err = bpf2go.LoadKmeshTracePoint()
}
if err != nil || spec == nil {
return nil, err
}
Expand Down Expand Up @@ -137,7 +142,11 @@ func (sc *BpfSockOps) loadKmeshSockopsObjects() (*ebpf.CollectionSpec, error) {

opts.Maps.PinPath = sc.Info.MapPath

spec, err = bpf2go.LoadKmeshSockops()
if utils.KernelVersionLowerThan5_13() {
spec, err = bpf2go.LoadKmeshSockopsCompat()
} else {
spec, err = bpf2go.LoadKmeshSockops()
}

if err != nil || spec == nil {
return nil, err
Expand Down

0 comments on commit f90febf

Please sign in to comment.