diff --git a/prog.go b/prog.go index 5e990af7f..e9c7bdb99 100644 --- a/prog.go +++ b/prog.go @@ -585,7 +585,9 @@ func (p *Program) Benchmark(in []byte, repeat int, reset func()) (uint32, time.D var haveProgTestRun = internal.FeatureTest("BPF_PROG_TEST_RUN", "4.12", func() error { prog, err := NewProgram(&ProgramSpec{ - Type: SocketFilter, + // The first PROG_TEST_RUN patches shipped in 4.12 only supported testing + // SKB and XDP programs. + Type: SchedACT, Instructions: asm.Instructions{ asm.LoadImm(asm.R0, 0, asm.DWord), asm.Return(), @@ -665,6 +667,10 @@ func (p *Program) testRun(in []byte, repeat int, reset func()) (uint32, []byte, continue } + if errors.Is(err, unix.ENOTSUPP) { + return 0, nil, 0, fmt.Errorf("can't test program type %s: %w", p.Type(), ErrNotSupported) + } + return 0, nil, 0, fmt.Errorf("can't run test: %w", err) }