Skip to content

Commit

Permalink
internal: include previous line on BPF context access error
Browse files Browse the repository at this point in the history
Add context if the last verifier log line indicates a context access
error.

See #723
  • Loading branch information
lmb authored and ti-mo committed Jul 19, 2022
1 parent bf69929 commit d560e44
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/errors.go
Expand Up @@ -128,6 +128,13 @@ func includePreviousLine(line string) bool {
return true
}

if strings.HasPrefix(line, "invalid bpf_context access") {
// 0: (79) r6 = *(u64 *)(r1 +0)
// func '__x64_sys_recvfrom' arg0 type FWD is not a struct
// invalid bpf_context access off=0 size=8
return true
}

return false
}

Expand Down
4 changes: 4 additions & 0 deletions internal/errors_test.go
Expand Up @@ -73,6 +73,10 @@ func TestVerifierError(t *testing.T) {
invalidR0 := readErrorFromFile(t, "testdata/invalid-R0.log")
t.Log(invalidR0)
qt.Assert(t, invalidR0.Error(), qt.Contains, "0: (95) exit: R0 !read_ok")

invalidCtx := readErrorFromFile(t, "testdata/invalid-ctx-access.log")
t.Log(invalidCtx)
qt.Assert(t, invalidCtx.Error(), qt.Contains, "func '__x64_sys_recvfrom' arg0 type FWD is not a struct: invalid bpf_context access off=0 size=8")
}

func ExampleVerifierError() {
Expand Down
Binary file added internal/testdata/invalid-ctx-access.log
Binary file not shown.

0 comments on commit d560e44

Please sign in to comment.