-
Notifications
You must be signed in to change notification settings - Fork 10
/
config.go
64 lines (48 loc) · 1.87 KB
/
config.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
package ebpf
import (
"strings"
aconfig "github.com/n9e/n9e-agentd/pkg/config"
"github.com/n9e/n9e-agentd/staging/datadog-agent/pkg/process/util"
)
const (
spNS = "system_probe_config"
)
// Config stores all common flags used by system-probe
type Config struct {
// BPFDebug enables bpf debug logs
BPFDebug bool
// BPFDir is the directory to load the eBPF program from
BPFDir string
// ExcludedBPFLinuxVersions lists Linux kernel versions that should not use BPF features
ExcludedBPFLinuxVersions []string
// ProcRoot is the root path to the proc filesystem
ProcRoot string
// EnableTracepoints enables use of tracepoints instead of kprobes for probing syscalls (if available on system)
EnableTracepoints bool
// EnableRuntimeCompiler enables the use of the embedded compiler to build eBPF programs on-host
EnableRuntimeCompiler bool
// KernelHeadersDir is the directories of the kernel headers to use for runtime compilation
KernelHeadersDirs []string
// RuntimeCompilerOutputDir is the directory where the runtime compiler will store compiled programs
RuntimeCompilerOutputDir string
// AllowPrecompiledFallback indicates whether we are allowed to fallback to the prebuilt probes if runtime compilation fails.
AllowPrecompiledFallback bool
}
func key(pieces ...string) string {
return strings.Join(pieces, ".")
}
// NewConfig creates a config with ebpf-related settings
func NewConfig() *Config {
cf := aconfig.C.SystemProbe
return &Config{
BPFDebug: cf.BPFDebug,
BPFDir: cf.BPFDir,
ExcludedBPFLinuxVersions: cf.ExcludedLinuxVersions,
EnableTracepoints: cf.EnableTracepoints,
ProcRoot: util.GetProcRoot(),
EnableRuntimeCompiler: cf.EnableRuntimeCompiler,
RuntimeCompilerOutputDir: cf.RuntimeCompilerOutputDir,
KernelHeadersDirs: cf.KernelHeaderDirs,
AllowPrecompiledFallback: true,
}
}