Debian Codegraph @

link/xdp_test.go

raw symbols SCIP
1 //go:build !windows
2
3 package link
4
5 import (
6 "math"
7 "testing"
8
9 "github.com/go-quicktest/qt"
10
11 "github.com/cilium/ebpf"
12 "github.com/cilium/ebpf/internal/testutils"
13 )
14
15 const IfIndexLO = 1
16
17 func TestAttachXDP(t *testing.T) {
18 testutils.SkipOnOldKernel(t, "5.9", "BPF_LINK_TYPE_XDP")
19
20 prog := mustLoadProgram(t, ebpf.XDP, 0, "")
21
22 _, err := AttachXDP(XDPOptions{
23 Program: prog,
24 Interface: math.MaxInt,
25 })
26 qt.Assert(t, qt.IsNotNil(err))
27
28 l, err := AttachXDP(XDPOptions{
29 Program: prog,
30 Interface: IfIndexLO,
31 })
32 qt.Assert(t, qt.IsNil(err))
33
34 info, err := l.Info()
35 qt.Assert(t, qt.IsNil(err))
36 qt.Assert(t, qt.Equals(info.XDP().Ifindex, IfIndexLO))
37
38 testLink(t, l, prog)
39 }