diff --git a/docs/sources/distributed-traces.md b/docs/sources/distributed-traces.md index 38e45ffbe..e5038dda9 100644 --- a/docs/sources/distributed-traces.md +++ b/docs/sources/distributed-traces.md @@ -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 diff --git a/pkg/config/ebpf_tracer.go b/pkg/config/ebpf_tracer.go index 2bf0b4edd..73eb26c63 100644 --- a/pkg/config/ebpf_tracer.go +++ b/pkg/config/ebpf_tracer.go @@ -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"` diff --git a/pkg/internal/ebpf/common/common.go b/pkg/internal/ebpf/common/common.go index edb378692..a20a40ff1 100644 --- a/pkg/internal/ebpf/common/common.go +++ b/pkg/internal/ebpf/common/common.go @@ -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) } diff --git a/pkg/internal/ebpf/generictracer/generictracer.go b/pkg/internal/ebpf/generictracer/generictracer.go index cf679b36d..ccee6fa66 100644 --- a/pkg/internal/ebpf/generictracer/generictracer.go +++ b/pkg/internal/ebpf/generictracer/generictracer.go @@ -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() diff --git a/pkg/internal/ebpf/httptracer/httptracer.go b/pkg/internal/ebpf/httptracer/httptracer.go index 88cdb0b9f..1dfa605f3 100644 --- a/pkg/internal/ebpf/httptracer/httptracer.go +++ b/pkg/internal/ebpf/httptracer/httptracer.go @@ -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()