Skip to content

Commit

Permalink
Add strict mode API
Browse files Browse the repository at this point in the history
  • Loading branch information
javierhonduco committed Apr 28, 2022
1 parent 64458ba commit 42409ad
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions libbpfgo.go
Expand Up @@ -328,6 +328,24 @@ func NewModuleFromFile(bpfObjPath string) (*Module, error) {
})
}

func SetStrictMode(mode string) error {
var chosenMode uint32
switch mode {
case "all":
chosenMode = C.LIBBPF_STRICT_ALL
case "none":
chosenMode = C.LIBBPF_STRICT_NONE
case "clean_ptrs":
chosenMode = C.LIBBPF_STRICT_CLEAN_PTRS
case "direct_errors":
chosenMode = C.LIBBPF_STRICT_DIRECT_ERRS
default:
return fmt.Errorf("%s is not a valid strict mode", mode)
}
C.libbpf_set_strict_mode(chosenMode)
return nil
}

func NewModuleFromFileArgs(args NewModuleArgs) (*Module, error) {
C.set_print_fn()
if err := bumpMemlockRlimit(); err != nil {
Expand Down

0 comments on commit 42409ad

Please sign in to comment.