Skip to content

Commit

Permalink
link: wrap errors for Raw{At,De}tachProgram
Browse files Browse the repository at this point in the history
This allows callers to detect the underlying syscall error, which is
necessary for being able to implement safe fallbacks based on the error
during program loading and unloading. runc in particular needs this to
be able to implement BPF_F_REPLACE fallbacks correctly.

Ref: opencontainers/runc#3008
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
  • Loading branch information
cyphar authored and lmb committed Jun 9, 2021
1 parent f510d07 commit ed2c0a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions link/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func RawAttachProgram(opts RawAttachProgramOptions) error {
}

if err := internal.BPFProgAttach(&attr); err != nil {
return fmt.Errorf("can't attach program: %s", err)
return fmt.Errorf("can't attach program: %w", err)
}
return nil
}
Expand All @@ -69,7 +69,7 @@ func RawDetachProgram(opts RawDetachProgramOptions) error {
AttachType: uint32(opts.Attach),
}
if err := internal.BPFProgDetach(&attr); err != nil {
return fmt.Errorf("can't detach program: %s", err)
return fmt.Errorf("can't detach program: %w", err)
}

return nil
Expand Down

0 comments on commit ed2c0a0

Please sign in to comment.