From 7b96cd6ded2668b04c908737ff393b805d34cc5c Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 25 Jan 2025 13:19:38 +0900 Subject: helper/seccomp: do not call F_println if not verbose This (slightly) improves performance. Signed-off-by: Ophestra --- helper/seccomp/seccomp.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'helper/seccomp/seccomp.go') 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 { -- cgit v1.3.1