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 222261b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion 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_errs":
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 Expand Up @@ -787,7 +805,6 @@ func (b *BPFMap) DeleteKeyBatch(keys unsafe.Pointer, count uint32) error {
ElemFlags: C.BPF_ANY,
Flags: C.BPF_ANY,
}

errC := C.bpf_map_delete_batch(b.fd, keys, &countC, bpfMapBatchOptsToC(opts))
if errC != 0 {
sc := syscall.Errno(-errC)
Expand Down

0 comments on commit 222261b

Please sign in to comment.