Skip to content

Commit

Permalink
trace: output kernel requirement for trace
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwinger233 committed Mar 28, 2024
1 parent c84a6a9 commit ad275c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/consts/ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ var (
ChecksumFeatureVersion = internal.Version{5, 8, 0}
ProgTypeSkLookupFeatureVersion = internal.Version{5, 9, 0}
UserspaceBatchUpdateLpmTrieFeatureVersion = internal.Version{5, 13, 0}
HelperBpfGetFuncIPVersionFeatureVersion = internal.Version{5, 15, 0}
)

const (
Expand Down
11 changes: 11 additions & 0 deletions trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/link"
"github.com/cilium/ebpf/ringbuf"
"github.com/daeuniverse/dae/common/consts"
internal "github.com/daeuniverse/dae/pkg/ebpf_internal"
"github.com/sirupsen/logrus"
)

Expand All @@ -42,6 +44,15 @@ func init() {
}

func StartTrace(ctx context.Context, ipVersion int, l4ProtoNo uint16, port int, outputFile string) (err error) {
kernelVersion, err := internal.KernelVersion()
if err != nil {
return fmt.Errorf("failed to get kernel version: %w", err)
}
if requirement := consts.HelperBpfGetFuncIPVersionFeatureVersion; kernelVersion.Less(requirement) {
return fmt.Errorf("your kernel version %v does not support bpf_get_func_ip; expect >=%v; upgrade your kernel and try again",
kernelVersion.String(),
requirement.String())
}
objs, err := rewriteAndLoadBpf(ipVersion, l4ProtoNo, port)
if err != nil {
return
Expand Down

0 comments on commit ad275c4

Please sign in to comment.