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

Allow users to skip Kernel check for bpf_loop functionality #1612

Merged
merged 6 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion docs/sources/distributed-traces.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ have their context propagated. We use this volume path to listen to newly create

#### Kernel version limitations

The network level context propagation incoming headers parsing requires kernel 5.17 or newer.
The network level context propagation incoming headers parsing generally requires kernel 5.17 or newer for the addition and use of BPF loops.

Some patched kernels, such as RHEL 9.2, may have this functionality ported back. Setting BEYLA_OVERRIDE_BPF_LOOP_ENABLED skips kernel checks in the case your kernel includes the functionality but is lower than 5.17.

### Go context propagation by instrumenting at library level

Expand Down
4 changes: 4 additions & 0 deletions pkg/config/ebpf_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ type EBPFTracer struct {
// Enables Linux Traffic Control probes for context propagation
ContextPropagationEnabled bool `yaml:"enable_context_propagation" env:"BEYLA_BPF_ENABLE_CONTEXT_PROPAGATION"`

// Skips checking the kernel version for bpf_loop functionality. Some modified kernels have this
// backported prior to version 5.17.
OverrideBPFLoopEnabled bool `yaml:"override_bpfloop_enabled" env:"BEYLA_OVERRIDE_BPF_LOOP_ENABLED"`

// Enables Linux Traffic Control probes for context propagation
UseTCForL7CP bool `yaml:"traffic_control_l7_context_propagation" env:"BEYLA_BPF_TC_L7_CP"`

Expand Down
6 changes: 5 additions & 1 deletion pkg/internal/ebpf/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ func SupportsContextPropagationWithProbe(log *slog.Logger) bool {
return false
}

func SupportsEBPFLoops() bool {
func SupportsEBPFLoops(log *slog.Logger, overrideKernelVersion bool) bool {
if overrideKernelVersion {
log.Debug("Skipping kernel version check for bpf_loop functionality: user supplied confirmation of support")
return true
}
kernelMajor, kernelMinor := KernelVersion()
return kernelMajor > 5 || (kernelMajor == 5 && kernelMinor >= 17)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/internal/ebpf/generictracer/generictracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,14 @@ func (p *Tracer) Load() (*ebpf.CollectionSpec, error) {
}

if p.cfg.EBPF.TrackRequestHeaders || p.cfg.EBPF.UseTCForL7CP || p.cfg.EBPF.ContextPropagationEnabled {
if ebpfcommon.SupportsEBPFLoops() {
p.log.Info("Found Linux kernel later than 5.17, enabling trace information parsing")
if ebpfcommon.SupportsEBPFLoops(p.log, p.cfg.EBPF.OverrideBPFLoopEnabled) {
p.log.Info("Found compatible Linux kernel, enabling trace information parsing")
loader = loadBpf_tp
if p.cfg.EBPF.BpfDebug {
loader = loadBpf_tp_debug
}
}
p.log.Info("Found incompatible Linux kernel, disabling trace information parsing")
}

return loader()
Expand Down
4 changes: 2 additions & 2 deletions pkg/internal/ebpf/httptracer/httptracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ func (p *Tracer) startTC(ctx context.Context) {

p.log.Info("enabling L7 context-propagation with Linux Traffic Control")

if !ebpfcommon.SupportsEBPFLoops() {
p.log.Error("cannot enable L7 context-propagation, kernel 5.17 or newer required")
if !ebpfcommon.SupportsEBPFLoops(p.log, p.cfg.EBPF.OverrideBPFLoopEnabled) {
p.log.Error("cannot enable L7 context-propagation, compatible kernel required")
}

p.ifaceManager = tcmanager.NewInterfaceManager()
Expand Down
Loading