AttachXDP failed on Ubuntu 20.04, kernel version is 5.4 #1487
-
Describe the bug
How to reproduceEnv: Ubuntu 20.04, kernel version 5.4 if err := features.HaveProgramType(ebpf.XDP); err == nil {
lk, linkErr := link.AttachXDP(link.XDPOptions{
Program: objs.TrafficStat,
Interface: iface.Index,
})
log.Info("Attach XDP result: %v", linkErr)
} Result:
Version informationgithub.com/cilium/ebpf v0.14.0 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
In var haveProgramTypeMatrix = internal.FeatureMatrix[ebpf.ProgramType]{
...
ebpf.XDP: {Version: "4.8"},
...
} But var haveBPFLink = internal.NewFeatureTest("bpf_link", "5.7", func() error {
...
return err
}) |
Beta Was this translation helpful? Give feedback.
-
Hi @loveyacper The eBPF program type XDP was introduced earlier (with 4.8 iirc) than |
Beta Was this translation helpful? Give feedback.
-
@florianl I tried and it worked. I appreciate your helpful and timely reply. |
Beta Was this translation helpful? Give feedback.
Hi @loveyacper
The eBPF program type XDP was introduced earlier (with 4.8 iirc) than
bpf_link
(5.7). As a consequence,bpf_link
is expected to not be available on a 5.4 kernel.You can still load XDP programs, but you have to use another method, like
ip link set ...
. This packagecilium/ebpf
focuses on everything around the eBPF syscall - therefore it does not cover the loading viaip link set ...
.A package, that supports loading of XDP on kernels that do not have support for
bpf_link
is jsimonetti/rtnetlink/v2#LinkService.Set.Feel free to checkout https://gist.github.com/florianl/935cfcbeeee209537d8303165dab41e0 as an example for this.