-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
70 lines (59 loc) · 1.54 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"log"
"rtcagent/cli"
"rtcagent/pkg/util/ebpf"
"rtcagent/pkg/util/kernel"
"runtime"
_ "github.com/shuLhan/go-bindata" // add for bindata in Makefile
)
const (
BtfNotSupport = "You can compile a no BTF version by yourself with command `make nocore`,Please read Makefile for more info."
)
var (
enableCORE = "true"
)
func main() {
kv, err := kernel.HostVersion()
if err != nil {
log.Fatal(err)
}
switch runtime.GOARCH {
case "amd64":
if kv < kernel.VersionCode(4, 18, 0) {
log.Fatalf("Linux/Android Kernel (x86_64) version %v is not supported. Need > 4.18 .", kv)
}
case "arm64":
if kv < kernel.VersionCode(5, 5, 0) {
log.Fatalf("Linux/Android Kernel (aarch64) version %v is not supported. Need > 5.5 .", kv)
}
default:
log.Fatalf("unsupported CPU arch:%v. ", runtime.GOARCH)
}
isContainer, err := ebpf.IsContainer()
if err != nil {
log.Fatal("Check container error:", err)
}
if isContainer {
log.Printf("Your environment is a container. We will not detect the BTF config.")
} else {
enable, e := ebpf.IsEnableBPF()
if e != nil {
log.Fatalf("Kernel config read failed, error:%v", e)
}
if !enable {
log.Fatalf("Kernel not support, error:%v", e)
}
if enableCORE == "true" {
enable, e := ebpf.IsEnableBTF()
if e != nil {
log.Fatalf("Can't found BTF config with error:%v.\n"+BtfNotSupport, e)
}
if !enable {
log.Fatal("BTF not support, please check it. shell: cat /boot/config-`uname -r` | grep CONFIG_DEBUG_INFO_BTF \n " +
BtfNotSupport)
}
}
}
cli.Start()
}