Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced kernel: Build 2 series of eBPF objects(kernel ver. <5.13 & >=5.13) and load eBPF dynamically when Kmesh starts up #914

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading