aboutsummaryrefslogtreecommitdiffhomepage
path: root/helper/seccomp/seccomp.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-01-25 13:19:38 +0900
committerOphestra <cat@gensokyo.uk>2025-01-25 13:19:38 +0900
commit7b96cd6ded2668b04c908737ff393b805d34cc5c (patch)
treeb78c76a9ca30efd78ca2cd6caf8b9b2c55bc80c1 /helper/seccomp/seccomp.go
parent163f15e93f009d15ecc2f93932e26728aff9904b (diff)
helper/seccomp: do not call F_println if not verbose
This (slightly) improves performance. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'helper/seccomp/seccomp.go')
-rw-r--r--helper/seccomp/seccomp.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/helper/seccomp/seccomp.go b/helper/seccomp/seccomp.go
index b3294672..ed13118a 100644
--- a/helper/seccomp/seccomp.go
+++ b/helper/seccomp/seccomp.go
@@ -28,6 +28,7 @@ var resErr = [...]error{
type SyscallOpts = C.f_syscall_opts
const (
+ flagVerbose SyscallOpts = C.F_VERBOSE
FlagExt SyscallOpts = C.F_EXT
FlagDenyNS SyscallOpts = C.F_DENY_NS
FlagDenyTTY SyscallOpts = C.F_DENY_TTY
@@ -64,6 +65,12 @@ func exportFilter(fd uintptr, opts SyscallOpts) error {
multiarch = C.SCMP_ARCH_ARM
}
+ // this removes repeated transitions between C and Go execution
+ // when producing log output via F_println and CPrintln is nil
+ if CPrintln != nil {
+ opts |= flagVerbose
+ }
+
res, err := C.f_export_bpf(C.int(fd), arch, multiarch, opts)
if re := resErr[res]; re != nil {
if err == nil {