From 2b5d31eebfb9c7c2f3cd13e68a55f0a0c2cae241 Mon Sep 17 00:00:00 2001 From: oliveromahony Date: Tue, 27 Aug 2024 14:20:42 +0100 Subject: [PATCH] Remove blocking calls in metrics framework (#788) * remove wait groups from metrics framework * updated aggregations to cater for new source reporting * fixed some memory leaks using goleak Co-authored-by: dhurley Co-authored-by: Aphral Griffin --- go.mod | 3 +- go.sum | 6 +- leak_test.go | 18 + nginx-agent.conf | 3 +- sdk/backoff/backoff.go | 2 +- sdk/go.mod | 2 +- sdk/go.sum | 4 +- sdk/vendor/golang.org/x/sys/LICENSE | 4 +- sdk/vendor/golang.org/x/sys/unix/mkerrors.sh | 1 + .../golang.org/x/sys/unix/syscall_darwin.go | 12 + .../golang.org/x/sys/unix/syscall_linux.go | 1 + .../golang.org/x/sys/unix/syscall_openbsd.go | 1 + .../x/sys/unix/zerrors_darwin_amd64.go | 5 + .../x/sys/unix/zerrors_darwin_arm64.go | 5 + .../golang.org/x/sys/unix/zerrors_linux.go | 38 ++- .../x/sys/unix/zerrors_linux_386.go | 2 + .../x/sys/unix/zerrors_linux_amd64.go | 2 + .../x/sys/unix/zerrors_linux_arm.go | 2 + .../x/sys/unix/zerrors_linux_arm64.go | 2 + .../x/sys/unix/zerrors_linux_loong64.go | 2 + .../x/sys/unix/zerrors_linux_mips.go | 2 + .../x/sys/unix/zerrors_linux_mips64.go | 2 + .../x/sys/unix/zerrors_linux_mips64le.go | 2 + .../x/sys/unix/zerrors_linux_mipsle.go | 2 + .../x/sys/unix/zerrors_linux_ppc.go | 2 + .../x/sys/unix/zerrors_linux_ppc64.go | 2 + .../x/sys/unix/zerrors_linux_ppc64le.go | 2 + .../x/sys/unix/zerrors_linux_riscv64.go | 2 + .../x/sys/unix/zerrors_linux_s390x.go | 2 + .../x/sys/unix/zerrors_linux_sparc64.go | 2 + .../x/sys/unix/zsyscall_darwin_amd64.go | 48 +++ .../x/sys/unix/zsyscall_darwin_amd64.s | 10 + .../x/sys/unix/zsyscall_darwin_arm64.go | 48 +++ .../x/sys/unix/zsyscall_darwin_arm64.s | 10 + .../golang.org/x/sys/unix/zsyscall_linux.go | 16 + .../x/sys/unix/zsyscall_openbsd_386.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_386.s | 5 + .../x/sys/unix/zsyscall_openbsd_amd64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_amd64.s | 5 + .../x/sys/unix/zsyscall_openbsd_arm.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_arm.s | 5 + .../x/sys/unix/zsyscall_openbsd_arm64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_arm64.s | 5 + .../x/sys/unix/zsyscall_openbsd_mips64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_mips64.s | 5 + .../x/sys/unix/zsyscall_openbsd_ppc64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_ppc64.s | 6 + .../x/sys/unix/zsyscall_openbsd_riscv64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_riscv64.s | 5 + .../x/sys/unix/zsysnum_linux_386.go | 1 + .../x/sys/unix/zsysnum_linux_amd64.go | 1 + .../x/sys/unix/zsysnum_linux_arm.go | 1 + .../x/sys/unix/zsysnum_linux_arm64.go | 1 + .../x/sys/unix/zsysnum_linux_loong64.go | 1 + .../x/sys/unix/zsysnum_linux_mips.go | 1 + .../x/sys/unix/zsysnum_linux_mips64.go | 1 + .../x/sys/unix/zsysnum_linux_mips64le.go | 1 + .../x/sys/unix/zsysnum_linux_mipsle.go | 1 + .../x/sys/unix/zsysnum_linux_ppc.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 1 + .../x/sys/unix/zsysnum_linux_riscv64.go | 1 + .../x/sys/unix/zsysnum_linux_s390x.go | 1 + .../x/sys/unix/zsysnum_linux_sparc64.go | 1 + .../golang.org/x/sys/unix/ztypes_linux.go | 10 +- .../x/sys/windows/security_windows.go | 2 +- .../x/sys/windows/syscall_windows.go | 12 +- .../golang.org/x/sys/windows/types_windows.go | 71 +++- .../x/sys/windows/zsyscall_windows.go | 49 ++- sdk/vendor/modules.txt | 2 +- src/core/config/config.go | 3 +- src/core/config/leak_test.go | 18 + src/core/environment.go | 6 +- src/core/leak_test.go | 18 + src/core/metrics/aggregate.go | 40 ++- src/core/metrics/aggregate_test.go | 310 ++++++++++++------ src/core/metrics/collectors/container.go | 11 +- src/core/metrics/collectors/container_test.go | 9 +- src/core/metrics/collectors/leak_test.go | 18 + src/core/metrics/collectors/nginx.go | 11 +- src/core/metrics/collectors/nginx_test.go | 9 +- .../metrics/collectors/source_mocks_test.go | 13 +- src/core/metrics/collectors/system.go | 11 +- src/core/metrics/collectors/system_test.go | 8 +- src/core/metrics/leak_test.go | 18 + src/core/metrics/metrics_util.go | 7 +- src/core/metrics/sources/cgroup/leak_test.go | 18 + src/core/metrics/sources/common.go | 3 + src/core/metrics/sources/container_cpu.go | 4 +- .../metrics/sources/container_cpu_test.go | 6 +- src/core/metrics/sources/container_mem.go | 4 +- .../metrics/sources/container_mem_test.go | 6 +- src/core/metrics/sources/cpu.go | 3 +- src/core/metrics/sources/cpu_test.go | 19 +- src/core/metrics/sources/disk.go | 7 +- src/core/metrics/sources/disk_io.go | 4 +- src/core/metrics/sources/disk_io_test.go | 6 +- src/core/metrics/sources/disk_test.go | 6 +- src/core/metrics/sources/leak_test.go | 18 + src/core/metrics/sources/load.go | 7 +- src/core/metrics/sources/load_test.go | 6 +- src/core/metrics/sources/mem.go | 6 +- src/core/metrics/sources/mem_test.go | 6 +- src/core/metrics/sources/net_io.go | 6 +- src/core/metrics/sources/net_io_test.go | 6 +- src/core/metrics/sources/nginx_access_log.go | 5 +- .../metrics/sources/nginx_access_log_test.go | 10 +- src/core/metrics/sources/nginx_error_log.go | 4 +- .../metrics/sources/nginx_error_log_test.go | 7 +- src/core/metrics/sources/nginx_oss.go | 5 +- src/core/metrics/sources/nginx_oss_test.go | 6 +- src/core/metrics/sources/nginx_plus.go | 7 +- src/core/metrics/sources/nginx_plus_test.go | 10 +- src/core/metrics/sources/nginx_process.go | 7 +- .../metrics/sources/nginx_process_test.go | 13 +- src/core/metrics/sources/nginx_static.go | 5 +- src/core/metrics/sources/nginx_static_test.go | 6 +- src/core/metrics/sources/nginx_worker.go | 5 +- src/core/metrics/sources/nginx_worker_test.go | 9 +- src/core/metrics/sources/swap.go | 4 +- src/core/metrics/sources/swap_test.go | 6 +- src/core/mock_pipe.go | 3 + src/core/os.go | 38 ++- src/core/pipe.go | 87 +++-- src/core/pipe_test.go | 69 ++-- src/core/tailer/leak_test.go | 18 + src/core/tailer/tailer.go | 18 + src/core/tailer/tailer_test.go | 16 +- src/extensions/advanced_metrics.go | 4 +- src/extensions/advanced_metrics_test.go | 5 +- src/extensions/nap_monitoring.go | 41 ++- src/extensions/nap_monitoring_test.go | 23 -- .../monitoring/collector/collector.go | 3 +- .../monitoring/collector/nap.go | 5 +- .../monitoring/collector/nap_test.go | 6 +- .../monitoring/manager/manager.go | 10 +- .../monitoring/processor/processor.go | 9 +- .../monitoring/processor/processor_test.go | 6 +- src/extensions/nginx-app-protect/nap/nap.go | 21 +- src/extensions/nginx_app_protect.go | 4 +- .../prometheus-metrics/prometheus_exporter.go | 13 +- src/plugins/agent_api.go | 8 +- src/plugins/agent_api_test.go | 4 +- src/plugins/features.go | 22 +- src/plugins/features_test.go | 6 +- src/plugins/file_watcher.go | 14 +- src/plugins/leak_test.go | 18 + src/plugins/metrics.go | 75 ++--- src/plugins/metrics_throlling.go | 52 ++- src/plugins/nginx_counter.go | 6 +- src/plugins/nginx_counter_test.go | 2 + src/plugins/process_watcher_test.go | 103 +++++- src/plugins/registration.go | 2 +- test/component/agent_api_test.go | 2 +- test/integration/api/api_test.go | 9 + test/integration/api/nginx-agent.conf | 2 +- test/integration/go.mod | 2 +- test/integration/go.sum | 8 +- .../grpc/grpc_config_apply_test.go | 2 +- .../nginx/agent/sdk/v2/backoff/backoff.go | 2 +- .../nginx/agent/v2/src/core/config/config.go | 3 +- .../nginx/agent/v2/src/core/environment.go | 6 +- .../nginx/agent/v2/src/core/mock_pipe.go | 3 + .../github.com/nginx/agent/v2/src/core/os.go | 38 ++- .../nginx/agent/v2/src/core/pipe.go | 87 +++-- .../vendor/golang.org/x/sys/LICENSE | 4 +- .../vendor/golang.org/x/sys/cpu/cpu.go | 2 + .../vendor/golang.org/x/sys/cpu/cpu_arm64.go | 12 + .../golang.org/x/sys/cpu/cpu_linux_arm64.go | 5 + .../vendor/golang.org/x/sys/unix/mkerrors.sh | 1 + .../golang.org/x/sys/unix/syscall_darwin.go | 12 + .../golang.org/x/sys/unix/syscall_linux.go | 1 + .../golang.org/x/sys/unix/syscall_openbsd.go | 1 + .../x/sys/unix/zerrors_darwin_amd64.go | 5 + .../x/sys/unix/zerrors_darwin_arm64.go | 5 + .../golang.org/x/sys/unix/zerrors_linux.go | 38 ++- .../x/sys/unix/zerrors_linux_386.go | 2 + .../x/sys/unix/zerrors_linux_amd64.go | 2 + .../x/sys/unix/zerrors_linux_arm.go | 2 + .../x/sys/unix/zerrors_linux_arm64.go | 2 + .../x/sys/unix/zerrors_linux_loong64.go | 2 + .../x/sys/unix/zerrors_linux_mips.go | 2 + .../x/sys/unix/zerrors_linux_mips64.go | 2 + .../x/sys/unix/zerrors_linux_mips64le.go | 2 + .../x/sys/unix/zerrors_linux_mipsle.go | 2 + .../x/sys/unix/zerrors_linux_ppc.go | 2 + .../x/sys/unix/zerrors_linux_ppc64.go | 2 + .../x/sys/unix/zerrors_linux_ppc64le.go | 2 + .../x/sys/unix/zerrors_linux_riscv64.go | 2 + .../x/sys/unix/zerrors_linux_s390x.go | 2 + .../x/sys/unix/zerrors_linux_sparc64.go | 2 + .../x/sys/unix/zsyscall_darwin_amd64.go | 48 +++ .../x/sys/unix/zsyscall_darwin_amd64.s | 10 + .../x/sys/unix/zsyscall_darwin_arm64.go | 48 +++ .../x/sys/unix/zsyscall_darwin_arm64.s | 10 + .../golang.org/x/sys/unix/zsyscall_linux.go | 16 + .../x/sys/unix/zsyscall_openbsd_386.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_386.s | 5 + .../x/sys/unix/zsyscall_openbsd_amd64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_amd64.s | 5 + .../x/sys/unix/zsyscall_openbsd_arm.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_arm.s | 5 + .../x/sys/unix/zsyscall_openbsd_arm64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_arm64.s | 5 + .../x/sys/unix/zsyscall_openbsd_mips64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_mips64.s | 5 + .../x/sys/unix/zsyscall_openbsd_ppc64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_ppc64.s | 6 + .../x/sys/unix/zsyscall_openbsd_riscv64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_riscv64.s | 5 + .../x/sys/unix/zsysnum_linux_386.go | 1 + .../x/sys/unix/zsysnum_linux_amd64.go | 1 + .../x/sys/unix/zsysnum_linux_arm.go | 1 + .../x/sys/unix/zsysnum_linux_arm64.go | 1 + .../x/sys/unix/zsysnum_linux_loong64.go | 1 + .../x/sys/unix/zsysnum_linux_mips.go | 1 + .../x/sys/unix/zsysnum_linux_mips64.go | 1 + .../x/sys/unix/zsysnum_linux_mips64le.go | 1 + .../x/sys/unix/zsysnum_linux_mipsle.go | 1 + .../x/sys/unix/zsysnum_linux_ppc.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 1 + .../x/sys/unix/zsysnum_linux_riscv64.go | 1 + .../x/sys/unix/zsysnum_linux_s390x.go | 1 + .../x/sys/unix/zsysnum_linux_sparc64.go | 1 + .../golang.org/x/sys/unix/ztypes_linux.go | 10 +- .../x/sys/windows/security_windows.go | 2 +- .../x/sys/windows/syscall_windows.go | 12 +- .../golang.org/x/sys/windows/types_windows.go | 71 +++- .../x/sys/windows/zsyscall_windows.go | 49 ++- test/integration/vendor/modules.txt | 2 +- test/performance/go.mod | 2 +- test/performance/go.sum | 6 +- .../nginx/agent/sdk/v2/backoff/backoff.go | 2 +- .../nginx/agent/v2/src/core/config/config.go | 3 +- .../nginx/agent/v2/src/core/environment.go | 6 +- .../agent/v2/src/core/metrics/aggregate.go | 40 ++- .../src/core/metrics/collectors/container.go | 11 +- .../v2/src/core/metrics/collectors/nginx.go | 11 +- .../v2/src/core/metrics/collectors/system.go | 11 +- .../agent/v2/src/core/metrics/metrics_util.go | 7 +- .../v2/src/core/metrics/sources/common.go | 3 + .../src/core/metrics/sources/container_cpu.go | 4 +- .../src/core/metrics/sources/container_mem.go | 4 +- .../agent/v2/src/core/metrics/sources/cpu.go | 3 +- .../agent/v2/src/core/metrics/sources/disk.go | 7 +- .../v2/src/core/metrics/sources/disk_io.go | 4 +- .../agent/v2/src/core/metrics/sources/load.go | 7 +- .../agent/v2/src/core/metrics/sources/mem.go | 6 +- .../v2/src/core/metrics/sources/net_io.go | 6 +- .../core/metrics/sources/nginx_access_log.go | 5 +- .../core/metrics/sources/nginx_error_log.go | 4 +- .../v2/src/core/metrics/sources/nginx_oss.go | 5 +- .../v2/src/core/metrics/sources/nginx_plus.go | 7 +- .../src/core/metrics/sources/nginx_process.go | 7 +- .../src/core/metrics/sources/nginx_static.go | 5 +- .../src/core/metrics/sources/nginx_worker.go | 5 +- .../agent/v2/src/core/metrics/sources/swap.go | 4 +- .../nginx/agent/v2/src/core/mock_pipe.go | 3 + .../github.com/nginx/agent/v2/src/core/os.go | 38 ++- .../nginx/agent/v2/src/core/pipe.go | 87 +++-- .../nginx/agent/v2/src/core/tailer/tailer.go | 18 + .../v2/src/extensions/advanced_metrics.go | 4 +- .../agent/v2/src/extensions/nap_monitoring.go | 41 ++- .../monitoring/collector/collector.go | 3 +- .../monitoring/collector/nap.go | 5 +- .../monitoring/manager/manager.go | 10 +- .../monitoring/processor/processor.go | 9 +- .../extensions/nginx-app-protect/nap/nap.go | 21 +- .../v2/src/extensions/nginx_app_protect.go | 4 +- .../prometheus-metrics/prometheus_exporter.go | 13 +- .../nginx/agent/v2/src/plugins/agent_api.go | 8 +- .../nginx/agent/v2/src/plugins/features.go | 22 +- .../agent/v2/src/plugins/file_watcher.go | 14 +- .../nginx/agent/v2/src/plugins/metrics.go | 75 ++--- .../agent/v2/src/plugins/metrics_throlling.go | 52 ++- .../agent/v2/src/plugins/nginx_counter.go | 6 +- .../agent/v2/src/plugins/registration.go | 2 +- .../vendor/golang.org/x/sys/LICENSE | 4 +- .../vendor/golang.org/x/sys/cpu/cpu.go | 2 + .../vendor/golang.org/x/sys/cpu/cpu_arm64.go | 12 + .../golang.org/x/sys/cpu/cpu_linux_arm64.go | 5 + .../vendor/golang.org/x/sys/unix/mkerrors.sh | 1 + .../golang.org/x/sys/unix/syscall_darwin.go | 12 + .../golang.org/x/sys/unix/syscall_linux.go | 1 + .../golang.org/x/sys/unix/syscall_openbsd.go | 1 + .../x/sys/unix/zerrors_darwin_amd64.go | 5 + .../x/sys/unix/zerrors_darwin_arm64.go | 5 + .../golang.org/x/sys/unix/zerrors_linux.go | 38 ++- .../x/sys/unix/zerrors_linux_386.go | 2 + .../x/sys/unix/zerrors_linux_amd64.go | 2 + .../x/sys/unix/zerrors_linux_arm.go | 2 + .../x/sys/unix/zerrors_linux_arm64.go | 2 + .../x/sys/unix/zerrors_linux_loong64.go | 2 + .../x/sys/unix/zerrors_linux_mips.go | 2 + .../x/sys/unix/zerrors_linux_mips64.go | 2 + .../x/sys/unix/zerrors_linux_mips64le.go | 2 + .../x/sys/unix/zerrors_linux_mipsle.go | 2 + .../x/sys/unix/zerrors_linux_ppc.go | 2 + .../x/sys/unix/zerrors_linux_ppc64.go | 2 + .../x/sys/unix/zerrors_linux_ppc64le.go | 2 + .../x/sys/unix/zerrors_linux_riscv64.go | 2 + .../x/sys/unix/zerrors_linux_s390x.go | 2 + .../x/sys/unix/zerrors_linux_sparc64.go | 2 + .../x/sys/unix/zsyscall_darwin_amd64.go | 48 +++ .../x/sys/unix/zsyscall_darwin_amd64.s | 10 + .../x/sys/unix/zsyscall_darwin_arm64.go | 48 +++ .../x/sys/unix/zsyscall_darwin_arm64.s | 10 + .../golang.org/x/sys/unix/zsyscall_linux.go | 16 + .../x/sys/unix/zsyscall_openbsd_386.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_386.s | 5 + .../x/sys/unix/zsyscall_openbsd_amd64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_amd64.s | 5 + .../x/sys/unix/zsyscall_openbsd_arm.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_arm.s | 5 + .../x/sys/unix/zsyscall_openbsd_arm64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_arm64.s | 5 + .../x/sys/unix/zsyscall_openbsd_mips64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_mips64.s | 5 + .../x/sys/unix/zsyscall_openbsd_ppc64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_ppc64.s | 6 + .../x/sys/unix/zsyscall_openbsd_riscv64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_riscv64.s | 5 + .../x/sys/unix/zsysnum_linux_386.go | 1 + .../x/sys/unix/zsysnum_linux_amd64.go | 1 + .../x/sys/unix/zsysnum_linux_arm.go | 1 + .../x/sys/unix/zsysnum_linux_arm64.go | 1 + .../x/sys/unix/zsysnum_linux_loong64.go | 1 + .../x/sys/unix/zsysnum_linux_mips.go | 1 + .../x/sys/unix/zsysnum_linux_mips64.go | 1 + .../x/sys/unix/zsysnum_linux_mips64le.go | 1 + .../x/sys/unix/zsysnum_linux_mipsle.go | 1 + .../x/sys/unix/zsysnum_linux_ppc.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 1 + .../x/sys/unix/zsysnum_linux_riscv64.go | 1 + .../x/sys/unix/zsysnum_linux_s390x.go | 1 + .../x/sys/unix/zsysnum_linux_sparc64.go | 1 + .../golang.org/x/sys/unix/ztypes_linux.go | 10 +- .../x/sys/windows/security_windows.go | 2 +- .../x/sys/windows/syscall_windows.go | 12 +- .../golang.org/x/sys/windows/types_windows.go | 71 +++- .../x/sys/windows/zsyscall_windows.go | 49 ++- test/performance/vendor/modules.txt | 2 +- test/testdata/configs/nginx-agent.conf | 2 +- .../nginx/agent/sdk/v2/backoff/backoff.go | 2 +- vendor/go.uber.org/goleak/.gitignore | 5 + vendor/go.uber.org/goleak/.golangci.yml | 28 ++ vendor/go.uber.org/goleak/CHANGELOG.md | 74 +++++ vendor/go.uber.org/goleak/LICENSE | 21 ++ vendor/go.uber.org/goleak/Makefile | 45 +++ vendor/go.uber.org/goleak/README.md | 74 +++++ vendor/go.uber.org/goleak/doc.go | 22 ++ .../go.uber.org/goleak/internal/stack/doc.go | 22 ++ .../go.uber.org/goleak/internal/stack/scan.go | 56 ++++ .../goleak/internal/stack/stacks.go | 298 +++++++++++++++++ vendor/go.uber.org/goleak/leaks.go | 108 ++++++ vendor/go.uber.org/goleak/options.go | 198 +++++++++++ vendor/go.uber.org/goleak/testmain.go | 69 ++++ vendor/go.uber.org/goleak/tracestack_new.go | 30 ++ vendor/golang.org/x/sys/LICENSE | 4 +- vendor/golang.org/x/sys/unix/mkerrors.sh | 1 + .../golang.org/x/sys/unix/syscall_darwin.go | 12 + vendor/golang.org/x/sys/unix/syscall_linux.go | 1 + .../golang.org/x/sys/unix/syscall_openbsd.go | 1 + .../x/sys/unix/zerrors_darwin_amd64.go | 5 + .../x/sys/unix/zerrors_darwin_arm64.go | 5 + vendor/golang.org/x/sys/unix/zerrors_linux.go | 38 ++- .../x/sys/unix/zerrors_linux_386.go | 2 + .../x/sys/unix/zerrors_linux_amd64.go | 2 + .../x/sys/unix/zerrors_linux_arm.go | 2 + .../x/sys/unix/zerrors_linux_arm64.go | 2 + .../x/sys/unix/zerrors_linux_loong64.go | 2 + .../x/sys/unix/zerrors_linux_mips.go | 2 + .../x/sys/unix/zerrors_linux_mips64.go | 2 + .../x/sys/unix/zerrors_linux_mips64le.go | 2 + .../x/sys/unix/zerrors_linux_mipsle.go | 2 + .../x/sys/unix/zerrors_linux_ppc.go | 2 + .../x/sys/unix/zerrors_linux_ppc64.go | 2 + .../x/sys/unix/zerrors_linux_ppc64le.go | 2 + .../x/sys/unix/zerrors_linux_riscv64.go | 2 + .../x/sys/unix/zerrors_linux_s390x.go | 2 + .../x/sys/unix/zerrors_linux_sparc64.go | 2 + .../x/sys/unix/zsyscall_darwin_amd64.go | 48 +++ .../x/sys/unix/zsyscall_darwin_amd64.s | 10 + .../x/sys/unix/zsyscall_darwin_arm64.go | 48 +++ .../x/sys/unix/zsyscall_darwin_arm64.s | 10 + .../golang.org/x/sys/unix/zsyscall_linux.go | 16 + .../x/sys/unix/zsyscall_openbsd_386.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_386.s | 5 + .../x/sys/unix/zsyscall_openbsd_amd64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_amd64.s | 5 + .../x/sys/unix/zsyscall_openbsd_arm.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_arm.s | 5 + .../x/sys/unix/zsyscall_openbsd_arm64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_arm64.s | 5 + .../x/sys/unix/zsyscall_openbsd_mips64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_mips64.s | 5 + .../x/sys/unix/zsyscall_openbsd_ppc64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_ppc64.s | 6 + .../x/sys/unix/zsyscall_openbsd_riscv64.go | 24 ++ .../x/sys/unix/zsyscall_openbsd_riscv64.s | 5 + .../x/sys/unix/zsysnum_linux_386.go | 1 + .../x/sys/unix/zsysnum_linux_amd64.go | 1 + .../x/sys/unix/zsysnum_linux_arm.go | 1 + .../x/sys/unix/zsysnum_linux_arm64.go | 1 + .../x/sys/unix/zsysnum_linux_loong64.go | 1 + .../x/sys/unix/zsysnum_linux_mips.go | 1 + .../x/sys/unix/zsysnum_linux_mips64.go | 1 + .../x/sys/unix/zsysnum_linux_mips64le.go | 1 + .../x/sys/unix/zsysnum_linux_mipsle.go | 1 + .../x/sys/unix/zsysnum_linux_ppc.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64.go | 1 + .../x/sys/unix/zsysnum_linux_ppc64le.go | 1 + .../x/sys/unix/zsysnum_linux_riscv64.go | 1 + .../x/sys/unix/zsysnum_linux_s390x.go | 1 + .../x/sys/unix/zsysnum_linux_sparc64.go | 1 + vendor/golang.org/x/sys/unix/ztypes_linux.go | 10 +- .../x/sys/windows/security_windows.go | 2 +- .../x/sys/windows/syscall_windows.go | 12 +- .../golang.org/x/sys/windows/types_windows.go | 71 +++- .../x/sys/windows/zsyscall_windows.go | 49 ++- vendor/modules.txt | 6 +- 423 files changed, 4774 insertions(+), 991 deletions(-) create mode 100644 leak_test.go create mode 100644 src/core/config/leak_test.go create mode 100644 src/core/leak_test.go create mode 100644 src/core/metrics/collectors/leak_test.go create mode 100644 src/core/metrics/leak_test.go create mode 100644 src/core/metrics/sources/cgroup/leak_test.go create mode 100644 src/core/metrics/sources/leak_test.go create mode 100644 src/core/tailer/leak_test.go create mode 100644 src/plugins/leak_test.go create mode 100644 vendor/go.uber.org/goleak/.gitignore create mode 100644 vendor/go.uber.org/goleak/.golangci.yml create mode 100644 vendor/go.uber.org/goleak/CHANGELOG.md create mode 100644 vendor/go.uber.org/goleak/LICENSE create mode 100644 vendor/go.uber.org/goleak/Makefile create mode 100644 vendor/go.uber.org/goleak/README.md create mode 100644 vendor/go.uber.org/goleak/doc.go create mode 100644 vendor/go.uber.org/goleak/internal/stack/doc.go create mode 100644 vendor/go.uber.org/goleak/internal/stack/scan.go create mode 100644 vendor/go.uber.org/goleak/internal/stack/stacks.go create mode 100644 vendor/go.uber.org/goleak/leaks.go create mode 100644 vendor/go.uber.org/goleak/options.go create mode 100644 vendor/go.uber.org/goleak/testmain.go create mode 100644 vendor/go.uber.org/goleak/tracestack_new.go diff --git a/go.mod b/go.mod index d27d605dd3..b93bcd8d31 100644 --- a/go.mod +++ b/go.mod @@ -40,8 +40,9 @@ require ( github.com/nginx/agent/sdk/v2 v2.30.3 github.com/prometheus/client_golang v1.19.1 github.com/rs/cors v1.11.0 + go.uber.org/goleak v1.3.0 go.uber.org/mock v0.4.0 - golang.org/x/sys v0.22.0 + golang.org/x/sys v0.24.0 golang.org/x/text v0.16.0 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index ee16c71866..e22fe475d3 100644 --- a/go.sum +++ b/go.sum @@ -180,6 +180,8 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -248,8 +250,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= diff --git a/leak_test.go b/leak_test.go new file mode 100644 index 0000000000..42f73ba31b --- /dev/null +++ b/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +package main + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/nginx-agent.conf b/nginx-agent.conf index da4660cb87..5a714bb5c7 100644 --- a/nginx-agent.conf +++ b/nginx-agent.conf @@ -24,6 +24,7 @@ dataplane: poll_interval: 30s # report interval for data plane status - the maximum duration to wait before syncing dataplane information if no updates have being observed report_interval: 24h + metrics: # specify the size of a buffer to build before sending metrics bulk_size: 20 @@ -45,4 +46,4 @@ config_dirs: "/etc/nginx:/usr/local/etc/nginx:/usr/share/nginx/modules:/etc/nms" # host: 127.0.0.1 # # Set this value to a secure port number to prevent information leaks. - # port: 8038 + # port: 8038 \ No newline at end of file diff --git a/sdk/backoff/backoff.go b/sdk/backoff/backoff.go index f5fa9e3b0a..6c26373b02 100644 --- a/sdk/backoff/backoff.go +++ b/sdk/backoff/backoff.go @@ -41,7 +41,7 @@ func WaitUntil( expoBackoffWithContext := backoff.WithContext(exponentialBackoff, ctx) - err := backoff.Retry(backoff.Operation(operation), expoBackoffWithContext) + err := backoff.Retry(operation, expoBackoffWithContext) if err != nil { return err } diff --git a/sdk/go.mod b/sdk/go.mod index 5cd996148c..af91062698 100644 --- a/sdk/go.mod +++ b/sdk/go.mod @@ -28,7 +28,7 @@ require ( golang.org/x/mod v0.19.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect + golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/tools v0.23.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect diff --git a/sdk/go.sum b/sdk/go.sum index 9027ec7270..fc3200948b 100644 --- a/sdk/go.sum +++ b/sdk/go.sum @@ -120,8 +120,8 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= diff --git a/sdk/vendor/golang.org/x/sys/LICENSE b/sdk/vendor/golang.org/x/sys/LICENSE index 6a66aea5ea..2a7cf70da6 100644 --- a/sdk/vendor/golang.org/x/sys/LICENSE +++ b/sdk/vendor/golang.org/x/sys/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/sdk/vendor/golang.org/x/sys/unix/mkerrors.sh b/sdk/vendor/golang.org/x/sys/unix/mkerrors.sh index 4ed2e488b6..d07dd09eb5 100644 --- a/sdk/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/sdk/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -58,6 +58,7 @@ includes_Darwin=' #define _DARWIN_USE_64_BIT_INODE #define __APPLE_USE_RFC_3542 #include +#include #include #include #include diff --git a/sdk/vendor/golang.org/x/sys/unix/syscall_darwin.go b/sdk/vendor/golang.org/x/sys/unix/syscall_darwin.go index 4cc7b00596..2d15200adb 100644 --- a/sdk/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/sdk/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -402,6 +402,18 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq)) } +//sys renamexNp(from string, to string, flag uint32) (err error) + +func RenamexNp(from string, to string, flag uint32) (err error) { + return renamexNp(from, to, flag) +} + +//sys renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) + +func RenameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + return renameatxNp(fromfd, from, tofd, to, flag) +} + //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL func Uname(uname *Utsname) error { diff --git a/sdk/vendor/golang.org/x/sys/unix/syscall_linux.go b/sdk/vendor/golang.org/x/sys/unix/syscall_linux.go index 5682e2628a..3f1d3d4cb2 100644 --- a/sdk/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/sdk/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -2592,3 +2592,4 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { } //sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) +//sys Mseal(b []byte, flags uint) (err error) diff --git a/sdk/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/sdk/vendor/golang.org/x/sys/unix/syscall_openbsd.go index b25343c71a..b86ded549c 100644 --- a/sdk/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/sdk/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -293,6 +293,7 @@ func Uname(uname *Utsname) error { //sys Mkfifoat(dirfd int, path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index e40fa85245..4308ac1772 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index bb02aa6c05..c8068a7a16 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux.go index 877a62b479..01a70b2463 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -457,6 +457,7 @@ const ( B600 = 0x8 B75 = 0x2 B9600 = 0xd + BCACHEFS_SUPER_MAGIC = 0xca451a4e BDEVFS_MAGIC = 0x62646576 BINDERFS_SUPER_MAGIC = 0x6c6f6f70 BINFMTFS_MAGIC = 0x42494e4d @@ -928,6 +929,7 @@ const ( EPOLL_CTL_ADD = 0x1 EPOLL_CTL_DEL = 0x2 EPOLL_CTL_MOD = 0x3 + EPOLL_IOC_TYPE = 0x8a EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2 ESP_V4_FLOW = 0xa ESP_V6_FLOW = 0xc @@ -941,9 +943,6 @@ const ( ETHTOOL_FEC_OFF = 0x4 ETHTOOL_FEC_RS = 0x8 ETHTOOL_FLAG_ALL = 0x7 - ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 - ETHTOOL_FLAG_OMIT_REPLY = 0x2 - ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_FLASHDEV = 0x33 ETHTOOL_FLASH_MAX_FILENAME = 0x80 ETHTOOL_FWVERS_LEN = 0x20 @@ -1705,6 +1704,7 @@ const ( KEXEC_ARCH_S390 = 0x160000 KEXEC_ARCH_SH = 0x2a0000 KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_CRASH_HOTPLUG_SUPPORT = 0x8 KEXEC_FILE_DEBUG = 0x8 KEXEC_FILE_NO_INITRAMFS = 0x4 KEXEC_FILE_ON_CRASH = 0x2 @@ -1780,6 +1780,7 @@ const ( KEY_SPEC_USER_KEYRING = -0x4 KEY_SPEC_USER_SESSION_KEYRING = -0x5 LANDLOCK_ACCESS_FS_EXECUTE = 0x1 + LANDLOCK_ACCESS_FS_IOCTL_DEV = 0x8000 LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800 LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40 LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80 @@ -1861,6 +1862,19 @@ const ( MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_FIXED_NOREPLACE = 0x100000 + MAP_HUGE_16GB = 0x88000000 + MAP_HUGE_16KB = 0x38000000 + MAP_HUGE_16MB = 0x60000000 + MAP_HUGE_1GB = 0x78000000 + MAP_HUGE_1MB = 0x50000000 + MAP_HUGE_256MB = 0x70000000 + MAP_HUGE_2GB = 0x7c000000 + MAP_HUGE_2MB = 0x54000000 + MAP_HUGE_32MB = 0x64000000 + MAP_HUGE_512KB = 0x4c000000 + MAP_HUGE_512MB = 0x74000000 + MAP_HUGE_64KB = 0x40000000 + MAP_HUGE_8MB = 0x5c000000 MAP_HUGE_MASK = 0x3f MAP_HUGE_SHIFT = 0x1a MAP_PRIVATE = 0x2 @@ -2498,6 +2512,23 @@ const ( PR_PAC_GET_ENABLED_KEYS = 0x3d PR_PAC_RESET_KEYS = 0x36 PR_PAC_SET_ENABLED_KEYS = 0x3c + PR_PPC_DEXCR_CTRL_CLEAR = 0x4 + PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10 + PR_PPC_DEXCR_CTRL_EDITABLE = 0x1 + PR_PPC_DEXCR_CTRL_MASK = 0x1f + PR_PPC_DEXCR_CTRL_SET = 0x2 + PR_PPC_DEXCR_CTRL_SET_ONEXEC = 0x8 + PR_PPC_DEXCR_IBRTPD = 0x1 + PR_PPC_DEXCR_NPHIE = 0x3 + PR_PPC_DEXCR_SBHE = 0x0 + PR_PPC_DEXCR_SRAPD = 0x2 + PR_PPC_GET_DEXCR = 0x48 + PR_PPC_SET_DEXCR = 0x49 + PR_RISCV_CTX_SW_FENCEI_OFF = 0x1 + PR_RISCV_CTX_SW_FENCEI_ON = 0x0 + PR_RISCV_SCOPE_PER_PROCESS = 0x0 + PR_RISCV_SCOPE_PER_THREAD = 0x1 + PR_RISCV_SET_ICACHE_FLUSH_CTX = 0x47 PR_RISCV_V_GET_CONTROL = 0x46 PR_RISCV_V_SET_CONTROL = 0x45 PR_RISCV_V_VSTATE_CTRL_CUR_MASK = 0x3 @@ -3192,6 +3223,7 @@ const ( STATX_MTIME = 0x40 STATX_NLINK = 0x4 STATX_SIZE = 0x200 + STATX_SUBVOL = 0x8000 STATX_TYPE = 0x1 STATX_UID = 0x8 STATX__RESERVED = 0x80000000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index e4bc0bd57c..684a5168da 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 689317afdb..61d74b592d 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 5cca668ac3..a28c9e3e89 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 14270508b0..ab5d1fe8ea 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 ESR_MAGIC = 0x45535201 EXTPROC = 0x10000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 28e39afdcb..c523090e7c 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index cd66e92cb4..01e6ea7804 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index c1595eba78..7aa610b1e7 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ee9456b0da..92af771b44 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 8cfca81e1b..b27ef5e6f1 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 60b0deb3af..237a2cefb3 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index f90aa7281b..4a5c555a36 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index ba9e015033..a02fb49a5f 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 07cdfd6e9f..e26a7c61b2 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 2f1dd214a7..c48f7c2103 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index f40519d901..ad4b9aace7 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -82,6 +82,8 @@ const ( EFD_CLOEXEC = 0x400000 EFD_NONBLOCK = 0x4000 EMT_TAGOVF = 0x1 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x400000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 07642c308d..b622533ef2 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 923e08cb79..cfe6646baf 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 7d73dda647..13f624f69f 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 057700111e..fe222b75df 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 87d8612a1d..1bc1a5adb2 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -2229,3 +2229,19 @@ func Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mseal(b []byte, flags uint) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSEAL, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 9dc42410b7..1851df14e8 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s index 41b5617316..0b43c69365 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 0d3a0751cd..e1ec0dbe4e 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s index 4019a656f6..880c6d6e31 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index c39f7776db..7c8452a63e 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s index ac4af24f90..b8ef95b0fa 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 57571d072f..2ffdf861f7 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s index f77d532121..2af3b5c762 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index e62963e67e..1da08d5267 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s index fae140b62c..b7a251353b 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 00831354c8..6e85b0aac9 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s index 9d1e0ff06d..f15dadf055 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -555,6 +555,12 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mount(SB) + RET +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_nanosleep(SB) RET diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 79029ed584..28b487df25 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s index da115f9a4b..1e7f321e43 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/sdk/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 53aef5dc58..524b0820cb 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -457,4 +457,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 71d524763d..d3e38f681a 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -379,4 +379,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index c747706131..70b35bf3b0 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -421,4 +421,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index f96e214f6d..6c778c2327 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -324,4 +324,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go index 28425346cf..37281cf51a 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -318,4 +318,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index d0953018da..7e567f1eff 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 295c7f4b81..38ae55e5ef 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index d1a9eaca7a..55e92e60a8 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index bec157c39f..60658d6a02 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index 7ee7bdc435..e203e8a7ed 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -448,4 +448,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index fad1f25b44..5944b97d54 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 7d3e16357d..c66d416dad 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index 0ed53ad9f7..9889f6a559 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -325,4 +325,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 2fba04ad50..01d86825bb 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -386,4 +386,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 621d00d741..7b703e77cd 100644 --- a/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/sdk/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -399,4 +399,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/sdk/vendor/golang.org/x/sys/unix/ztypes_linux.go b/sdk/vendor/golang.org/x/sys/unix/ztypes_linux.go index 4740b83485..7f1961b907 100644 --- a/sdk/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/sdk/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -110,7 +110,8 @@ type Statx_t struct { Mnt_id uint64 Dio_mem_align uint32 Dio_offset_align uint32 - _ [12]uint64 + Subvol uint64 + _ [11]uint64 } type Fsid struct { @@ -3473,7 +3474,7 @@ const ( DEVLINK_PORT_FN_ATTR_STATE = 0x2 DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3 DEVLINK_PORT_FN_ATTR_CAPS = 0x4 - DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x5 + DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x6 ) type FsverityDigest struct { @@ -3806,6 +3807,9 @@ const ( ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 ETHTOOL_MSG_KERNEL_MAX = 0x2b + ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 + ETHTOOL_FLAG_OMIT_REPLY = 0x2 + ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 @@ -3975,7 +3979,7 @@ const ( ETHTOOL_A_TSINFO_TX_TYPES = 0x3 ETHTOOL_A_TSINFO_RX_FILTERS = 0x4 ETHTOOL_A_TSINFO_PHC_INDEX = 0x5 - ETHTOOL_A_TSINFO_MAX = 0x5 + ETHTOOL_A_TSINFO_MAX = 0x6 ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0 ETHTOOL_A_CABLE_TEST_HEADER = 0x1 ETHTOOL_A_CABLE_TEST_MAX = 0x1 diff --git a/sdk/vendor/golang.org/x/sys/windows/security_windows.go b/sdk/vendor/golang.org/x/sys/windows/security_windows.go index 97651b5bd0..b6e1ab76f8 100644 --- a/sdk/vendor/golang.org/x/sys/windows/security_windows.go +++ b/sdk/vendor/golang.org/x/sys/windows/security_windows.go @@ -1179,7 +1179,7 @@ type OBJECTS_AND_NAME struct { //sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD //sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW -//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) = advapi32.GetAce +//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) = advapi32.GetAce // Control returns the security descriptor control bits. func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { diff --git a/sdk/vendor/golang.org/x/sys/windows/syscall_windows.go b/sdk/vendor/golang.org/x/sys/windows/syscall_windows.go index 6525c62f3c..1fa34fd17c 100644 --- a/sdk/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/sdk/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -17,8 +17,10 @@ import ( "unsafe" ) -type Handle uintptr -type HWND uintptr +type ( + Handle uintptr + HWND uintptr +) const ( InvalidHandle = ^Handle(0) @@ -211,6 +213,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW //sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId +//sys LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) [failretval==0] = user32.LoadKeyboardLayoutW +//sys UnloadKeyboardLayout(hkl Handle) (err error) = user32.UnloadKeyboardLayout +//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout +//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx //sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow //sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW //sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx @@ -1368,9 +1374,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) { func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4) } + func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq))) } + func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { return syscall.EWINDOWS } diff --git a/sdk/vendor/golang.org/x/sys/windows/types_windows.go b/sdk/vendor/golang.org/x/sys/windows/types_windows.go index d8cb71db0a..3f03b3d57c 100644 --- a/sdk/vendor/golang.org/x/sys/windows/types_windows.go +++ b/sdk/vendor/golang.org/x/sys/windows/types_windows.go @@ -2003,7 +2003,21 @@ const ( MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20 ) -const GAA_FLAG_INCLUDE_PREFIX = 0x00000010 +// Flags for GetAdaptersAddresses, see +// https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses. +const ( + GAA_FLAG_SKIP_UNICAST = 0x1 + GAA_FLAG_SKIP_ANYCAST = 0x2 + GAA_FLAG_SKIP_MULTICAST = 0x4 + GAA_FLAG_SKIP_DNS_SERVER = 0x8 + GAA_FLAG_INCLUDE_PREFIX = 0x10 + GAA_FLAG_SKIP_FRIENDLY_NAME = 0x20 + GAA_FLAG_INCLUDE_WINS_INFO = 0x40 + GAA_FLAG_INCLUDE_GATEWAYS = 0x80 + GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x100 + GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x200 + GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400 +) const ( IF_TYPE_OTHER = 1 @@ -2017,6 +2031,50 @@ const ( IF_TYPE_IEEE1394 = 144 ) +// Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin +const ( + IpPrefixOriginOther = 0 + IpPrefixOriginManual = 1 + IpPrefixOriginWellKnown = 2 + IpPrefixOriginDhcp = 3 + IpPrefixOriginRouterAdvertisement = 4 + IpPrefixOriginUnchanged = 1 << 4 +) + +// Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin +const ( + NlsoOther = 0 + NlsoManual = 1 + NlsoWellKnown = 2 + NlsoDhcp = 3 + NlsoLinkLayerAddress = 4 + NlsoRandom = 5 + IpSuffixOriginOther = 0 + IpSuffixOriginManual = 1 + IpSuffixOriginWellKnown = 2 + IpSuffixOriginDhcp = 3 + IpSuffixOriginLinkLayerAddress = 4 + IpSuffixOriginRandom = 5 + IpSuffixOriginUnchanged = 1 << 4 +) + +// Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state +const ( + NldsInvalid = 0 + NldsTentative = 1 + NldsDuplicate = 2 + NldsDeprecated = 3 + NldsPreferred = 4 + IpDadStateInvalid = 0 + IpDadStateTentative = 1 + IpDadStateDuplicate = 2 + IpDadStateDeprecated = 3 + IpDadStatePreferred = 4 +) + type SocketAddress struct { Sockaddr *syscall.RawSockaddrAny SockaddrLength int32 @@ -3404,3 +3462,14 @@ type DCB struct { EvtChar byte wReserved1 uint16 } + +// Keyboard Layout Flags. +// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw +const ( + KLF_ACTIVATE = 0x00000001 + KLF_SUBSTITUTE_OK = 0x00000002 + KLF_REORDER = 0x00000008 + KLF_REPLACELANG = 0x00000010 + KLF_NOTELLSHELL = 0x00000080 + KLF_SETFORPROCESS = 0x00000100 +) diff --git a/sdk/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/sdk/vendor/golang.org/x/sys/windows/zsyscall_windows.go index eba761018a..9bb979a3e4 100644 --- a/sdk/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/sdk/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -478,12 +478,16 @@ var ( procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow") procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow") procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo") + procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout") procGetShellWindow = moduser32.NewProc("GetShellWindow") procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") procIsWindow = moduser32.NewProc("IsWindow") procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode") procIsWindowVisible = moduser32.NewProc("IsWindowVisible") + procLoadKeyboardLayoutW = moduser32.NewProc("LoadKeyboardLayoutW") procMessageBoxW = moduser32.NewProc("MessageBoxW") + procToUnicodeEx = moduser32.NewProc("ToUnicodeEx") + procUnloadKeyboardLayout = moduser32.NewProc("UnloadKeyboardLayout") procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") @@ -789,6 +793,14 @@ func FreeSid(sid *SID) (err error) { return } +func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) { + r1, _, e1 := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func GetLengthSid(sid *SID) (len uint32) { r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) len = uint32(r0) @@ -1225,14 +1237,6 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE return } -func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) { - r0, _, _ := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) - if r0 == 0 { - ret = GetLastError() - } - return -} - func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) { r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor))) if r1 == 0 { @@ -4082,6 +4086,12 @@ func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) { return } +func GetKeyboardLayout(tid uint32) (hkl Handle) { + r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(tid), 0, 0) + hkl = Handle(r0) + return +} + func GetShellWindow() (shellWindow HWND) { r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0) shellWindow = HWND(r0) @@ -4115,6 +4125,15 @@ func IsWindowVisible(hwnd HWND) (isVisible bool) { return } +func LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) { + r0, _, e1 := syscall.Syscall(procLoadKeyboardLayoutW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(flags), 0) + hkl = Handle(r0) + if hkl == 0 { + err = errnoErr(e1) + } + return +} + func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) ret = int32(r0) @@ -4124,6 +4143,20 @@ func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret i return } +func ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) { + r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(vkey), uintptr(scancode), uintptr(unsafe.Pointer(keystate)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(flags), uintptr(hkl), 0, 0) + ret = int32(r0) + return +} + +func UnloadKeyboardLayout(hkl Handle) (err error) { + r1, _, e1 := syscall.Syscall(procUnloadKeyboardLayout.Addr(), 1, uintptr(hkl), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) { var _p0 uint32 if inheritExisting { diff --git a/sdk/vendor/modules.txt b/sdk/vendor/modules.txt index 0e518d815f..c9841dbd19 100644 --- a/sdk/vendor/modules.txt +++ b/sdk/vendor/modules.txt @@ -79,7 +79,7 @@ golang.org/x/net/trace # golang.org/x/sync v0.7.0 ## explicit; go 1.18 golang.org/x/sync/errgroup -# golang.org/x/sys v0.22.0 +# golang.org/x/sys v0.24.0 ## explicit; go 1.18 golang.org/x/sys/unix golang.org/x/sys/windows diff --git a/src/core/config/config.go b/src/core/config/config.go index addc4604b4..dfee04b1bc 100644 --- a/src/core/config/config.go +++ b/src/core/config/config.go @@ -429,12 +429,11 @@ func LoadPropertiesFromFile(cfg string) error { if err != nil { return fmt.Errorf("error attempting to open dynamic config (%s): %v", dynamicCfgPath, err) } - + defer dynCfg.Close() featuresAreSet, cleanDynCfgContent, err := removeFeatures(dynCfg) if err != nil { return fmt.Errorf("error updating dynamic config with features removed (%s): %v", dynamicCfgPath, err) } - dynCfg.Close() if featuresAreSet { err = os.WriteFile(dynamicCfgPath, cleanDynCfgContent, 0o640) diff --git a/src/core/config/leak_test.go b/src/core/config/leak_test.go new file mode 100644 index 0000000000..13e0f351f2 --- /dev/null +++ b/src/core/config/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +package config + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/core/environment.go b/src/core/environment.go index 7ddfb52690..5bb0355aa3 100644 --- a/src/core/environment.go +++ b/src/core/environment.go @@ -408,7 +408,7 @@ func getContainerID(mountInfo string) (string, error) { if err != nil { return "", fmt.Errorf("could not read %s: %v", mountInfo, err) } - + defer mInfoFile.Close() fileScanner := bufio.NewScanner(mInfoFile) fileScanner.Split(bufio.ScanLines) @@ -416,10 +416,6 @@ func getContainerID(mountInfo string) (string, error) { for fileScanner.Scan() { lines = append(lines, fileScanner.Text()) } - err = mInfoFile.Close() - if err != nil { - return "", fmt.Errorf("unable to close file %s: %v", mountInfo, err) - } for _, line := range lines { splitLine := strings.Split(line, " ") diff --git a/src/core/leak_test.go b/src/core/leak_test.go new file mode 100644 index 0000000000..aca7a3351b --- /dev/null +++ b/src/core/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +package core + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/core/metrics/aggregate.go b/src/core/metrics/aggregate.go index 663f995737..77d3f1e60e 100644 --- a/src/core/metrics/aggregate.go +++ b/src/core/metrics/aggregate.go @@ -30,8 +30,9 @@ type PerDimension struct { type MetricsHandler func(float64, int) float64 type Collections struct { - Count int // this is the number of collections run. Will use this to calculate the average. - Data map[string]PerDimension + Count int // this is the number of collections run. Will use this to calculate the average. + MetricsCount map[string]PerDimension + Data map[string]PerDimension } func dimChecksum(stats *proto.StatsEntity) string { @@ -59,15 +60,22 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe } } + if _, ok := metricsCollections.MetricsCount[dimensionsChecksum]; !ok { + metricsCollections.MetricsCount[dimensionsChecksum] = PerDimension{ + Dimensions: stats.GetDimensions(), + RunningSumMap: make(map[string]float64), + } + } + simpleMetrics := stats.GetSimplemetrics() - if simpleMetrics != nil { - for _, simpleMetric := range simpleMetrics { - if metrics, ok := metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name]; ok { - metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = metrics + simpleMetric.GetValue() - } else { - metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = simpleMetric.GetValue() - } + for _, simpleMetric := range simpleMetrics { + if metrics, ok := metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name]; ok { + metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name]++ + metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = metrics + simpleMetric.GetValue() + } else { + metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = 1 + metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = simpleMetric.GetValue() } } } @@ -79,8 +87,8 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe func GenerateMetrics(metricsCollections Collections) []*proto.StatsEntity { results := make([]*proto.StatsEntity, 0, 200) - for _, metricsPerDimension := range metricsCollections.Data { - simpleMetrics := getAggregatedSimpleMetric(metricsCollections.Count, metricsPerDimension.RunningSumMap) + for name, metricsPerDimension := range metricsCollections.Data { + simpleMetrics := getAggregatedSimpleMetric(metricsCollections.MetricsCount[name], metricsPerDimension.RunningSumMap) results = append(results, NewStatsEntity( metricsPerDimension.Dimensions, simpleMetrics, @@ -90,7 +98,7 @@ func GenerateMetrics(metricsCollections Collections) []*proto.StatsEntity { return results } -func getAggregatedSimpleMetric(count int, internalMap map[string]float64) (simpleMetrics []*proto.SimpleMetric) { +func getAggregatedSimpleMetric(count PerDimension, internalMap map[string]float64) (simpleMetrics []*proto.SimpleMetric) { variableMetrics := map[*regexp.Regexp]MetricsHandler{ failsRegex: sum, freeRegex: avg, @@ -105,13 +113,13 @@ func getAggregatedSimpleMetric(count int, internalMap map[string]float64) (simpl var aggregatedValue float64 switch valueType { case "sum": - aggregatedValue = sum(value, count) + aggregatedValue = sum(value, int(count.RunningSumMap[name])) case "avg": - aggregatedValue = avg(value, count) + aggregatedValue = avg(value, int(count.RunningSumMap[name])) case "boolean": - aggregatedValue = boolean(value, count) + aggregatedValue = boolean(value, int(count.RunningSumMap[name])) } // Only aggregate metrics when the aggregation method is defined @@ -122,7 +130,7 @@ func getAggregatedSimpleMetric(count int, internalMap map[string]float64) (simpl } else { for reg, calculation := range variableMetrics { if reg.MatchString(name) { - result := calculation(value, count) + result := calculation(value, int(count.RunningSumMap[name])) simpleMetrics = append(simpleMetrics, &proto.SimpleMetric{ Name: name, diff --git a/src/core/metrics/aggregate_test.go b/src/core/metrics/aggregate_test.go index 86e4d465cc..a3a98fae03 100644 --- a/src/core/metrics/aggregate_test.go +++ b/src/core/metrics/aggregate_test.go @@ -10,6 +10,7 @@ package metrics import ( "encoding/json" "fmt" + "sort" "testing" log "github.com/sirupsen/logrus" @@ -19,109 +20,231 @@ import ( "github.com/stretchr/testify/assert" ) -func TestSaveCollections(t *testing.T) { - reports := []*proto.MetricsReport{ - { - Meta: &proto.Metadata{}, - Type: proto.MetricsReport_SYSTEM, - Data: []*proto.StatsEntity{ - { - Simplemetrics: []*proto.SimpleMetric{ - { - Name: "system.mem.used", - Value: 5, - }, - { - Name: "system.io.kbs_w", - Value: 5.3, - }, - { - Name: "system.cpu.system", - Value: 2.4, - }, - { - Name: "system.cpu.user", - Value: 6.8, - }, +var reports = []*proto.MetricsReport{ + { + Meta: &proto.Metadata{}, + Type: proto.MetricsReport_SYSTEM, + Data: []*proto.StatsEntity{ + { + Simplemetrics: []*proto.SimpleMetric{ + { + Name: "system.mem.used", + Value: 5, }, - Dimensions: []*proto.Dimension{ - { - Name: "hostname", - Value: "test-host", - }, + { + Name: "system.io.kbs_w", + Value: 5.3, + }, + { + Name: "system.cpu.system", + Value: 2.4, + }, + { + Name: "system.cpu.user", + Value: 6.8, + }, + }, + Dimensions: []*proto.Dimension{ + { + Name: "hostname", + Value: "test-host", + }, + }, + }, + }, + }, + { + Meta: &proto.Metadata{}, + Type: proto.MetricsReport_SYSTEM, + Data: []*proto.StatsEntity{ + { + Simplemetrics: []*proto.SimpleMetric{ + { + Name: "system.mem.used", + Value: 6, + }, + { + Name: "system.io.kbs_w", + Value: 7.3, + }, + { + Name: "system.cpu.system", + Value: 8.3, + }, + { + Name: "system.cpu.user", + Value: 3.8, + }, + }, + Dimensions: []*proto.Dimension{ + { + Name: "hostname", + Value: "test-host2", }, }, }, }, + }, +} + +func TestSaveCollections(t *testing.T) { + tests := []struct { + name string + reports []*proto.MetricsReport + expected map[string]float64 + }{ { - Meta: &proto.Metadata{}, - Type: proto.MetricsReport_SYSTEM, - Data: []*proto.StatsEntity{ - { - Simplemetrics: []*proto.SimpleMetric{ - { - Name: "system.mem.used", - Value: 6, - }, - { - Name: "system.io.kbs_w", - Value: 7.3, - }, - { - Name: "system.cpu.system", - Value: 8.3, - }, - { - Name: "system.cpu.user", - Value: 3.8, + name: "save collection test", + reports: reports, + expected: map[string]float64{ + "system.mem.used": 5, + "system.io.kbs_w": 5.3, + "system.io.kbs_r": 0, + "system.cpu.system": 2.4, + "system.cpu.user": 6.8, + }, + }, + { + name: "save collection test with duplicates", + reports: append(reports, &proto.MetricsReport{ + Meta: &proto.Metadata{}, + Type: proto.MetricsReport_SYSTEM, + Data: []*proto.StatsEntity{ + { + Simplemetrics: []*proto.SimpleMetric{ + { + Name: "system.mem.used", + Value: 7, + }, + { + Name: "system.io.kbs_w", + Value: 4.3, + }, + { + Name: "system.cpu.system", + Value: 2.3, + }, + { + Name: "system.cpu.user", + Value: 1.8, + }, }, - }, - Dimensions: []*proto.Dimension{ - { - Name: "hostname", - Value: "test-host2", + Dimensions: []*proto.Dimension{ + { + Name: "hostname", + Value: "test-host", + }, }, }, }, + }), + expected: map[string]float64{ + "system.mem.used": 12, + "system.io.kbs_w": 9.6, + "system.io.kbs_r": 0, + "system.cpu.system": 4.699999999999999, + "system.cpu.user": 8.6, }, }, } + for _, test := range tests { + + metricsCollections := Collections{ + Count: len(test.reports), + Data: make(map[string]PerDimension), + MetricsCount: make(map[string]PerDimension), + } + dimension1 := []*proto.Dimension{ + { + Name: "hostname", + Value: "test-host", + }, + } + var dimensionsChecksum string + data, err := json.Marshal(dimension1) + if err == nil { + dimensionsChecksum = checksum.HexChecksum(data) + } else { + dimensionsChecksum = checksum.HexChecksum([]byte(fmt.Sprintf("%v", dimension1))) + } + metricsCollections.Data[dimensionsChecksum] = PerDimension{ + Dimensions: dimension1, + RunningSumMap: make(map[string]float64), + } + + metricsCollections.MetricsCount[dimensionsChecksum] = PerDimension{ + Dimensions: dimension1, + RunningSumMap: make(map[string]float64), + } + + metricsCollections = SaveCollections(metricsCollections, test.reports...) + log.Info(metricsCollections) + + assert.NotNil(t, metricsCollections) + + for key, value := range test.expected { + assert.Equal(t, value, metricsCollections.Data[dimensionsChecksum].RunningSumMap[key]) + } + } +} + +func TestGenerateMetrics(t *testing.T) { metricsCollections := Collections{ Count: 2, - Data: make(map[string]PerDimension), + Data: map[string]PerDimension{ + "checksum1": { + Dimensions: []*proto.Dimension{ + {Name: "hostname", Value: "test-host"}, + }, + RunningSumMap: map[string]float64{ + "system.mem.used": 20.0, + "system.cpu.system": 10.0, + }, + }, + }, + MetricsCount: map[string]PerDimension{ + "checksum1": { + Dimensions: []*proto.Dimension{ + {Name: "hostname", Value: "test-host"}, + }, + RunningSumMap: map[string]float64{ + "system.mem.used": 2, + "system.cpu.system": 2, + }, + }, + }, } - dimension1 := []*proto.Dimension{ + + results := GenerateMetrics(metricsCollections) + + expectedResults := []*proto.StatsEntity{ { - Name: "hostname", - Value: "test-host", + Dimensions: []*proto.Dimension{ + {Name: "hostname", Value: "test-host"}, + }, + Simplemetrics: []*proto.SimpleMetric{ + {Name: "system.mem.used", Value: 10.0}, + {Name: "system.cpu.system", Value: 5.0}, + }, }, } - var dimensionsChecksum string - data, err := json.Marshal(dimension1) - if err == nil { - dimensionsChecksum = checksum.HexChecksum(data) - } else { - dimensionsChecksum = checksum.HexChecksum([]byte(fmt.Sprintf("%v", dimension1))) - } - metricsCollections.Data[dimensionsChecksum] = PerDimension{ - Dimensions: dimension1, - RunningSumMap: make(map[string]float64), + + assert.Equal(t, len(expectedResults), len(results)) + for i, expected := range expectedResults { + assert.Equal(t, expected.GetDimensions(), results[i].GetDimensions()) + assert.Equal(t, len(expected.GetSimplemetrics()), len(results[i].GetSimplemetrics())) + + metrics := results[i].GetSimplemetrics() + sort.Slice(metrics, func(k, l int) bool { + return metrics[k].GetName() > metrics[l].GetName() + }) + + for j, expectedMetric := range expected.GetSimplemetrics() { + assert.Equal(t, expectedMetric.GetName(), results[i].GetSimplemetrics()[j].GetName()) + assert.Equal(t, expectedMetric.GetValue(), results[i].GetSimplemetrics()[j].GetValue()) + } } - metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.mem.used"] = 6.2 - metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.io.kbs_w"] = 3.4 - metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.io.kbs_r"] = 2.3 - metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.cpu.system"] = 6.2 - - metricsCollections = SaveCollections(metricsCollections, reports...) - log.Info(metricsCollections) - - assert.NotNil(t, metricsCollections) - assert.Equal(t, 11.2, metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.mem.used"]) - assert.Equal(t, 8.7, metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.io.kbs_w"]) - assert.Equal(t, 2.3, metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.io.kbs_r"]) - assert.Equal(t, 8.6, metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.cpu.system"]) - assert.Equal(t, 6.8, metricsCollections.Data[dimensionsChecksum].RunningSumMap["system.cpu.user"]) } func TestGenerateAggregationReport(t *testing.T) { @@ -155,41 +278,40 @@ func TestGenerateAggregationReport(t *testing.T) { for _, v := range simplemetrics { switch { case v.Name == "system.mem.used": - assert.Equal(t, float64(50.1), v.Value) + assert.Equal(t, float64(100.2), v.Value) case v.Name == "system.io.kbs_w": assert.Equal(t, float64(600), v.Value) case v.Name == "system.io.kbs_r": assert.Equal(t, float64(6000), v.Value) case v.Name == "system.cpu.system": - assert.Equal(t, float64(100.1), v.Value) + assert.Equal(t, float64(200.2), v.Value) case v.Name == "system.undefined_method": assert.Equal(t, float64(1000), v.Value) } } - } } func TestAvg(t *testing.T) { - result := avg(float64(2.12), 2) - assert.Equal(t, float64(1.06), result) + result := avg(2.12, 2) + assert.Equal(t, 1.06, result) - result = avg(float64(2.12), 0) - assert.Equal(t, float64(2.12), result) + result = avg(2.12, 0) + assert.Equal(t, 2.12, result) } func TestSum(t *testing.T) { - result := sum(float64(2.12), 2) - assert.Equal(t, float64(2.12), result) + result := sum(2.12, 2) + assert.Equal(t, 2.12, result) } func TestBoolean(t *testing.T) { - result := boolean(float64(2.12), 2) + result := boolean(2.12, 2) assert.Equal(t, 1.0, result) - result = boolean(float64(0.2), 2) + result = boolean(0.2, 2) assert.Equal(t, 0.0, result) - result = boolean(float64(2.12), 0) + result = boolean(2.12, 0) assert.Equal(t, 2.12, result) } diff --git a/src/core/metrics/collectors/container.go b/src/core/metrics/collectors/container.go index e0e60d4b75..1c7cf82292 100644 --- a/src/core/metrics/collectors/container.go +++ b/src/core/metrics/collectors/container.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" log "github.com/sirupsen/logrus" @@ -46,18 +45,12 @@ func NewContainerCollector(env core.Environment, conf *config.Config) *Container } func (c *ContainerCollector) collectMetrics(ctx context.Context) { - // using a separate WaitGroup, since we need to wait for our own buffer to be filled - // this ensures the collection is done before our own for/select loop to pull things off the buf - wg := &sync.WaitGroup{} for _, containerSource := range c.sources { - wg.Add(1) - go containerSource.Collect(ctx, wg, c.buf) + go containerSource.Collect(ctx, c.buf) } - wg.Wait() } -func (c *ContainerCollector) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *ContainerCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectMetrics(ctx) commonDims := c.dim.ToDimensions() diff --git a/src/core/metrics/collectors/container_test.go b/src/core/metrics/collectors/container_test.go index bb8cc95974..1ef4636377 100644 --- a/src/core/metrics/collectors/container_test.go +++ b/src/core/metrics/collectors/container_test.go @@ -10,8 +10,8 @@ package collectors import ( "context" "reflect" - "sync" "testing" + "time" "github.com/stretchr/testify/assert" @@ -62,15 +62,14 @@ func TestContainerCollector_Collect(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) - channel := make(chan *metrics.StatsEntityWrapper) - go containerCollector.Collect(ctx, wg, channel) + go containerCollector.Collect(ctx, channel) containerCollector.buf <- &metrics.StatsEntityWrapper{Type: proto.MetricsReport_SYSTEM, Data: &proto.StatsEntity{Dimensions: []*proto.Dimension{{Name: "new_dim", Value: "123"}}}} actual := <-channel + time.Sleep(100 * time.Millisecond) + mockSource1.AssertExpectations(t) mockSource2.AssertExpectations(t) diff --git a/src/core/metrics/collectors/leak_test.go b/src/core/metrics/collectors/leak_test.go new file mode 100644 index 0000000000..970818c307 --- /dev/null +++ b/src/core/metrics/collectors/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +package collectors + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/core/metrics/collectors/nginx.go b/src/core/metrics/collectors/nginx.go index f2e58ae505..b6355e6929 100644 --- a/src/core/metrics/collectors/nginx.go +++ b/src/core/metrics/collectors/nginx.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" agent_config "github.com/nginx/agent/sdk/v2/agent/config" "github.com/nginx/agent/v2/src/core" @@ -73,18 +72,12 @@ func buildSources(dimensions *metrics.CommonDim, binary core.NginxBinary, collec } func (c *NginxCollector) collectMetrics(ctx context.Context) { - // using a separate WaitGroup, since we need to wait for our own buffer to be filled - // this ensures the collection is done before our own for/select loop to pull things off the buf - wg := &sync.WaitGroup{} for _, nginxSource := range c.sources { - wg.Add(1) - go nginxSource.Collect(ctx, wg, c.buf) + go nginxSource.Collect(ctx, c.buf) } - wg.Wait() } -func (c *NginxCollector) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectMetrics(ctx) for { select { diff --git a/src/core/metrics/collectors/nginx_test.go b/src/core/metrics/collectors/nginx_test.go index 1dea9cb536..0b08fe9462 100644 --- a/src/core/metrics/collectors/nginx_test.go +++ b/src/core/metrics/collectors/nginx_test.go @@ -10,8 +10,8 @@ package collectors import ( "context" "reflect" - "sync" "testing" + "time" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -173,10 +173,9 @@ func TestNginxCollector_Collect(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) - go nginxCollector.Collect(ctx, wg, make(chan<- *metrics.StatsEntityWrapper)) - wg.Wait() + go nginxCollector.Collect(ctx, make(chan<- *metrics.StatsEntityWrapper)) + + time.Sleep(100 * time.Millisecond) mockNginxSource1.AssertExpectations(t) mockNginxSource2.AssertExpectations(t) diff --git a/src/core/metrics/collectors/source_mocks_test.go b/src/core/metrics/collectors/source_mocks_test.go index b6fa5a5ad2..bff1e1683f 100644 --- a/src/core/metrics/collectors/source_mocks_test.go +++ b/src/core/metrics/collectors/source_mocks_test.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" "github.com/nginx/agent/v2/src/core/metrics" "github.com/stretchr/testify/mock" @@ -17,7 +16,7 @@ import ( func GetNginxSourceMock() *NginxSourceMock { mockSource := new(NginxSourceMock) - mockSource.On("Collect", mock.Anything, mock.Anything, mock.Anything).Once() + mockSource.On("Collect", mock.Anything, mock.Anything).Once() return mockSource } @@ -25,9 +24,8 @@ type NginxSourceMock struct { mock.Mock } -func (m *NginxSourceMock) Collect(ctx context.Context, wg *sync.WaitGroup, statsChannel chan<- *metrics.StatsEntityWrapper) { - m.Called(ctx, wg, statsChannel) - wg.Done() +func (m *NginxSourceMock) Collect(ctx context.Context, statsChannel chan<- *metrics.StatsEntityWrapper) { + m.Called(ctx, statsChannel) } func (m *NginxSourceMock) Update(dimensions *metrics.CommonDim, collectorConf *metrics.NginxCollectorConfig) { @@ -42,7 +40,6 @@ type SourceMock struct { mock.Mock } -func (m *SourceMock) Collect(ctx context.Context, wg *sync.WaitGroup, statsChannel chan<- *metrics.StatsEntityWrapper) { - m.Called(ctx, wg, statsChannel) - wg.Done() +func (m *SourceMock) Collect(ctx context.Context, statsChannel chan<- *metrics.StatsEntityWrapper) { + m.Called(ctx, statsChannel) } diff --git a/src/core/metrics/collectors/system.go b/src/core/metrics/collectors/system.go index a92c4a7b8e..cd91e7b1c7 100644 --- a/src/core/metrics/collectors/system.go +++ b/src/core/metrics/collectors/system.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" @@ -57,18 +56,12 @@ func NewSystemCollector(env core.Environment, conf *config.Config) *SystemCollec } func (c *SystemCollector) collectMetrics(ctx context.Context) { - // using a separate WaitGroup, since we need to wait for our own buffer to be filled - // this ensures the collection is done before our own for/select loop to pull things off the buf - wg := &sync.WaitGroup{} for _, systemSource := range c.sources { - wg.Add(1) - go systemSource.Collect(ctx, wg, c.buf) + go systemSource.Collect(ctx, c.buf) } - wg.Wait() } -func (c *SystemCollector) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *SystemCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectMetrics(ctx) commonDims := c.dim.ToDimensions() diff --git a/src/core/metrics/collectors/system_test.go b/src/core/metrics/collectors/system_test.go index a7cd9bdebc..a965548cad 100644 --- a/src/core/metrics/collectors/system_test.go +++ b/src/core/metrics/collectors/system_test.go @@ -10,8 +10,8 @@ package collectors import ( "context" "reflect" - "sync" "testing" + "time" "github.com/stretchr/testify/assert" @@ -94,15 +94,15 @@ func TestSystemCollector_Collect(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper) - go systemCollector.Collect(ctx, wg, channel) + go systemCollector.Collect(ctx, channel) systemCollector.buf <- &metrics.StatsEntityWrapper{Type: proto.MetricsReport_SYSTEM, Data: &proto.StatsEntity{Dimensions: []*proto.Dimension{{Name: "new_dim", Value: "123"}}}} actual := <-channel + time.Sleep(100 * time.Millisecond) + mockSource1.AssertExpectations(t) mockSource2.AssertExpectations(t) diff --git a/src/core/metrics/leak_test.go b/src/core/metrics/leak_test.go new file mode 100644 index 0000000000..e814bcd1c5 --- /dev/null +++ b/src/core/metrics/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +package metrics + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/core/metrics/metrics_util.go b/src/core/metrics/metrics_util.go index 43b2ea7381..4128c87e5e 100644 --- a/src/core/metrics/metrics_util.go +++ b/src/core/metrics/metrics_util.go @@ -11,7 +11,6 @@ import ( "context" "math" "sort" - "sync" "time" "github.com/nginx/agent/sdk/v2/proto" @@ -22,16 +21,16 @@ import ( ) type Collector interface { - Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *StatsEntityWrapper) + Collect(ctx context.Context, m chan<- *StatsEntityWrapper) UpdateConfig(config *config.Config) } type Source interface { - Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *StatsEntityWrapper) + Collect(ctx context.Context, m chan<- *StatsEntityWrapper) } type NginxSource interface { - Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *StatsEntityWrapper) + Collect(ctx context.Context, m chan<- *StatsEntityWrapper) Update(dimensions *CommonDim, collectorConf *NginxCollectorConfig) Stop() } diff --git a/src/core/metrics/sources/cgroup/leak_test.go b/src/core/metrics/sources/cgroup/leak_test.go new file mode 100644 index 0000000000..7755cf68cd --- /dev/null +++ b/src/core/metrics/sources/cgroup/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +package cgroup + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/core/metrics/sources/common.go b/src/core/metrics/sources/common.go index 3041ee5121..1a942a1e9f 100644 --- a/src/core/metrics/sources/common.go +++ b/src/core/metrics/sources/common.go @@ -13,6 +13,7 @@ import ( "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" + log "github.com/sirupsen/logrus" ) const ( @@ -91,6 +92,8 @@ func Delta(current, previous map[string]map[string]float64) map[string]map[strin func SendNginxDownStatus(ctx context.Context, dims []*proto.Dimension, m chan<- *metrics.StatsEntityWrapper) { simpleMetrics := []*proto.SimpleMetric{newFloatMetric("nginx.status", float64(0))} + log.Debugf("nginx down status %d", len(simpleMetrics)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper(dims, simpleMetrics, proto.MetricsReport_INSTANCE): diff --git a/src/core/metrics/sources/container_cpu.go b/src/core/metrics/sources/container_cpu.go index 474f6871c0..998b1653fc 100644 --- a/src/core/metrics/sources/container_cpu.go +++ b/src/core/metrics/sources/container_cpu.go @@ -13,7 +13,6 @@ import ( "path" "strconv" "strings" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" @@ -47,9 +46,8 @@ func NewContainerCPUSource(namespace string, basePath string) *ContainerCPU { return &ContainerCPU{basePath, cgroup.IsCgroupV2(basePath), NewMetricSourceLogger(), &namedMetric{namespace, CpuGroup}} } -func (c *ContainerCPU) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerCPU) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { log.Trace("Collecting container CPU metrics") - defer wg.Done() containerStats := map[string]float64{} diff --git a/src/core/metrics/sources/container_cpu_test.go b/src/core/metrics/sources/container_cpu_test.go index 27212b7c7c..ba054a577a 100644 --- a/src/core/metrics/sources/container_cpu_test.go +++ b/src/core/metrics/sources/container_cpu_test.go @@ -12,7 +12,6 @@ import ( "path" "runtime" "sort" - "sync" "testing" "time" @@ -120,12 +119,9 @@ func TestContainerCPUSource(t *testing.T) { t.Run(test.name, func(tt *testing.T) { actual := make(chan *metrics.StatsEntityWrapper, 1) ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) containerCPUSource := NewContainerCPUSource("container", test.basePath) - go containerCPUSource.Collect(ctx, wg, actual) - wg.Wait() + go containerCPUSource.Collect(ctx, actual) select { case result := <-actual: diff --git a/src/core/metrics/sources/container_mem.go b/src/core/metrics/sources/container_mem.go index 01d0bcd7ce..086ac5b345 100644 --- a/src/core/metrics/sources/container_mem.go +++ b/src/core/metrics/sources/container_mem.go @@ -13,7 +13,6 @@ import ( "path" "strconv" "strings" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" @@ -40,9 +39,8 @@ func NewContainerMemorySource(namespace string, basePath string) *ContainerMemor return &ContainerMemory{basePath, cgroup.IsCgroupV2(basePath), NewMetricSourceLogger(), &namedMetric{namespace, MemoryGroup}} } -func (c *ContainerMemory) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerMemory) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { log.Trace("Collecting container memory metrics") - defer wg.Done() var containerStats map[string]float64 diff --git a/src/core/metrics/sources/container_mem_test.go b/src/core/metrics/sources/container_mem_test.go index 9c1fccf584..096b8c65e2 100644 --- a/src/core/metrics/sources/container_mem_test.go +++ b/src/core/metrics/sources/container_mem_test.go @@ -12,7 +12,6 @@ import ( "path" "runtime" "sort" - "sync" "testing" "time" @@ -64,12 +63,9 @@ func TestContainerMemorySource(t *testing.T) { t.Run(test.name, func(tt *testing.T) { actual := make(chan *metrics.StatsEntityWrapper, 1) ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) containerMemorySource := NewContainerMemorySource("container", test.basePath) - go containerMemorySource.Collect(ctx, wg, actual) - wg.Wait() + go containerMemorySource.Collect(ctx, actual) select { case result := <-actual: diff --git a/src/core/metrics/sources/cpu.go b/src/core/metrics/sources/cpu.go index 520c8f550e..f7bb0046ca 100644 --- a/src/core/metrics/sources/cpu.go +++ b/src/core/metrics/sources/cpu.go @@ -69,8 +69,7 @@ func diffTimeStat(t1, t2 cpu.TimesStat) cpu.TimesStat { } } -func (c *CPUTimes) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *CPUTimes) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { var simpleMetrics []*proto.SimpleMetric if c.isDocker { dockerCpuPercentages, err := c.cgroupCPUSource.Percentages() diff --git a/src/core/metrics/sources/cpu_test.go b/src/core/metrics/sources/cpu_test.go index af20233ce3..d4582cd04d 100644 --- a/src/core/metrics/sources/cpu_test.go +++ b/src/core/metrics/sources/cpu_test.go @@ -12,7 +12,6 @@ import ( "path" "runtime" "sort" - "sync" "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -104,11 +103,8 @@ func TestCPUTimesCollect_VM(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 1) - cpuTimes.Collect(ctx, wg, channel) - wg.Wait() + cpuTimes.Collect(ctx, channel) actual := <-channel @@ -147,11 +143,9 @@ func TestCPUTimesCollect_VM(t *testing.T) { } ctx = context.TODO() - wg = &sync.WaitGroup{} - wg.Add(1) + channel = make(chan *metrics.StatsEntityWrapper, 1) - cpuTimes.Collect(ctx, wg, channel) - wg.Wait() + cpuTimes.Collect(ctx, channel) actual = <-channel @@ -190,11 +184,10 @@ func TestCPUTimesCollect_Container(t *testing.T) { cgroup.CpuStatsPath = localDirectory + "/testdata/proc/stat" ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) + channel := make(chan *metrics.StatsEntityWrapper, 1) - cpuTimes.Collect(ctx, wg, channel) - wg.Wait() + cpuTimes.Collect(ctx, channel) + actual := <-channel actualMetricNames := []string{} diff --git a/src/core/metrics/sources/disk.go b/src/core/metrics/sources/disk.go index 4721330979..98a3847a2d 100644 --- a/src/core/metrics/sources/disk.go +++ b/src/core/metrics/sources/disk.go @@ -10,11 +10,11 @@ package sources import ( "context" "fmt" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/metrics" + log "github.com/sirupsen/logrus" ) const MOUNT_POINT = "mount_point" @@ -31,8 +31,7 @@ func NewDiskSource(namespace string, env core.Environment) *Disk { return &Disk{NewMetricSourceLogger(), &namedMetric{namespace, "disk"}, disks, env} } -func (c *Disk) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *Disk) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { for _, part := range c.disks { if part.Device == "" || part.FsType == "" { continue @@ -50,6 +49,8 @@ func (c *Disk) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metric "in_use": float64(usage.UsedPercentage), }) + log.Debugf("disk metrics collected: %v", len(simpleMetrics)) + select { case <-ctx.Done(): return diff --git a/src/core/metrics/sources/disk_io.go b/src/core/metrics/sources/disk_io.go index eaa961cd25..3a8f692275 100644 --- a/src/core/metrics/sources/disk_io.go +++ b/src/core/metrics/sources/disk_io.go @@ -37,8 +37,7 @@ func NewDiskIOSource(namespace string, env core.Environment) *DiskIO { return &DiskIO{namedMetric: &namedMetric{namespace, "io"}, env: env, diskIOStatsFunc: disk.IOCountersWithContext} } -func (dio *DiskIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (dio *DiskIO) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { dio.init.Do(func() { dio.diskDevs, _ = dio.env.DiskDevices() dio.diskIOStats = dio.newDiskIOCounters(ctx, dio.diskDevs) @@ -52,6 +51,7 @@ func (dio *DiskIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *me for k, v := range diffDiskIOStats { simpleMetrics := dio.convertSamplesToSimpleMetrics(v) + log.Debugf("disk io metrics collected: %v", len(simpleMetrics)) select { case <-ctx.Done(): diff --git a/src/core/metrics/sources/disk_io_test.go b/src/core/metrics/sources/disk_io_test.go index 1e7a1cc3a0..3a4080e7d9 100644 --- a/src/core/metrics/sources/disk_io_test.go +++ b/src/core/metrics/sources/disk_io_test.go @@ -10,7 +10,6 @@ package sources import ( "context" "sort" - "sync" "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -39,11 +38,8 @@ func TestDiskIOCollect(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) - diskio.Collect(ctx, wg, channel) - wg.Wait() + diskio.Collect(ctx, channel) actual := <-channel diff --git a/src/core/metrics/sources/disk_test.go b/src/core/metrics/sources/disk_test.go index 9e0047c031..b35d33d48c 100644 --- a/src/core/metrics/sources/disk_test.go +++ b/src/core/metrics/sources/disk_test.go @@ -10,7 +10,6 @@ package sources import ( "context" "sort" - "sync" "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -35,11 +34,8 @@ func TestDiskCollect(t *testing.T) { disk := NewDiskSource(namespace, env) ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) - disk.Collect(ctx, wg, channel) - wg.Wait() + disk.Collect(ctx, channel) actual := <-channel diff --git a/src/core/metrics/sources/leak_test.go b/src/core/metrics/sources/leak_test.go new file mode 100644 index 0000000000..c5ef179178 --- /dev/null +++ b/src/core/metrics/sources/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +package sources + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/core/metrics/sources/load.go b/src/core/metrics/sources/load.go index ca1e7ab7d3..d71cde8a0e 100644 --- a/src/core/metrics/sources/load.go +++ b/src/core/metrics/sources/load.go @@ -10,11 +10,11 @@ package sources import ( "context" "fmt" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" "github.com/shirou/gopsutil/v3/load" + log "github.com/sirupsen/logrus" ) type Load struct { @@ -27,8 +27,7 @@ func NewLoadSource(namespace string) *Load { return &Load{logger: NewMetricSourceLogger(), namedMetric: &namedMetric{namespace, "load"}, avgStatsFunc: load.Avg} } -func (c *Load) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *Load) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { loadStats, err := c.avgStatsFunc() if err != nil { c.logger.Log(fmt.Sprintf("Failed to collect Load metrics, %v", err)) @@ -41,6 +40,8 @@ func (c *Load) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metric "15": loadStats.Load15, }) + log.Debugf("load metrics count: %v", len(simpleMetrics)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper([]*proto.Dimension{}, simpleMetrics, proto.MetricsReport_SYSTEM): diff --git a/src/core/metrics/sources/load_test.go b/src/core/metrics/sources/load_test.go index 6c3fa27f88..e1fa43b5c2 100644 --- a/src/core/metrics/sources/load_test.go +++ b/src/core/metrics/sources/load_test.go @@ -10,7 +10,6 @@ package sources import ( "context" "sort" - "sync" "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -36,11 +35,8 @@ func TestLoadCollect(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) - loadSource.Collect(ctx, wg, channel) - wg.Wait() + loadSource.Collect(ctx, channel) actual := <-channel diff --git a/src/core/metrics/sources/mem.go b/src/core/metrics/sources/mem.go index 77e801ca8e..a3177253d3 100644 --- a/src/core/metrics/sources/mem.go +++ b/src/core/metrics/sources/mem.go @@ -11,7 +11,6 @@ import ( "context" "fmt" "os" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -38,8 +37,7 @@ func NewVirtualMemorySource(namespace string, env core.Environment) *VirtualMemo return &VirtualMemory{NewMetricSourceLogger(), &namedMetric{namespace, MemoryGroup}, statFunc} } -func (c *VirtualMemory) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *VirtualMemory) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { memstats, err := c.statFunc(ctx) if err != nil { if e, ok := err.(*os.PathError); ok { @@ -61,7 +59,7 @@ func (c *VirtualMemory) Collect(ctx context.Context, wg *sync.WaitGroup, m chan< "available": float64(memstats.Available), }) - log.Debugf("Memory metrics collected: %v", simpleMetrics) + log.Debugf("Memory metrics count: %v", len(simpleMetrics)) select { case <-ctx.Done(): diff --git a/src/core/metrics/sources/mem_test.go b/src/core/metrics/sources/mem_test.go index 1847f453f3..81c1330ab0 100644 --- a/src/core/metrics/sources/mem_test.go +++ b/src/core/metrics/sources/mem_test.go @@ -10,7 +10,6 @@ package sources import ( "context" "sort" - "sync" "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -57,11 +56,8 @@ func TestVirtualMemoryCollect(t *testing.T) { virtualMemorySource := NewVirtualMemorySource("test", env) ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 1) - go virtualMemorySource.Collect(ctx, wg, channel) - wg.Wait() + go virtualMemorySource.Collect(ctx, channel) actual := <-channel diff --git a/src/core/metrics/sources/net_io.go b/src/core/metrics/sources/net_io.go index 9ac04d4bcb..e3ef91cd83 100644 --- a/src/core/metrics/sources/net_io.go +++ b/src/core/metrics/sources/net_io.go @@ -16,6 +16,7 @@ import ( "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/metrics" "github.com/shirou/gopsutil/v3/net" + log "github.com/sirupsen/logrus" ) const NETWORK_INTERFACE = "network_interface" @@ -45,8 +46,7 @@ func NewNetIOSource(namespace string, env core.Environment) *NetIO { } } -func (nio *NetIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (nio *NetIO) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { nio.init.Do(func() { ifs, err := nio.newNetInterfaces(ctx) if err != nil || ifs == nil { @@ -82,6 +82,8 @@ func (nio *NetIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *met } simpleMetrics := nio.convertSamplesToSimpleMetrics(v) + log.Debugf("net IO stats count: %d", len(simpleMetrics)) + select { case <-ctx.Done(): return diff --git a/src/core/metrics/sources/net_io_test.go b/src/core/metrics/sources/net_io_test.go index 20ff69e279..cd58e1e588 100644 --- a/src/core/metrics/sources/net_io_test.go +++ b/src/core/metrics/sources/net_io_test.go @@ -10,7 +10,6 @@ package sources import ( "context" "sort" - "sync" "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -49,11 +48,8 @@ func TestNetIOCollect(t *testing.T) { } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) channel := make(chan *metrics.StatsEntityWrapper, 100) - nioSource.Collect(ctx, wg, channel) - wg.Wait() + nioSource.Collect(ctx, channel) actual := <-channel diff --git a/src/core/metrics/sources/nginx_access_log.go b/src/core/metrics/sources/nginx_access_log.go index 5cf9b19c8d..46c50b5830 100644 --- a/src/core/metrics/sources/nginx_access_log.go +++ b/src/core/metrics/sources/nginx_access_log.go @@ -108,8 +108,7 @@ func NewNginxAccessLog( return nginxAccessLog } -func (c *NginxAccessLog) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxAccessLog) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectLogStats(ctx, m) } @@ -378,6 +377,8 @@ func (c *NginxAccessLog) logStats(ctx context.Context, logFile, logFormat string httpCounters, upstreamCounters, upstreamCacheCounters = map[string]float64{}, map[string]float64{}, map[string]float64{} gzipRatios, requestLengths, requestTimes, upstreamResponseLength, upstreamResponseTimes, upstreamConnectTimes, upstreamHeaderTimes = []float64{}, []float64{}, []float64{}, []float64{}, []float64{}, []float64{}, []float64{} + log.Debugf("access log stats count: %d", len(simpleMetrics)) + c.buf = append(c.buf, metrics.NewStatsEntityWrapper(c.baseDimensions.ToDimensions(), simpleMetrics, proto.MetricsReport_INSTANCE)) mu.Unlock() diff --git a/src/core/metrics/sources/nginx_access_log_test.go b/src/core/metrics/sources/nginx_access_log_test.go index 7ddc72a894..d1601c2149 100644 --- a/src/core/metrics/sources/nginx_access_log_test.go +++ b/src/core/metrics/sources/nginx_access_log_test.go @@ -743,6 +743,7 @@ func TestAccessLogStats(t *testing.T) { logFormat string logLines []string expectedStats *proto.StatsEntity + timeout time.Duration }{ { "default_access_log_test", @@ -771,6 +772,7 @@ func TestAccessLogStats(t *testing.T) { }, }, }, + time.Minute, }, { "invalid_access_log", @@ -803,6 +805,7 @@ func TestAccessLogStats(t *testing.T) { }, }, }, + time.Second, }, { "full_access_log_test", @@ -1047,6 +1050,7 @@ func TestAccessLogStats(t *testing.T) { }, }, }, + time.Second, }, { "custom_access_log_test", @@ -1075,6 +1079,7 @@ func TestAccessLogStats(t *testing.T) { }, }, }, + time.Second, }, } @@ -1085,9 +1090,10 @@ func TestAccessLogStats(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { accessLogFile, _ := os.CreateTemp(os.TempDir(), "access.log") - + ctx, cncl := context.WithTimeout(context.Background(), test.timeout) + defer cncl() nginxAccessLog := NewNginxAccessLog(&metrics.CommonDim{}, OSSNamespace, binary, OSSNginxType, collectionDuration) - go nginxAccessLog.logStats(context.TODO(), accessLogFile.Name(), test.logFormat) + go nginxAccessLog.logStats(ctx, accessLogFile.Name(), test.logFormat) time.Sleep(sleepDuration) diff --git a/src/core/metrics/sources/nginx_error_log.go b/src/core/metrics/sources/nginx_error_log.go index d985d78b5f..06368eb93a 100644 --- a/src/core/metrics/sources/nginx_error_log.go +++ b/src/core/metrics/sources/nginx_error_log.go @@ -101,9 +101,7 @@ func NewNginxErrorLog( return nginxErrorLog } -func (c *NginxErrorLog) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() - +func (c *NginxErrorLog) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectLogStats(ctx, m) } diff --git a/src/core/metrics/sources/nginx_error_log_test.go b/src/core/metrics/sources/nginx_error_log_test.go index 0141c30a80..1fe8f022a2 100644 --- a/src/core/metrics/sources/nginx_error_log_test.go +++ b/src/core/metrics/sources/nginx_error_log_test.go @@ -73,6 +73,7 @@ func TestErrorLogStats(t *testing.T) { name string logLines []string expectedStats *proto.StatsEntity + timeout time.Duration }{ { "default_error_log_test", @@ -103,6 +104,7 @@ func TestErrorLogStats(t *testing.T) { }, }, }, + time.Second, }, } @@ -113,9 +115,10 @@ func TestErrorLogStats(t *testing.T) { for _, test := range tests { t.Run(test.name, func(tt *testing.T) { errorLogFile, _ := os.CreateTemp(os.TempDir(), "error.log") - + ctx, cncl := context.WithTimeout(context.Background(), test.timeout) + defer cncl() nginxErrorLog := NewNginxErrorLog(&metrics.CommonDim{}, OSSNamespace, binary, OSSNginxType, collectionDuration) - go nginxErrorLog.logStats(context.TODO(), errorLogFile.Name()) + go nginxErrorLog.logStats(ctx, errorLogFile.Name()) time.Sleep(sleepDuration) diff --git a/src/core/metrics/sources/nginx_oss.go b/src/core/metrics/sources/nginx_oss.go index 8bdd16c33e..a633cedd58 100644 --- a/src/core/metrics/sources/nginx_oss.go +++ b/src/core/metrics/sources/nginx_oss.go @@ -34,8 +34,7 @@ func NewNginxOSS(baseDimensions *metrics.CommonDim, namespace, stubStatus string return &NginxOSS{baseDimensions: baseDimensions, stubStatus: stubStatus, namedMetric: &namedMetric{namespace: namespace}, logger: NewMetricSourceLogger()} } -func (c *NginxOSS) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxOSS) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { var err error c.init.Do(func() { cl := client.NewNginxClient(&http.Client{}, c.stubStatus) @@ -106,6 +105,8 @@ func (c *NginxOSS) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *me simpleMetrics = append(simpleMetrics, &proto.SimpleMetric{Name: "nginx.status", Value: 1.0}) + log.Debugf("oss metrics count %d", len(simpleMetrics)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper(c.baseDimensions.ToDimensions(), simpleMetrics, proto.MetricsReport_INSTANCE): diff --git a/src/core/metrics/sources/nginx_oss_test.go b/src/core/metrics/sources/nginx_oss_test.go index 9195514438..d86532866d 100644 --- a/src/core/metrics/sources/nginx_oss_test.go +++ b/src/core/metrics/sources/nginx_oss_test.go @@ -11,7 +11,6 @@ import ( "context" "net/http" "net/http/httptest" - "sync" "testing" "github.com/nginx/agent/sdk/v2/proto" @@ -110,10 +109,7 @@ Reading: 0 Writing: 1 Waiting: 0 logger: NewMetricSourceLogger(), } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) - go c.Collect(ctx, wg, test.m) - wg.Wait() + go c.Collect(ctx, test.m) statEntity := <-test.m assert.Len(tt, statEntity.Data.Simplemetrics, len(test.expectedMetrics)) for _, metric := range statEntity.Data.Simplemetrics { diff --git a/src/core/metrics/sources/nginx_plus.go b/src/core/metrics/sources/nginx_plus.go index 3077083ba8..105b063dfc 100644 --- a/src/core/metrics/sources/nginx_plus.go +++ b/src/core/metrics/sources/nginx_plus.go @@ -85,8 +85,7 @@ func NewNginxPlus(baseDimensions *metrics.CommonDim, nginxNamespace, plusNamespa return &NginxPlus{baseDimensions: baseDimensions, nginxNamespace: nginxNamespace, plusNamespace: plusNamespace, plusAPI: plusAPI, clientVersion: clientVersion, logger: NewMetricSourceLogger()} } -func (c *NginxPlus) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxPlus) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.init.Do(func() { latestAPIVersion, err := c.getLatestAPIVersion(ctx, c.plusAPI) if err != nil { @@ -533,6 +532,8 @@ func (c *NginxPlus) commonMetrics(stats, prevStats *plusclient.Stats) *metrics.S "request.count": float64(requestCount), }) + log.Debugf("common metrics count %d", len(simpleMetrics)) + dims := c.baseDimensions.ToDimensions() return metrics.NewStatsEntityWrapper(dims, simpleMetrics, proto.MetricsReport_INSTANCE) } @@ -559,6 +560,8 @@ func (c *NginxPlus) sslMetrics(stats, prevStats *plusclient.Stats) *metrics.Stat "ssl.reuses": float64(sslReuses), }) + log.Debugf("SSL metrics count %d", len(simpleMetrics)) + dims := c.baseDimensions.ToDimensions() return metrics.NewStatsEntityWrapper(dims, simpleMetrics, proto.MetricsReport_INSTANCE) } diff --git a/src/core/metrics/sources/nginx_plus_test.go b/src/core/metrics/sources/nginx_plus_test.go index b067a987ad..bc9d65049c 100644 --- a/src/core/metrics/sources/nginx_plus_test.go +++ b/src/core/metrics/sources/nginx_plus_test.go @@ -12,7 +12,6 @@ import ( "fmt" "net/http" "net/http/httptest" - "sync" "testing" "github.com/nginx/agent/sdk/v2/proto" @@ -565,9 +564,7 @@ type FakeNginxPlus struct { } // Collect is fake collector that hard codes a stats struct response to avoid dependency on external NGINX Plus api -func (f *FakeNginxPlus) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() - +func (f *FakeNginxPlus) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { f.baseDimensions.NginxType = "plus" f.baseDimensions.PublishedAPI = f.plusAPI f.baseDimensions.NginxBuild = stats.NginxInfo.Build @@ -982,10 +979,7 @@ func TestNginxPlus_Collect(t *testing.T) { ctx := context.TODO() f := &FakeNginxPlus{NewNginxPlus(test.baseDimensions, "nginx", "plus", "", 6)} - wg := &sync.WaitGroup{} - wg.Add(1) - go f.Collect(ctx, wg, test.m) - wg.Wait() + go f.Collect(ctx, test.m) instanceMetrics := <-test.m assert.Len(t, instanceMetrics.Data.Simplemetrics, len(expectedInstanceMetrics)) diff --git a/src/core/metrics/sources/nginx_process.go b/src/core/metrics/sources/nginx_process.go index da533967e3..61852b4eab 100644 --- a/src/core/metrics/sources/nginx_process.go +++ b/src/core/metrics/sources/nginx_process.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -44,14 +43,14 @@ func (c *NginxProcess) getNginxCount() float64 { return 0.0 } -func (c *NginxProcess) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() - +func (c *NginxProcess) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { l := &namedMetric{namespace: PlusNamespace, group: ""} countSimpleMetric := l.convertSamplesToSimpleMetrics(map[string]float64{ "instance.count": c.getNginxCount(), }) + log.Debugf("instance metrics count %d", len(countSimpleMetric)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper(c.baseDimensions.ToDimensions(), countSimpleMetric, proto.MetricsReport_INSTANCE): diff --git a/src/core/metrics/sources/nginx_process_test.go b/src/core/metrics/sources/nginx_process_test.go index f8c8b45438..8bdb4756d2 100644 --- a/src/core/metrics/sources/nginx_process_test.go +++ b/src/core/metrics/sources/nginx_process_test.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "testing" "time" @@ -58,10 +57,8 @@ func TestNginxProcessCollector_Collect_Process(t *testing.T) { // tell the mock nginx binary to return something ctx := context.TODO() - wg := sync.WaitGroup{} - wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) - go n.Collect(ctx, &wg, m) + go n.Collect(ctx, m) time.Sleep(100 * time.Millisecond) mockBinary.AssertNumberOfCalls(t, "GetNginxDetailsByID", 1) @@ -102,10 +99,8 @@ func TestNginxProcessCollector_Collect_NoProcess(t *testing.T) { // tell the mock nginx binary to return something ctx := context.TODO() - wg := sync.WaitGroup{} - wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) - go n.Collect(ctx, &wg, m) + go n.Collect(ctx, m) time.Sleep(100 * time.Millisecond) mockBinary.AssertNumberOfCalls(t, "GetNginxDetailsByID", 1) @@ -149,10 +144,8 @@ func TestNginxProcessCollector_Collect_NotPlus(t *testing.T) { // tell the mock nginx binary to return something ctx := context.TODO() - wg := sync.WaitGroup{} - wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) - go n.Collect(ctx, &wg, m) + go n.Collect(ctx, m) time.Sleep(100 * time.Millisecond) mockBinary.AssertNumberOfCalls(t, "GetNginxDetailsByID", 1) diff --git a/src/core/metrics/sources/nginx_static.go b/src/core/metrics/sources/nginx_static.go index 82cdde4f4d..e7d6adfb18 100644 --- a/src/core/metrics/sources/nginx_static.go +++ b/src/core/metrics/sources/nginx_static.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "github.com/nginx/agent/v2/src/core/metrics" log "github.com/sirupsen/logrus" @@ -26,9 +25,7 @@ func NewNginxStatic(baseDimensions *metrics.CommonDim, namespace string) *NginxS return &NginxStatic{baseDimensions: baseDimensions, namedMetric: &namedMetric{namespace: namespace}} } -func (c *NginxStatic) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() - +func (c *NginxStatic) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { SendNginxDownStatus(ctx, c.baseDimensions.ToDimensions(), m) } diff --git a/src/core/metrics/sources/nginx_static_test.go b/src/core/metrics/sources/nginx_static_test.go index 02e3b7048f..fa93e0a9d8 100644 --- a/src/core/metrics/sources/nginx_static_test.go +++ b/src/core/metrics/sources/nginx_static_test.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "testing" "github.com/nginx/agent/sdk/v2/proto" @@ -65,10 +64,7 @@ func TestNginxStatic_Collect(t *testing.T) { namedMetric: test.namedMetric, } ctx := context.TODO() - wg := &sync.WaitGroup{} - wg.Add(1) - go c.Collect(ctx, wg, test.m) - wg.Wait() + go c.Collect(ctx, test.m) statEntity := <-test.m assert.Len(tt, statEntity.Data.Simplemetrics, len(expectedMetrics)) for _, metric := range statEntity.Data.Simplemetrics { diff --git a/src/core/metrics/sources/nginx_worker.go b/src/core/metrics/sources/nginx_worker.go index 12a64f8c58..e2312494bf 100644 --- a/src/core/metrics/sources/nginx_worker.go +++ b/src/core/metrics/sources/nginx_worker.go @@ -49,9 +49,8 @@ func NewNginxWorker(baseDimensions *metrics.CommonDim, } } -func (c *NginxWorker) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxWorker) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { var err error - defer wg.Done() childProcs := c.binary.GetChildProcesses() c.init.Do(func() { for pid, children := range childProcs { @@ -262,6 +261,8 @@ func (client *NginxWorkerClient) GetWorkerStats(childProcs []*proto.NginxDetails stats.Workers.KbsW = kbsw stats.Workers.FdsCount = fdSum + log.Debugf("worker stats for number of workers: %f", stats.Workers.Count) + return stats, nil } diff --git a/src/core/metrics/sources/nginx_worker_test.go b/src/core/metrics/sources/nginx_worker_test.go index fda857e0a5..a67ee8c67e 100644 --- a/src/core/metrics/sources/nginx_worker_test.go +++ b/src/core/metrics/sources/nginx_worker_test.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "testing" "time" @@ -78,10 +77,8 @@ func TestNginxWorkerCollector(t *testing.T) { // tell the mock nginx binary to return something ctx := context.TODO() - wg := sync.WaitGroup{} - wg.Add(1) m := make(chan *metrics.StatsEntityWrapper) - go n.Collect(ctx, &wg, m) + go n.Collect(ctx, m) time.Sleep(100 * time.Millisecond) mockClient.AssertNumberOfCalls(t, "GetWorkerStats", 2) @@ -122,9 +119,7 @@ func TestNginxWorkerCollector(t *testing.T) { } } - wg.Add(1) - - go n.Collect(ctx, &wg, m) + go n.Collect(ctx, m) time.Sleep(100 * time.Millisecond) mockClient.AssertNumberOfCalls(t, "GetWorkerStats", 3) diff --git a/src/core/metrics/sources/swap.go b/src/core/metrics/sources/swap.go index 2197b0365a..a8d2e30223 100644 --- a/src/core/metrics/sources/swap.go +++ b/src/core/metrics/sources/swap.go @@ -12,7 +12,6 @@ import ( "fmt" "math/big" "os" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -49,8 +48,7 @@ func NewSwapSource(namespace string, env core.Environment) *Swap { return &Swap{NewMetricSourceLogger(), &namedMetric{namespace, "swap"}, statFunc} } -func (c *Swap) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *Swap) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { swapStats, err := c.statFunc() if err != nil { if e, ok := err.(*os.PathError); ok { diff --git a/src/core/metrics/sources/swap_test.go b/src/core/metrics/sources/swap_test.go index 9e8af9daf2..d0ada3c25d 100644 --- a/src/core/metrics/sources/swap_test.go +++ b/src/core/metrics/sources/swap_test.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "testing" "github.com/nginx/agent/v2/src/core/metrics" @@ -91,10 +90,7 @@ func TestSwapSource_Collect(t *testing.T) { UsedPercent: 30, }, nil } - wg := &sync.WaitGroup{} - wg.Add(1) - go c.Collect(ctx, wg, test.m) - wg.Wait() + go c.Collect(ctx, test.m) statsEntity := <-test.m assert.Len(tt, statsEntity.Data.Simplemetrics, len(expectedMetrics)) diff --git a/src/core/mock_pipe.go b/src/core/mock_pipe.go index a11ccbb18e..91e087e5f7 100644 --- a/src/core/mock_pipe.go +++ b/src/core/mock_pipe.go @@ -146,3 +146,6 @@ func (p *MockMessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { } return pluginAlreadyRegistered } + +func (p *MockMessagePipe) Close() { +} diff --git a/src/core/os.go b/src/core/os.go index e1f95cf324..885b91ba3c 100644 --- a/src/core/os.go +++ b/src/core/os.go @@ -8,10 +8,16 @@ package core import ( + "context" "os" + "sync" "time" + + "github.com/nginx/agent/sdk/v2/backoff" ) +var chmodMutex sync.Mutex + // FileExists determines if the specified file given by the file path exists on the system. // If the file does NOT exist on the system the bool will be false and the error will be nil, // if the error is not nil then it's possible the file might exist but an error verifying it's @@ -42,19 +48,21 @@ func FilesExists(filePaths []string) (bool, error) { return true, nil } -func EnableWritePermissionForSocket(path string) error { - timeout := time.After(time.Second * 1) - var lastError error - for { - select { - case <-timeout: - return lastError - default: - lastError = os.Chmod(path, 0o660) - if lastError == nil { - return nil - } - } - <-time.After(time.Microsecond * 100) - } +// EnableWritePermissionForSocket attempts to set the write permissions for a socket file located at the specified path. +// The function continuously attempts the operation until either it succeeds or the timeout period elapses. +func EnableWritePermissionForSocket(ctx context.Context, path string) error { + err := backoff.WaitUntil(ctx, backoff.BackoffSettings{ + InitialInterval: time.Microsecond * 100, + MaxInterval: time.Microsecond * 100, + MaxElapsedTime: time.Second * 1, + Jitter: backoff.BACKOFF_JITTER, + Multiplier: backoff.BACKOFF_MULTIPLIER, + }, func() error { + chmodMutex.Lock() + lastError := os.Chmod(path, 0o660) + chmodMutex.Unlock() + return lastError + }) + + return err } diff --git a/src/core/pipe.go b/src/core/pipe.go index be4dff74ce..47311e79dc 100644 --- a/src/core/pipe.go +++ b/src/core/pipe.go @@ -36,20 +36,18 @@ type MessagePipe struct { plugins []Plugin extensionPlugins []ExtensionPlugin ctx context.Context - cancel context.CancelFunc mu sync.RWMutex bus message_bus.MessageBus } func NewMessagePipe(ctx context.Context, size int) *MessagePipe { - pipeContext, pipeCancel := context.WithCancel(ctx) return &MessagePipe{ messageChannel: make(chan *Message, size), plugins: make([]Plugin, 0, MaxPlugins), extensionPlugins: make([]ExtensionPlugin, 0, MaxExtensionPlugins), - ctx: pipeContext, - cancel: pipeCancel, + ctx: ctx, mu: sync.RWMutex{}, + bus: message_bus.New(size), } } @@ -64,10 +62,10 @@ func InitializePipe(ctx context.Context, corePlugins []Plugin, extensionPlugins func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []ExtensionPlugin) error { p.mu.Lock() + defer p.mu.Unlock() p.plugins = append(p.plugins, plugins...) p.extensionPlugins = append(p.extensionPlugins, extensionPlugins...) - p.bus = message_bus.New(size) pluginsRegistered := []string{} extensionPluginsRegistered := []string{} @@ -91,25 +89,26 @@ func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []Ex } extensionPluginsRegistered = append(extensionPluginsRegistered, *plugin.Info().name) } - log.Infof("The following core plugins have being registered: %q", pluginsRegistered) - log.Infof("The following extension plugins have being registered: %q", extensionPluginsRegistered) - p.mu.Unlock() + log.Infof("The following core plugins have been registered: %q", pluginsRegistered) + log.Infof("The following extension plugins have been registered: %q", extensionPluginsRegistered) + return nil } func (p *MessagePipe) DeRegister(pluginNames []string) error { p.mu.Lock() + defer p.mu.Unlock() - var plugins []Plugin + var pluginsToRemove []Plugin for _, name := range pluginNames { for _, plugin := range p.plugins { if plugin.Info().Name() == name { - plugins = append(plugins, plugin) + pluginsToRemove = append(pluginsToRemove, plugin) } } } - for _, plugin := range plugins { + for _, plugin := range pluginsToRemove { index := getIndex(plugin.Info().Name(), p.plugins) if index != -1 { @@ -124,10 +123,8 @@ func (p *MessagePipe) DeRegister(pluginNames []string) error { } } } - } - p.mu.Unlock() return nil } @@ -143,9 +140,11 @@ func getIndex(pluginName string, plugins []Plugin) int { func (p *MessagePipe) Process(messages ...*Message) { for _, m := range messages { select { - case p.messageChannel <- m: case <-p.ctx.Done(): return + case p.messageChannel <- m: + default: + return } } } @@ -156,20 +155,13 @@ func (p *MessagePipe) Run() { for { select { case <-p.ctx.Done(): - for _, r := range p.plugins { - r.Close() - } - - for _, r := range p.extensionPlugins { - r.Close() - } - - close(p.messageChannel) - + p.cleanup() return case m := <-p.messageChannel: p.mu.Lock() - p.bus.Publish(m.Topic(), m) + if p.bus != nil { + p.bus.Publish(m.Topic(), m) + } p.mu.Unlock() } } @@ -179,18 +171,47 @@ func (p *MessagePipe) Context() context.Context { return p.ctx } -func (p *MessagePipe) Cancel() context.CancelFunc { - return p.cancel -} - func (p *MessagePipe) GetPlugins() []Plugin { + p.mu.RLock() + defer p.mu.RUnlock() return p.plugins } func (p *MessagePipe) GetExtensionPlugins() []ExtensionPlugin { + p.mu.RLock() + defer p.mu.RUnlock() return p.extensionPlugins } +func (p *MessagePipe) cleanup() { + p.mu.RLock() + defer p.mu.RUnlock() + for _, r := range p.plugins { + for _, subscription := range r.Subscriptions() { + if p.bus != nil { + p.bus.Close(subscription) + } + } + r.Close() + } + + for _, r := range p.extensionPlugins { + for _, subscription := range r.Subscriptions() { + if p.bus != nil { + p.bus.Close(subscription) + } + } + r.Close() + } + + p.bus = nil + p.plugins = nil + if p.messageChannel != nil { + close(p.messageChannel) + } + p.messageChannel = nil +} + func (p *MessagePipe) initPlugins() { for _, r := range p.plugins { r.Init(p) @@ -202,11 +223,13 @@ func (p *MessagePipe) initPlugins() { } func (p *MessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { - pluginAlreadyRegistered := false + p.mu.RLock() + defer p.mu.RUnlock() + for _, plugin := range p.GetPlugins() { if plugin.Info().Name() == pluginName { - pluginAlreadyRegistered = true + return true } } - return pluginAlreadyRegistered + return false } diff --git a/src/core/pipe_test.go b/src/core/pipe_test.go index 73ce9aeff4..fc47645b75 100644 --- a/src/core/pipe_test.go +++ b/src/core/pipe_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" ) type testPlugin struct { @@ -40,7 +41,7 @@ func (p *testPlugin) Subscriptions() []string { return []string{"test.message"} } -func TestMessagePipe(t *testing.T) { +func TestMessagePipe_Run(t *testing.T) { messages := []*Message{ NewMessage("test.message", 1), NewMessage("test.message", 2), @@ -49,48 +50,51 @@ func TestMessagePipe(t *testing.T) { NewMessage("test.message", 5), } + ctx, cancel := context.WithCancel(context.Background()) + + pipe := NewMessagePipe(ctx, 10) + plugin := new(testPlugin) plugin.On("Init").Times(1) plugin.On("Process").Times(len(messages)) plugin.On("Close").Times(1) - ctx, cancel := context.WithCancel(context.Background()) - pipelineDone := make(chan bool) - - messagePipe := NewMessagePipe(ctx, 100) - err := messagePipe.Register(10, []Plugin{plugin}, nil) + err := pipe.Register(10, []Plugin{plugin}, nil) + require.NoError(t, err) - assert.NoError(t, err) + go pipe.Run() - go func() { - messagePipe.Run() - pipelineDone <- true - }() + pipe.Process(messages...) - messagePipe.Process(messages...) - time.Sleep(10 * time.Millisecond) // for the above call being asynchronous + time.Sleep(100 * time.Millisecond) cancel() - <-pipelineDone + + time.Sleep(200 * time.Millisecond) plugin.AssertExpectations(t) } -func TestPipe_DeRegister(t *testing.T) { - plugin := new(testPlugin) - plugin.On("Init").Times(1) - plugin.On("Close").Times(1) - +func TestMessagePipe_Process(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - messagePipe := SetupMockMessagePipe(t, ctx, []Plugin{plugin}, []ExtensionPlugin{}) + pipe := NewMessagePipe(ctx, 10) - err := messagePipe.DeRegister([]string{*plugin.Info().name}) + messages := []*Message{ + NewMessage("test.message", 1), + } + + pipe.Process(messages...) - assert.NoError(t, err) + select { + case msg := <-pipe.messageChannel: + assert.Equal(t, "test.message", *msg.topic) + case <-time.After(time.Second): + t.Fatal("Expected message not received") + } - assert.Equal(t, 0, len(messagePipe.GetPlugins())) + cancel() + time.Sleep(200 * time.Millisecond) } func TestPipe_IsPluginAlreadyRegistered(t *testing.T) { @@ -99,21 +103,20 @@ func TestPipe_IsPluginAlreadyRegistered(t *testing.T) { plugin.On("Close").Times(1) ctx, cancel := context.WithCancel(context.Background()) - pipelineDone := make(chan bool) messagePipe := NewMessagePipe(ctx, 100) err := messagePipe.Register(10, []Plugin{plugin}, nil) - assert.NoError(t, err) - - go func() { - messagePipe.Run() - pipelineDone <- true - }() // for the above call being asynchronous + require.NoError(t, err) - cancel() - <-pipelineDone + go messagePipe.Run() assert.True(t, messagePipe.IsPluginAlreadyRegistered(*plugin.Info().name)) assert.False(t, messagePipe.IsPluginAlreadyRegistered("metrics")) + + cancel() + + time.Sleep(200 * time.Millisecond) + + plugin.AssertExpectations(t) } diff --git a/src/core/tailer/leak_test.go b/src/core/tailer/leak_test.go new file mode 100644 index 0000000000..f4b4c0a15f --- /dev/null +++ b/src/core/tailer/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +package tailer + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/core/tailer/tailer.go b/src/core/tailer/tailer.go index 67b3074934..0609ee37ec 100644 --- a/src/core/tailer/tailer.go +++ b/src/core/tailer/tailer.go @@ -127,6 +127,11 @@ func (t *Tailer) Tail(ctx context.Context, data chan<- string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } + stopErr := t.handle.Stop() + if stopErr != nil { + log.Tracef("Unable to stop tailer, %v", stopErr) + return + } log.Trace("Tailer is done") return } @@ -156,6 +161,13 @@ func (t *PatternTailer) Tail(ctx context.Context, data chan<- map[string]string) case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } + + stopErr := t.handle.Stop() + if stopErr != nil { + log.Tracef("Unable to stop tailer, %v", stopErr) + return + } + log.Tracef("Tailer is done") return } @@ -184,6 +196,12 @@ func (t *LTSVTailer) Tail(ctx context.Context, data chan<- map[string]string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } + stopErr := t.handle.Stop() + if stopErr != nil { + log.Tracef("Unable to stop tailer, %v", stopErr) + return + } + log.Tracef("Tailer is done") return } diff --git a/src/core/tailer/tailer_test.go b/src/core/tailer/tailer_test.go index 251838ecf4..b6cd5f5274 100644 --- a/src/core/tailer/tailer_test.go +++ b/src/core/tailer/tailer_test.go @@ -70,9 +70,9 @@ func TestTailer(t *testing.T) { timeoutDuration := time.Millisecond * 300 ctx, cancel := context.WithTimeout(context.Background(), timeoutDuration) - defer cancel() data := make(chan string, 100) + go tailer.Tail(ctx, data) time.Sleep(time.Millisecond * 100) @@ -95,23 +95,27 @@ T: break T } } + cancel() os.Remove(errorLogFile.Name()) assert.Equal(t, 1, count) + + time.Sleep(500 * time.Millisecond) } func TestPatternTailer(t *testing.T) { accessLogFile, _ := os.CreateTemp(os.TempDir(), "access.log") - logLine := "127.0.0.1 - - [19/May/2022:09:30:39 +0000] \"GET /nginx_status HTTP/1.1\" 500 98 \"-\" \"Go-http-client/1.1\" \"-\"\n" + logLine := "127.0.0.1 - - [19/May/2022:09:30:39 +0000] \"GET /nginx_status HTTP/1.1\" 500 98 \"-\" \"Go-http-client/1.1\"" tailer, err := NewPatternTailer(accessLogFile.Name(), defaultPatterns) require.Nil(t, err) timeoutDuration := time.Millisecond * 300 + ctx, cancel := context.WithTimeout(context.Background(), timeoutDuration) - defer cancel() data := make(chan map[string]string, 100) + go tailer.Tail(ctx, data) time.Sleep(time.Millisecond * 100) @@ -125,7 +129,8 @@ func TestPatternTailer(t *testing.T) { T: for { select { - case <-data: + case d := <-data: + assert.Equal(t, logLine, d["DEFAULT"]) count++ case <-time.After(timeoutDuration): break T @@ -133,9 +138,12 @@ T: break T } } + cancel() os.Remove(accessLogFile.Name()) assert.Equal(t, 1, count) + + time.Sleep(500 * time.Millisecond) } func TestLTSVTailer(t *testing.T) { diff --git a/src/extensions/advanced_metrics.go b/src/extensions/advanced_metrics.go index 33ad249be3..32b61fef2d 100644 --- a/src/extensions/advanced_metrics.go +++ b/src/extensions/advanced_metrics.go @@ -259,9 +259,9 @@ func (m *AdvancedMetrics) run() { } }() defer m.ctxCancel() - err := core.EnableWritePermissionForSocket(m.cfg.Address) + err := core.EnableWritePermissionForSocket(m.ctx, m.cfg.Address) if err != nil { - log.Error("App centric metric plugin failed to change socket permissions") + log.Errorf("App centric metric plugin failed to change socket permissions: %v", err) } commonDimensions := append(m.commonDims.ToDimensions(), &proto.Dimension{ Name: aggregationDurationDimension, diff --git a/src/extensions/advanced_metrics_test.go b/src/extensions/advanced_metrics_test.go index e44ebc027d..0a1720a05d 100644 --- a/src/extensions/advanced_metrics_test.go +++ b/src/extensions/advanced_metrics_test.go @@ -11,13 +11,12 @@ import ( "context" "testing" + "github.com/gogo/protobuf/types" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" "github.com/nginx/agent/v2/src/extensions/advanced-metrics/pkg/publisher" tutils "github.com/nginx/agent/v2/test/utils" - - "github.com/gogo/protobuf/types" "github.com/stretchr/testify/assert" ) @@ -202,10 +201,8 @@ func TestAppCentricMetricClose(t *testing.T) { defer cancelCTX() messagePipe := core.SetupMockMessagePipe(t, ctx, []core.Plugin{}, []core.ExtensionPlugin{pluginUnderTest}) - pluginUnderTest.Init(messagePipe) pluginUnderTest.Close() - env.AssertExpectations(t) } diff --git a/src/extensions/nap_monitoring.go b/src/extensions/nap_monitoring.go index a59d3bfdfa..061a31d5cd 100644 --- a/src/extensions/nap_monitoring.go +++ b/src/extensions/nap_monitoring.go @@ -11,12 +11,13 @@ import ( "context" "time" + "github.com/nginx/agent/v2/src/core/metrics" + agent_config "github.com/nginx/agent/sdk/v2/agent/config" "github.com/nginx/agent/sdk/v2/proto" models "github.com/nginx/agent/sdk/v2/proto/events" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" - "github.com/nginx/agent/v2/src/core/metrics" "github.com/nginx/agent/v2/src/core/payloads" "github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager" @@ -41,16 +42,18 @@ var nginxAppProtectMonitoringDefault = &manager.NginxAppProtectMonitoringConfig{ } type NAPMonitoring struct { - monitorMgr *manager.Manager - messagePipeline core.MessagePipeInterface - reportInterval time.Duration - reportCount int - ctx context.Context - ctxCancel context.CancelFunc + monitorMgr *manager.Manager + messagePipeline core.MessagePipeInterface + reportInterval time.Duration + reportCount int + ctx context.Context + ctxCancel context.CancelFunc + nginxAppProtectMonitoringConfig *manager.NginxAppProtectMonitoringConfig + env core.Environment + cfg *config.Config } func NewNAPMonitoring(env core.Environment, cfg *config.Config, nginxAppProtectMonitoringConf interface{}) (*NAPMonitoring, error) { - commonDims := metrics.NewCommonDim(env.NewHostInfo("agentVersion", &cfg.Tags, cfg.ConfigDirs, false), cfg, "") nginxAppProtectMonitoringConfig := nginxAppProtectMonitoringDefault if nginxAppProtectMonitoringConf != nil { @@ -62,11 +65,6 @@ func NewNAPMonitoring(env core.Environment, cfg *config.Config, nginxAppProtectM } } - m, err := manager.NewManager(nginxAppProtectMonitoringConfig, commonDims) - if err != nil { - return nil, err - } - if !(nginxAppProtectMonitoringConfig.ReportInterval > minReportIntervalDelimiter) { log.Warnf("NAP Monitoring report interval must be higher than %v. Defaulting to %v", minReportIntervalDelimiter, @@ -83,9 +81,11 @@ func NewNAPMonitoring(env core.Environment, cfg *config.Config, nginxAppProtectM } return &NAPMonitoring{ - monitorMgr: m, - reportInterval: nginxAppProtectMonitoringConfig.ReportInterval, - reportCount: nginxAppProtectMonitoringConfig.ReportCount, + cfg: cfg, + nginxAppProtectMonitoringConfig: nginxAppProtectMonitoringConfig, + env: env, + reportInterval: nginxAppProtectMonitoringConfig.ReportInterval, + reportCount: nginxAppProtectMonitoringConfig.ReportCount, }, nil } @@ -94,6 +94,15 @@ func (n *NAPMonitoring) Info() *core.Info { } func (n *NAPMonitoring) Init(pipeline core.MessagePipeInterface) { + commonDims := metrics.NewCommonDim(n.env.NewHostInfo("agentVersion", &n.cfg.Tags, n.cfg.ConfigDirs, false), n.cfg, "") + + m, err := manager.NewManager(n.nginxAppProtectMonitoringConfig, commonDims) + if err != nil { + log.Errorf("Could not initialize nginx-app-protect-monitoring: %v", err) + return + } + + n.monitorMgr = m log.Infof("%s initializing", napMonitoringPluginName) n.messagePipeline = pipeline ctx, cancel := context.WithCancel(n.messagePipeline.Context()) diff --git a/src/extensions/nap_monitoring_test.go b/src/extensions/nap_monitoring_test.go index 363c83ecff..4f35f6fd70 100644 --- a/src/extensions/nap_monitoring_test.go +++ b/src/extensions/nap_monitoring_test.go @@ -35,17 +35,6 @@ func TestNAPMonitoring(t *testing.T) { }, error: false, }, - { - name: "invalid Syslog IP address", - conf: manager.NginxAppProtectMonitoringConfig{ - CollectorBufferSize: 1, - ProcessorBufferSize: 1, - SyslogIP: "no_such_host", - SyslogPort: 1236, - }, - error: true, - errorContains: "lookup", - }, { // Current behaviour is logging a warning and then // defaulting to the default buffer size = 50000 if the passed parameter is invalid @@ -58,17 +47,6 @@ func TestNAPMonitoring(t *testing.T) { }, error: false, }, - { - name: "invalid Syslog port", - conf: manager.NginxAppProtectMonitoringConfig{ - CollectorBufferSize: 1, - ProcessorBufferSize: 1, - SyslogIP: "127.0.0.1", - SyslogPort: -4321, - }, - error: true, - errorContains: "invalid port", - }, } env := tutils.GetMockEnv() @@ -76,7 +54,6 @@ func TestNAPMonitoring(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { _, err := NewNAPMonitoring(env, &config.Config{}, test.conf) - if test.error { assert.Contains(t, err.Error(), test.errorContains) } else { diff --git a/src/extensions/nginx-app-protect/monitoring/collector/collector.go b/src/extensions/nginx-app-protect/monitoring/collector/collector.go index bc9f7e085e..dd18ccec2d 100644 --- a/src/extensions/nginx-app-protect/monitoring/collector/collector.go +++ b/src/extensions/nginx-app-protect/monitoring/collector/collector.go @@ -9,7 +9,6 @@ package collector import ( "context" - "sync" "github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring" ) @@ -18,5 +17,5 @@ import ( // collect Raw Log data from WAF Instances. type Collector interface { // Collect starts collecting on collect chan until ctx.Done() chan gets a signal - Collect(ctx context.Context, wg *sync.WaitGroup, collect chan<- *monitoring.RawLog) + Collect(ctx context.Context, collect chan<- *monitoring.RawLog) } diff --git a/src/extensions/nginx-app-protect/monitoring/collector/nap.go b/src/extensions/nginx-app-protect/monitoring/collector/nap.go index f7b71b2302..70af0ab9eb 100644 --- a/src/extensions/nginx-app-protect/monitoring/collector/nap.go +++ b/src/extensions/nginx-app-protect/monitoring/collector/nap.go @@ -10,7 +10,6 @@ package collector import ( "context" "fmt" - "sync" "github.com/sirupsen/logrus" "gopkg.in/mcuadros/go-syslog.v2" @@ -84,9 +83,7 @@ func newSyslogServer(logger *logrus.Entry, ip string, port int) (*syslogServer, } // Collect starts collecting on collect chan until done chan gets a signal. -func (nap *NAPCollector) Collect(ctx context.Context, wg *sync.WaitGroup, collect chan<- *monitoring.RawLog) { - defer wg.Done() - +func (nap *NAPCollector) Collect(ctx context.Context, collect chan<- *monitoring.RawLog) { nap.logger.Infof("Starting collection for %s", monitoring.NAP) for { diff --git a/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go b/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go index a341ea5e08..851579decd 100644 --- a/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go +++ b/src/extensions/nginx-app-protect/monitoring/collector/nap_test.go @@ -13,7 +13,6 @@ import ( "log/syslog" "strconv" "strings" - "sync" "testing" "github.com/sirupsen/logrus" @@ -88,10 +87,7 @@ func TestNAPCollect(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - wg := &sync.WaitGroup{} - wg.Add(1) - - go waf.Collect(ctx, wg, collect) + go waf.Collect(ctx, collect) logwriter, err = syslog.Dial("tcp4", testIP+":"+strconv.Itoa(testPort), syslog.LOG_INFO|syslog.LOG_USER, "test") if err != nil { diff --git a/src/extensions/nginx-app-protect/monitoring/manager/manager.go b/src/extensions/nginx-app-protect/monitoring/manager/manager.go index 1c4e30f560..4c0700a00f 100644 --- a/src/extensions/nginx-app-protect/monitoring/manager/manager.go +++ b/src/extensions/nginx-app-protect/monitoring/manager/manager.go @@ -10,7 +10,6 @@ package manager import ( "context" "runtime" - "sync" "time" log "github.com/sirupsen/logrus" @@ -152,17 +151,12 @@ func (s *Manager) Run(ctx context.Context) { chtx, cancel := context.WithCancel(ctx) defer cancel() - waitGroup := &sync.WaitGroup{} - waitGroup.Add(2) - - go s.collector.Collect(chtx, waitGroup, s.collectChan) - go s.processor.Process(chtx, waitGroup, s.collectChan, s.processorChan) + go s.collector.Collect(chtx, s.collectChan) + go s.processor.Process(chtx, s.collectChan, s.processorChan) <-ctx.Done() s.logger.Infof("Received Context cancellation, %s is wrapping up...", componentName) - waitGroup.Wait() - s.logger.Infof("Context cancellation, %s wrapped up...", componentName) } diff --git a/src/extensions/nginx-app-protect/monitoring/processor/processor.go b/src/extensions/nginx-app-protect/monitoring/processor/processor.go index da2065c8df..810f334e81 100644 --- a/src/extensions/nginx-app-protect/monitoring/processor/processor.go +++ b/src/extensions/nginx-app-protect/monitoring/processor/processor.go @@ -76,8 +76,6 @@ func GetClient(cfg *Config) (*Client, error) { // processorWorker is a worker process to process events. func (c *Client) processorWorker(ctx context.Context, wg *sync.WaitGroup, id int, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { - defer wg.Done() - c.logger.Debugf("Setting up Processor Worker: %d", id) for { @@ -121,14 +119,11 @@ func (c *Client) processorWorker(ctx context.Context, wg *sync.WaitGroup, id int } // Process processes the raw log entries from collected chan into Security Events on processed chan. -func (c *Client) Process(ctx context.Context, wg *sync.WaitGroup, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { - defer wg.Done() - +func (c *Client) Process(ctx context.Context, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { c.logger.Info("Setting up Processor") for id := 1; id <= c.workers; id++ { - wg.Add(1) - go c.processorWorker(ctx, wg, id, collected, processed) + go c.processorWorker(ctx, nil, id, collected, processed) } c.logger.Infof("Done setting up %v Processor Workers", c.workers) diff --git a/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go b/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go index ef09de1701..4b8cde67b5 100644 --- a/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go +++ b/src/extensions/nginx-app-protect/monitoring/processor/processor_test.go @@ -12,7 +12,6 @@ import ( "context" "os" "strings" - "sync" "testing" "time" @@ -1215,11 +1214,8 @@ func TestNAPProcess(t *testing.T) { t.Fatalf("Could not get a Processor Client: %s", err) } - wg := &sync.WaitGroup{} - - wg.Add(1) // Start Processor - go p.Process(ctx, wg, collect, processed) + go p.Process(ctx, collect, processed) // Briefly sleep so map can be reconciled before event is collected // and processed diff --git a/src/extensions/nginx-app-protect/nap/nap.go b/src/extensions/nginx-app-protect/nap/nap.go index 2043859d77..49a486d10a 100644 --- a/src/extensions/nginx-app-protect/nap/nap.go +++ b/src/extensions/nginx-app-protect/nap/nap.go @@ -8,11 +8,13 @@ package nap import ( + "context" "fmt" "io/fs" "os" "path/filepath" "strings" + "sync" "time" "github.com/nginx/agent/v2/src/core" @@ -31,6 +33,7 @@ var ( requiredNAPFiles = []string{NAP_VERSION_FILE, NAP_RELEASE_FILE} requireNAPProcesses = []string{BD_SOCKET_PLUGIN_PROCESS} processCheckFunc = core.CheckForProcesses + mu = sync.Mutex{} ) // NewNginxAppProtect returns the object NginxAppProtect, which contains information related @@ -96,25 +99,27 @@ func NewNginxAppProtect(optDirPath, symLinkDir string) (*NginxAppProtect, error) // - NAP version changed // - Attack signature installed/version changed // - Threat campaign installed/version changed -func (nap *NginxAppProtect) Monitor(pollInterval time.Duration) chan NAPReportBundle { +func (nap *NginxAppProtect) Monitor(ctx context.Context, pollInterval time.Duration) chan NAPReportBundle { msgChannel := make(chan NAPReportBundle) - go nap.monitor(msgChannel, pollInterval) + go nap.monitor(ctx, msgChannel, pollInterval) return msgChannel } // monitor checks the system for any NAP related changes and communicates those changes with // a report message sent via the channel provided to it. -func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterval time.Duration) { +func (nap *NginxAppProtect) monitor(ctx context.Context, msgChannel chan NAPReportBundle, pollInterval time.Duration) { // Initial symlink sync + mu.Lock() if nap.Release.VersioningDetails.NAPRelease != "" { err := nap.syncSymLink("", nap.Release.VersioningDetails.NAPBuild) if err != nil { log.Errorf("Error occurred while performing initial sync for NAP symlink - %v", err) } } + mu.Unlock() ticker := time.NewTicker(pollInterval) - + defer ticker.Stop() for { select { case <-ticker.C: @@ -127,8 +132,10 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva newNAPReport := newNap.GenerateNAPReport() // Check if there has been any change in the NAP report + mu.Lock() if nap.napReportIsEqual(newNAPReport) { log.Debugf("No change in NAP detected... Checking NAP again in %v seconds", pollInterval.Seconds()) + mu.Unlock() break } @@ -140,6 +147,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva err = nap.syncSymLink(nap.Release.VersioningDetails.NAPBuild, newNAPReport.NAPVersion) if err != nil { log.Errorf("Got the following error syncing NAP symlink - %v", err) + mu.Unlock() break } @@ -148,12 +156,15 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva nap.Release = newNap.Release nap.AttackSignaturesVersion = newNap.AttackSignaturesVersion nap.ThreatCampaignsVersion = newNap.ThreatCampaignsVersion + mu.Unlock() // Send the update message through the channel msgChannel <- NAPReportBundle{ PreviousReport: previousReport, UpdatedReport: newNAPReport, } + case <-ctx.Done(): + return } } } @@ -236,6 +247,8 @@ func (nap *NginxAppProtect) removeNAPSymlinks(symlinkPatternToIgnore string) err // function has NOT called the Monitor function that is responsible for updating its values // to be in sync with the current system NAP values. func (nap *NginxAppProtect) GenerateNAPReport() NAPReport { + mu.Lock() + defer mu.Unlock() return NAPReport{ NAPVersion: nap.Release.VersioningDetails.NAPBuild, NAPRelease: nap.Release.VersioningDetails.NAPRelease, diff --git a/src/extensions/nginx_app_protect.go b/src/extensions/nginx_app_protect.go index 62c7e0328d..fccffa6a7b 100644 --- a/src/extensions/nginx_app_protect.go +++ b/src/extensions/nginx_app_protect.go @@ -130,8 +130,8 @@ func (n *NginxAppProtect) monitor() { ), ) - napUpdateChannel := n.nap.Monitor(n.reportInterval) - + napUpdateChannel := n.nap.Monitor(n.ctx, n.reportInterval) + defer close(napUpdateChannel) for { select { case updateMsg := <-napUpdateChannel: diff --git a/src/extensions/prometheus-metrics/prometheus_exporter.go b/src/extensions/prometheus-metrics/prometheus_exporter.go index a7688a48d5..31b45ba333 100644 --- a/src/extensions/prometheus-metrics/prometheus_exporter.go +++ b/src/extensions/prometheus-metrics/prometheus_exporter.go @@ -4,6 +4,7 @@ import ( "strings" "github.com/nginx/agent/sdk/v2/proto" + "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/metrics" "github.com/prometheus/client_golang/prometheus" @@ -21,10 +22,16 @@ func (e *Exporter) SetLatestMetricReport(latest *metrics.MetricsReportBundle) { e.latestMetricReports = latest } -func (e *Exporter) GetLatestMetricReports() (reports []*proto.MetricsReport) { - for _, report := range e.latestMetricReports.Data { - reports = append(reports, report) +func (e *Exporter) SetLatestMetricReports(data []core.Payload) { + e.latestMetricReports.Data = nil + + for _, report := range data { + e.latestMetricReports.Data = append(e.latestMetricReports.Data, report.(*proto.MetricsReport)) } +} + +func (e *Exporter) GetLatestMetricReports() (reports []*proto.MetricsReport) { + reports = append(reports, e.latestMetricReports.Data...) return } diff --git a/src/plugins/agent_api.go b/src/plugins/agent_api.go index ba212bd7cc..e8e55899b0 100644 --- a/src/plugins/agent_api.go +++ b/src/plugins/agent_api.go @@ -204,10 +204,12 @@ func (a *AgentAPI) Process(message *core.Message) { default: log.Warnf("Unknown Command_NginxConfigResponse type: %T(%v)", message.Data(), message.Data()) } - case core.MetricReport: + case core.CommMetrics: switch response := message.Data().(type) { case *metrics.MetricsReportBundle: a.exporter.SetLatestMetricReport(response) + case []core.Payload: + a.exporter.SetLatestMetricReports(response) default: log.Warnf("Unknown MetricReportBundle type: %T(%v)", message.Data(), message.Data()) } @@ -240,7 +242,6 @@ func (a *AgentAPI) Info() *core.Info { func (a *AgentAPI) Subscriptions() []string { return []string{ core.AgentAPIConfigApplyResponse, - core.MetricReport, core.NginxConfigValidationPending, core.NginxConfigApplyFailed, core.NginxConfigApplySucceeded, @@ -248,6 +249,7 @@ func (a *AgentAPI) Subscriptions() []string { core.AgentConnected, core.CommandSent, core.MetricReportSent, + core.CommMetrics, } } @@ -383,7 +385,7 @@ func (h *NginxHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // // 200: []NginxDetails // 500 -func (h *NginxHandler) sendInstanceDetailsPayload(w http.ResponseWriter, r *http.Request) error { +func (h *NginxHandler) sendInstanceDetailsPayload(w http.ResponseWriter, _ *http.Request) error { nginxDetails := h.getNginxDetails() w.WriteHeader(http.StatusOK) diff --git a/src/plugins/agent_api_test.go b/src/plugins/agent_api_test.go index 39a05368f0..7a74ceaa76 100644 --- a/src/plugins/agent_api_test.go +++ b/src/plugins/agent_api_test.go @@ -51,7 +51,6 @@ func TestAgentAPI_Info(t *testing.T) { func TestAgentAPI_Subscriptions(t *testing.T) { expectedSubscriptions := []string{ core.AgentAPIConfigApplyResponse, - core.MetricReport, core.NginxConfigValidationPending, core.NginxConfigApplyFailed, core.NginxConfigApplySucceeded, @@ -59,6 +58,7 @@ func TestAgentAPI_Subscriptions(t *testing.T) { core.AgentConnected, core.CommandSent, core.MetricReportSent, + core.CommMetrics, } agentAPI := AgentAPI{} @@ -420,7 +420,7 @@ func TestProcess_metricReport(t *testing.T) { // Check that latest metric report isn't set assert.NotEqual(t, metricReport, agentAPI.exporter.GetLatestMetricReports()[0]) - agentAPI.Process(core.NewMessage(core.MetricReport, metricReportBundle)) + agentAPI.Process(core.NewMessage(core.CommMetrics, metricReportBundle)) // Check that latest metric report matches the report that was processed assert.Equal(t, metricReport, agentAPI.exporter.GetLatestMetricReports()[0]) diff --git a/src/plugins/features.go b/src/plugins/features.go index 6beeee9f5d..1f38ab54f0 100644 --- a/src/plugins/features.go +++ b/src/plugins/features.go @@ -133,7 +133,7 @@ func (f *Features) Process(msg *core.Message) { } } -func (f *Features) enableMetricsFeature(data string) []core.Plugin { +func (f *Features) enableMetricsFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) { conf, err := config.GetConfig(f.conf.ClientID) @@ -151,7 +151,7 @@ func (f *Features) enableMetricsFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableMetricsCollectionFeature(data string) []core.Plugin { +func (f *Features) enableMetricsCollectionFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) && !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsCollection) { @@ -168,7 +168,7 @@ func (f *Features) enableMetricsCollectionFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableMetricsThrottleFeature(data string) []core.Plugin { +func (f *Features) enableMetricsThrottleFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) && !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsThrottle) { @@ -185,7 +185,7 @@ func (f *Features) enableMetricsThrottleFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableMetricsSenderFeature(data string) []core.Plugin { +func (f *Features) enableMetricsSenderFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) && !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsSender) { @@ -202,7 +202,7 @@ func (f *Features) enableMetricsSenderFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableAgentAPIFeature(data string) []core.Plugin { +func (f *Features) enableAgentAPIFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureAgentAPI) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -217,7 +217,7 @@ func (f *Features) enableAgentAPIFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableRegistrationFeature(data string) []core.Plugin { +func (f *Features) enableRegistrationFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureRegistration) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -232,7 +232,7 @@ func (f *Features) enableRegistrationFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableDataPlaneStatusFeature(data string) []core.Plugin { +func (f *Features) enableDataPlaneStatusFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureDataPlaneStatus) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -247,7 +247,7 @@ func (f *Features) enableDataPlaneStatusFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableProcessWatcherFeature(data string) []core.Plugin { +func (f *Features) enableProcessWatcherFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureProcessWatcher) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -262,7 +262,7 @@ func (f *Features) enableProcessWatcherFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableActivityEventsFeature(data string) []core.Plugin { +func (f *Features) enableActivityEventsFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureActivityEvents) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -277,7 +277,7 @@ func (f *Features) enableActivityEventsFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableFileWatcherFeature(data string) []core.Plugin { +func (f *Features) enableFileWatcherFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureFileWatcher) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -293,7 +293,7 @@ func (f *Features) enableFileWatcherFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableNginxCountingFeature(data string) []core.Plugin { +func (f *Features) enableNginxCountingFeature(_ string) []core.Plugin { countingPlugins := []core.Plugin{} if len(f.conf.Nginx.NginxCountingSocket) > 0 { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureNginxCounting) { diff --git a/src/plugins/features_test.go b/src/plugins/features_test.go index 0bd19918eb..bc70addf1e 100644 --- a/src/plugins/features_test.go +++ b/src/plugins/features_test.go @@ -18,7 +18,6 @@ import ( "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" tutils "github.com/nginx/agent/v2/test/utils" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -86,6 +85,7 @@ func TestFeatures_Process(t *testing.T) { env := tutils.NewMockEnvironment() env.Mock.On("IsContainer").Return(true) + env.Mock.On("FileStat", "/usr/local/etc/nginx").Return(env.FileStat) env.On("NewHostInfo", "agentVersion", &[]string{"locally-tagged", "tagged-locally"}).Return(&proto.HostInfo{}) binary.On("GetNginxDetailsFromProcess", &core.Process{Name: "12345", IsMaster: true}).Return(detailsMap[processID]) @@ -121,6 +121,10 @@ func TestFeatures_Process(t *testing.T) { assert.GreaterOrEqual(t, len(processedMessages), 1) assert.Equal(t, core.EnableFeature, processedMessages[0].Topic()) assert.Equal(t, tc.pluginName, messagePipe.GetPlugins()[1].Info().Name()) + + for _, plugin := range messagePipe.GetPlugins() { + plugin.Close() + } } cancelCTX() diff --git a/src/plugins/file_watcher.go b/src/plugins/file_watcher.go index 74b3cfd2e6..9d3568c031 100644 --- a/src/plugins/file_watcher.go +++ b/src/plugins/file_watcher.go @@ -51,15 +51,9 @@ const ( ) func NewFileWatcher(config *config.Config, env core.Environment) *FileWatcher { - watcher, err := fsnotify.NewWatcher() - if err != nil { - log.Errorf("Error creating file watcher: %v", err) - } - fw := &FileWatcher{ config: config, watching: &sync.Map{}, - watcher: watcher, wg: sync.WaitGroup{}, env: env, enabled: true, @@ -71,6 +65,14 @@ func NewFileWatcher(config *config.Config, env core.Environment) *FileWatcher { func (fw *FileWatcher) Init(pipeline core.MessagePipeInterface) { log.Info("FileWatcher initializing") + watcher, err := fsnotify.NewWatcher() + if err != nil { + log.Errorf("Error creating file watcher: %v", err) + return + } + + fw.watcher = watcher + fw.messagePipeline = pipeline fw.ctx, fw.cancelFunction = context.WithCancel(fw.messagePipeline.Context()) for dir := range fw.config.AllowedDirectoriesMap { diff --git a/src/plugins/leak_test.go b/src/plugins/leak_test.go new file mode 100644 index 0000000000..374e99f47c --- /dev/null +++ b/src/plugins/leak_test.go @@ -0,0 +1,18 @@ +/** + * Copyright (c) F5, Inc. + * + * This source code is licensed under the Apache License, Version 2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +package plugins + +import ( + "testing" + + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} diff --git a/src/plugins/metrics.go b/src/plugins/metrics.go index de869794bc..55238474c4 100644 --- a/src/plugins/metrics.go +++ b/src/plugins/metrics.go @@ -44,7 +44,7 @@ type Metrics struct { } func NewMetrics(config *config.Config, env core.Environment, binary core.NginxBinary, processes []*core.Process) *Metrics { - collectorConfigsMap := createCollectorConfigsMap(config, env, binary, processes) + collectorConfigsMap := createCollectorConfigsMap(config, binary, processes) return &Metrics{ collectorsUpdate: atomic.NewBool(false), ticker: time.NewTicker(config.AgentMetrics.CollectionInterval), @@ -67,6 +67,7 @@ func (m *Metrics) Init(pipeline core.MessagePipeInterface) { m.pipeline = pipeline m.ctx = pipeline.Context() go m.metricsGoroutine() + go m.drainBuffer(m.ctx) } func (m *Metrics) Close() { @@ -80,7 +81,7 @@ func (m *Metrics) Process(msg *core.Message) { case msg.Exact(core.AgentConfigChanged), msg.Exact(core.NginxConfigApplySucceeded): // If the agent config on disk changed or the NGINX statusAPI was updated // Then update Metrics with relevant config info - collectorConfigsMap := createCollectorConfigsMap(m.conf, m.env, m.binary, m.getNginxProccessInfo()) + collectorConfigsMap := createCollectorConfigsMap(m.conf, m.binary, m.getNginxProccessInfo()) m.collectorConfigsMapMutex.Lock() m.collectorConfigsMap = collectorConfigsMap m.collectorConfigsMapMutex.Unlock() @@ -101,7 +102,7 @@ func (m *Metrics) Process(msg *core.Message) { case msg.Exact(core.NginxDetailProcUpdate): m.syncProcessInfo(msg.Data().([]*core.Process)) - collectorConfigsMap := createCollectorConfigsMap(m.conf, m.env, m.binary, m.getNginxProccessInfo()) + collectorConfigsMap := createCollectorConfigsMap(m.conf, m.binary, m.getNginxProccessInfo()) for key, collectorConfig := range collectorConfigsMap { if _, ok := m.collectorConfigsMap[key]; !ok { log.Debugf("Adding new nginx collector for nginx id: %s", collectorConfig.NginxId) @@ -176,8 +177,33 @@ func (m *Metrics) metricsGoroutine() { } return case <-m.ticker.C: - stats := m.collectStats() - if bundlePayload := metrics.GenerateMetricsReportBundle(stats); bundlePayload != nil { + m.collectStats() + + if m.collectorsUpdate.Load() { + m.ticker = time.NewTicker(m.conf.AgentMetrics.CollectionInterval) + m.collectorsUpdate.Store(false) + } + + case err := <-m.errors: + log.Errorf("Error in metricsGoroutine %v", err) + } + } +} + +func (m *Metrics) drainBuffer(ctx context.Context) { + for { + // drain the buf, since our sources/collectors are all done, we can rely on buffer length + select { + case <-ctx.Done(): + log.Debug("context done in drainBuffer") + + err := ctx.Err() + if err != nil { + log.Errorf("error in done context collectStats %v", err) + } + return + case stats := <-m.buf: + if bundlePayload := metrics.GenerateMetricsReportBundle([]*metrics.StatsEntityWrapper{stats}); bundlePayload != nil { if m.conf.IsFeatureEnabled(agent_config.FeatureMetrics) || m.conf.IsFeatureEnabled(agent_config.FeatureMetricsThrottle) { m.pipeline.Process(core.NewMessage(core.MetricReport, bundlePayload)) } else { @@ -198,53 +224,22 @@ func (m *Metrics) metricsGoroutine() { } } } - - if m.collectorsUpdate.Load() { - m.ticker = time.NewTicker(m.conf.AgentMetrics.CollectionInterval) - m.collectorsUpdate.Store(false) - } - - case err := <-m.errors: - log.Errorf("Error in metricsGoroutine %v", err) } } } -func (m *Metrics) collectStats() (stats []*metrics.StatsEntityWrapper) { - // set a timeout for a millisecond less than the collection interval - ctx, cancel := context.WithTimeout(m.ctx, (m.interval - 1*time.Millisecond)) - defer cancel() +func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { // locks the m.collectors to make sure it doesn't get deleted in the middle // of collection, as we will delete the old one if config changes. // maybe we can fine tune the lock later, but the collection has been very quick so far. m.collectorsMutex.Lock() defer m.collectorsMutex.Unlock() - wg := &sync.WaitGroup{} start := time.Now() for _, s := range m.collectors { - wg.Add(1) - go s.Collect(ctx, wg, m.buf) - } - // wait until all the collection go routines are done, which either context timeout or exit - wg.Wait() - - for len(m.buf) > 0 { - // drain the buf, since our sources/collectors are all done, we can rely on buffer length - select { - case <-ctx.Done(): - log.Debugf("context done in %s collectStats", time.Since(start)) - - err := ctx.Err() - if err != nil { - log.Errorf("error in done context collectStats %v", err) - } - return - case stat := <-m.buf: - stats = append(stats, stat) - } + go s.Collect(m.ctx, m.buf) } - log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), ctx.Err() != nil) + log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), m.ctx.Err() != nil) return } @@ -304,7 +299,7 @@ func (m *Metrics) syncAgentConfigChange() { m.conf = conf } -func createCollectorConfigsMap(config *config.Config, env core.Environment, binary core.NginxBinary, processes []*core.Process) map[string]*metrics.NginxCollectorConfig { +func createCollectorConfigsMap(config *config.Config, binary core.NginxBinary, processes []*core.Process) map[string]*metrics.NginxCollectorConfig { collectorConfigsMap := make(map[string]*metrics.NginxCollectorConfig) for _, p := range processes { diff --git a/src/plugins/metrics_throlling.go b/src/plugins/metrics_throlling.go index 770bf27331..249ff15ef2 100644 --- a/src/plugins/metrics_throlling.go +++ b/src/plugins/metrics_throlling.go @@ -4,7 +4,6 @@ * This source code is licensed under the Apache License, Version 2.0 license found in the * LICENSE file in the root directory of this source tree. */ - package plugins import ( @@ -37,6 +36,7 @@ type MetricsThrottle struct { metricsAggregation bool metricsCollections map[proto.MetricsReport_Type]*metrics.Collections ctx context.Context + cancel context.CancelFunc wg sync.WaitGroup mu sync.Mutex env core.Environment @@ -53,7 +53,6 @@ func NewMetricsThrottle(conf *config.Config, env core.Environment) *MetricsThrot collectorsUpdate: atomic.NewBool(false), metricsAggregation: conf.AgentMetrics.Mode == "aggregated", metricsCollections: make(map[proto.MetricsReport_Type]*metrics.Collections, 0), - wg: sync.WaitGroup{}, env: env, conf: conf, errors: make(chan error), @@ -62,10 +61,10 @@ func NewMetricsThrottle(conf *config.Config, env core.Environment) *MetricsThrot func (r *MetricsThrottle) Init(pipeline core.MessagePipeInterface) { r.messagePipeline = pipeline - r.ctx = pipeline.Context() + r.ctx, r.cancel = context.WithCancel(pipeline.Context()) if r.metricsAggregation { r.wg.Add(1) - go r.metricsReportGoroutine(r.ctx, &r.wg) + go r.metricsReportGoroutine() } log.Info("MetricsThrottle initializing") } @@ -73,6 +72,8 @@ func (r *MetricsThrottle) Init(pipeline core.MessagePipeInterface) { func (r *MetricsThrottle) Close() { log.Info("MetricsThrottle is wrapping up") r.reportsReady.Store(false) // allow metricsReportGoroutine to shutdown gracefully + r.cancel() + r.wg.Wait() r.ticker.Stop() } @@ -98,8 +99,9 @@ func (r *MetricsThrottle) Process(msg *core.Message) { if len(report.Data) > 0 { if _, ok := r.metricsCollections[report.Type]; !ok { r.metricsCollections[report.Type] = &metrics.Collections{ - Count: 0, - Data: make(map[string]metrics.PerDimension), + Count: 0, + MetricsCount: make(map[string]metrics.PerDimension), + Data: make(map[string]metrics.PerDimension), } } collection := metrics.SaveCollections(*r.metricsCollections[report.Type], report) @@ -136,19 +138,29 @@ func (r *MetricsThrottle) Subscriptions() []string { return []string{core.MetricReport, core.AgentConfigChanged} } -func (r *MetricsThrottle) metricsReportGoroutine(ctx context.Context, wg *sync.WaitGroup) { - defer wg.Done() +func (r *MetricsThrottle) metricsReportGoroutine() { + defer r.wg.Done() defer r.ticker.Stop() + defer close(r.errors) log.Info("MetricsThrottle waiting for report ready") for { - if !r.reportsReady.Load() { - continue + select { + case <-r.ctx.Done(): + err := r.ctx.Err() + if err != nil && err != context.Canceled { + log.Errorf("error in done context metricsReportGoroutine %v", err) + } + return + default: + if !r.reportsReady.Load() { + continue + } } select { - case <-ctx.Done(): + case <-r.ctx.Done(): err := r.ctx.Err() - if err != nil { + if err != nil && err != context.Canceled { log.Errorf("error in done context metricsReportGoroutine %v", err) } return @@ -167,7 +179,9 @@ func (r *MetricsThrottle) metricsReportGoroutine(ctx context.Context, wg *sync.W r.collectorsUpdate.Store(false) } case err := <-r.errors: - log.Errorf("Error in metricsReportGoroutine %v", err) + if err != nil { + log.Errorf("Error in metricsReportGoroutine %v", err) + } } } } @@ -192,16 +206,20 @@ func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { defer r.mu.Unlock() for reportType, collection := range r.metricsCollections { - reports = append(reports, &proto.MetricsReport{ + report := &proto.MetricsReport{ Meta: &proto.Metadata{ Timestamp: types.TimestampNow(), }, Type: reportType, Data: metrics.GenerateMetrics(*collection), - }) + } + + reports = append(reports, report) + r.metricsCollections[reportType] = &metrics.Collections{ - Count: 0, - Data: make(map[string]metrics.PerDimension), + Count: 0, + MetricsCount: map[string]metrics.PerDimension{}, + Data: make(map[string]metrics.PerDimension), } } diff --git a/src/plugins/nginx_counter.go b/src/plugins/nginx_counter.go index 68f9b4fe7a..e4d3e1e53c 100644 --- a/src/plugins/nginx_counter.go +++ b/src/plugins/nginx_counter.go @@ -84,7 +84,7 @@ func (nc *NginxCounter) agentServer(serverAddress []string) { log.Warn("failed to start NGINX counter listener") } - err = core.EnableWritePermissionForSocket(serverAddress[1]) + err = core.EnableWritePermissionForSocket(nc.ctx, serverAddress[1]) if err != nil { log.Warn("unable to set correct write permissions for NGINX counter socket") } @@ -115,6 +115,10 @@ func (nc *NginxCounter) Close() { if err := os.RemoveAll(nc.serverAddress[1]); err != nil { log.Warn("Error removing socket") } + + nc.processMutex.RLock() + nc.nginxes = nil + nc.processMutex.RUnlock() } func (nc *NginxCounter) Info() *core.Info { diff --git a/src/plugins/nginx_counter_test.go b/src/plugins/nginx_counter_test.go index 54910bc554..b28350c471 100644 --- a/src/plugins/nginx_counter_test.go +++ b/src/plugins/nginx_counter_test.go @@ -94,6 +94,8 @@ func TestNginxCounter(t *testing.T) { assert.NotEqual(t, result, tt.expectedPayload) wg.Wait() + + nginxCounter.Close() }) } } diff --git a/src/plugins/process_watcher_test.go b/src/plugins/process_watcher_test.go index 05b7d69a66..2fd31b21e7 100644 --- a/src/plugins/process_watcher_test.go +++ b/src/plugins/process_watcher_test.go @@ -11,6 +11,8 @@ import ( "context" "testing" + "github.com/stretchr/testify/mock" + "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" @@ -24,6 +26,7 @@ func TestProcessWatcher_getProcUpdates(t *testing.T) { seenMasterProcs map[int32]*core.Process seenWorkerProcs map[int32]*core.Process seenNginxDetails map[int32]*proto.NginxDetails + nginxDetails []*proto.NginxDetails nginxProcs []*core.Process expectedProcUpdates map[string]string expectedMasterPids []int32 @@ -34,6 +37,32 @@ func TestProcessWatcher_getProcUpdates(t *testing.T) { seenMasterProcs: map[int32]*core.Process{}, seenWorkerProcs: map[int32]*core.Process{}, seenNginxDetails: map[int32]*proto.NginxDetails{}, + nginxDetails: []*proto.NginxDetails{ + { + NginxId: "1", Version: "21", ConfPath: "/etc/yo", ProcessId: "1", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "2", Version: "21", ConfPath: "/etc/yo", ProcessId: "2", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "3", Version: "21", ConfPath: "/etc/yo", ProcessId: "3", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + }, nginxProcs: []*core.Process{ tutils.GetProcesses()[0], tutils.GetProcesses()[1], @@ -61,6 +90,24 @@ func TestProcessWatcher_getProcUpdates(t *testing.T) { 2: {ProcessId: "2"}, 3: {ProcessId: "3"}, }, + nginxDetails: []*proto.NginxDetails{ + { + NginxId: "4", Version: "21", ConfPath: "/etc/yo", ProcessId: "4", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "5", Version: "21", ConfPath: "/etc/yo", ProcessId: "5", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + }, nginxProcs: []*core.Process{ tutils.GetProcesses()[0], {Pid: 4, ParentPid: 1, Name: "worker-1", IsMaster: false}, @@ -94,6 +141,56 @@ func TestProcessWatcher_getProcUpdates(t *testing.T) { {Pid: 7, ParentPid: 6, Name: "worker-1", IsMaster: false}, {Pid: 8, ParentPid: 6, Name: "worker-2", IsMaster: false}, }, + nginxDetails: []*proto.NginxDetails{ + { + NginxId: "6", Version: "21", ConfPath: "/etc/yo", ProcessId: "6", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "7", Version: "21", ConfPath: "/etc/yo", ProcessId: "7", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "8", Version: "21", ConfPath: "/etc/yo", ProcessId: "8", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "1", Version: "21", ConfPath: "/etc/yo", ProcessId: "1", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "2", Version: "21", ConfPath: "/etc/yo", ProcessId: "2", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + { + NginxId: "3", Version: "21", ConfPath: "/etc/yo", ProcessId: "3", StartTime: 1238043824, + BuiltFromSource: false, + LoadableModules: []string{}, + RuntimeModules: []string{}, + Plus: &proto.NginxPlusMetaData{Enabled: true}, + ConfigureArgs: []string{}, + }, + }, expectedProcUpdates: map[string]string{ "6": "nginx.master.created", "7": "nginx.worker.created", @@ -133,7 +230,11 @@ func TestProcessWatcher_getProcUpdates(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { env := tutils.NewMockEnvironment() - binary := core.NewNginxBinary(env, &config.Config{}) + binary := &tutils.MockNginxBinary{} + + for _, nginxDetail := range tt.nginxDetails { + binary.On("GetNginxDetailsFromProcess", mock.Anything).Return(nginxDetail).Once() + } pw := NewProcessWatcher(env, binary, tt.nginxProcs, &config.Config{}) pw.seenMasterProcs = tt.seenMasterProcs diff --git a/src/plugins/registration.go b/src/plugins/registration.go index 1f67865d36..7ec3a22ef8 100644 --- a/src/plugins/registration.go +++ b/src/plugins/registration.go @@ -148,7 +148,7 @@ func (r *OneTimeRegistration) areDataplaneSoftwareDetailsReady() error { for _, extension := range r.config.Extensions { if _, ok := r.dataplaneSoftwareDetails[extension]; !ok { - return fmt.Errorf("Registration max retries has been met before the extension %s was ready for registration", extension) + return fmt.Errorf("registration max retries has been met before the extension %s was ready for registration", extension) } } diff --git a/test/component/agent_api_test.go b/test/component/agent_api_test.go index 9ef0b1bbb4..f6980074f9 100644 --- a/test/component/agent_api_test.go +++ b/test/component/agent_api_test.go @@ -148,7 +148,7 @@ func TestMetrics(t *testing.T) { agentAPI := plugins.NewAgentAPI(conf, mockEnvironment, mockNginxBinary, []*core.Process{}) agentAPI.Init(core.NewMockMessagePipe(context.TODO())) - agentAPI.Process(core.NewMessage(core.MetricReport, &metrics.MetricsReportBundle{Data: []*proto.MetricsReport{ + agentAPI.Process(core.NewMessage(core.CommMetrics, &metrics.MetricsReportBundle{Data: []*proto.MetricsReport{ { Type: proto.MetricsReport_SYSTEM, Meta: &proto.Metadata{ diff --git a/test/integration/api/api_test.go b/test/integration/api/api_test.go index ec3691c813..34a60f1972 100644 --- a/test/integration/api/api_test.go +++ b/test/integration/api/api_test.go @@ -23,6 +23,8 @@ const ( API_HOST = "0.0.0.0" ) +var delay = time.Duration(5 * time.Second) + func TestAPI_Nginx(t *testing.T) { testContainer := utils.SetupTestContainerWithAgent( t, @@ -31,6 +33,9 @@ func TestAPI_Nginx(t *testing.T) { "Starting Agent API HTTP server with port from config and TLS disabled", ) + // wait for report interval to send metrics + time.Sleep(delay) + client := resty.New() client.SetRetryCount(3).SetRetryWaitTime(50 * time.Millisecond).SetRetryMaxWaitTime(200 * time.Millisecond) @@ -66,9 +71,13 @@ func TestAPI_Metrics(t *testing.T) { "Starting Agent API HTTP server with port from config and TLS disabled", ) + // wait for report interval to send metrics + time.Sleep(delay) + client := resty.New() url := fmt.Sprintf("http://%s:%d/metrics/", API_HOST, API_PORT) + client.SetRetryCount(5).SetRetryWaitTime(5 * time.Second).SetRetryMaxWaitTime(5 * time.Second) client.AddRetryCondition( func(r *resty.Response, err error) bool { diff --git a/test/integration/api/nginx-agent.conf b/test/integration/api/nginx-agent.conf index fedca4030b..069dfdc44e 100644 --- a/test/integration/api/nginx-agent.conf +++ b/test/integration/api/nginx-agent.conf @@ -48,7 +48,7 @@ metrics: # specify the size of a buffer to build before sending metrics bulk_size: 20 # specify metrics poll interval - report_interval: 1m + report_interval: 2s collection_interval: 1s mode: aggregated diff --git a/test/integration/go.mod b/test/integration/go.mod index f23f029922..efc2f15d35 100644 --- a/test/integration/go.mod +++ b/test/integration/go.mod @@ -187,7 +187,7 @@ require ( golang.org/x/net v0.27.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect + golang.org/x/sys v0.24.0 // indirect golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect diff --git a/test/integration/go.sum b/test/integration/go.sum index d46b7873ce..8bb7d68290 100644 --- a/test/integration/go.sum +++ b/test/integration/go.sum @@ -600,8 +600,8 @@ go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lI go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= -go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -706,8 +706,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= diff --git a/test/integration/grpc/grpc_config_apply_test.go b/test/integration/grpc/grpc_config_apply_test.go index dd68e186c5..302949ac39 100644 --- a/test/integration/grpc/grpc_config_apply_test.go +++ b/test/integration/grpc/grpc_config_apply_test.go @@ -94,7 +94,7 @@ func TestRegistrationAndConfigApply(t *testing.T) { t, "grpc-registration-and-config-apply", "./nginx-agent.conf:/etc/nginx-agent/nginx-agent.conf", - "The following core plugins have being registered", + "The following core plugins have been registered", ) // Validate that registration is complete diff --git a/test/integration/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go b/test/integration/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go index f5fa9e3b0a..6c26373b02 100644 --- a/test/integration/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go +++ b/test/integration/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go @@ -41,7 +41,7 @@ func WaitUntil( expoBackoffWithContext := backoff.WithContext(exponentialBackoff, ctx) - err := backoff.Retry(backoff.Operation(operation), expoBackoffWithContext) + err := backoff.Retry(operation, expoBackoffWithContext) if err != nil { return err } diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/config/config.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/config/config.go index addc4604b4..dfee04b1bc 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/config/config.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/config/config.go @@ -429,12 +429,11 @@ func LoadPropertiesFromFile(cfg string) error { if err != nil { return fmt.Errorf("error attempting to open dynamic config (%s): %v", dynamicCfgPath, err) } - + defer dynCfg.Close() featuresAreSet, cleanDynCfgContent, err := removeFeatures(dynCfg) if err != nil { return fmt.Errorf("error updating dynamic config with features removed (%s): %v", dynamicCfgPath, err) } - dynCfg.Close() if featuresAreSet { err = os.WriteFile(dynamicCfgPath, cleanDynCfgContent, 0o640) diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go index 7ddfb52690..5bb0355aa3 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go @@ -408,7 +408,7 @@ func getContainerID(mountInfo string) (string, error) { if err != nil { return "", fmt.Errorf("could not read %s: %v", mountInfo, err) } - + defer mInfoFile.Close() fileScanner := bufio.NewScanner(mInfoFile) fileScanner.Split(bufio.ScanLines) @@ -416,10 +416,6 @@ func getContainerID(mountInfo string) (string, error) { for fileScanner.Scan() { lines = append(lines, fileScanner.Text()) } - err = mInfoFile.Close() - if err != nil { - return "", fmt.Errorf("unable to close file %s: %v", mountInfo, err) - } for _, line := range lines { splitLine := strings.Split(line, " ") diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go index a11ccbb18e..91e087e5f7 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go @@ -146,3 +146,6 @@ func (p *MockMessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { } return pluginAlreadyRegistered } + +func (p *MockMessagePipe) Close() { +} diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go index e1f95cf324..885b91ba3c 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/os.go @@ -8,10 +8,16 @@ package core import ( + "context" "os" + "sync" "time" + + "github.com/nginx/agent/sdk/v2/backoff" ) +var chmodMutex sync.Mutex + // FileExists determines if the specified file given by the file path exists on the system. // If the file does NOT exist on the system the bool will be false and the error will be nil, // if the error is not nil then it's possible the file might exist but an error verifying it's @@ -42,19 +48,21 @@ func FilesExists(filePaths []string) (bool, error) { return true, nil } -func EnableWritePermissionForSocket(path string) error { - timeout := time.After(time.Second * 1) - var lastError error - for { - select { - case <-timeout: - return lastError - default: - lastError = os.Chmod(path, 0o660) - if lastError == nil { - return nil - } - } - <-time.After(time.Microsecond * 100) - } +// EnableWritePermissionForSocket attempts to set the write permissions for a socket file located at the specified path. +// The function continuously attempts the operation until either it succeeds or the timeout period elapses. +func EnableWritePermissionForSocket(ctx context.Context, path string) error { + err := backoff.WaitUntil(ctx, backoff.BackoffSettings{ + InitialInterval: time.Microsecond * 100, + MaxInterval: time.Microsecond * 100, + MaxElapsedTime: time.Second * 1, + Jitter: backoff.BACKOFF_JITTER, + Multiplier: backoff.BACKOFF_MULTIPLIER, + }, func() error { + chmodMutex.Lock() + lastError := os.Chmod(path, 0o660) + chmodMutex.Unlock() + return lastError + }) + + return err } diff --git a/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go b/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go index be4dff74ce..47311e79dc 100644 --- a/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go +++ b/test/integration/vendor/github.com/nginx/agent/v2/src/core/pipe.go @@ -36,20 +36,18 @@ type MessagePipe struct { plugins []Plugin extensionPlugins []ExtensionPlugin ctx context.Context - cancel context.CancelFunc mu sync.RWMutex bus message_bus.MessageBus } func NewMessagePipe(ctx context.Context, size int) *MessagePipe { - pipeContext, pipeCancel := context.WithCancel(ctx) return &MessagePipe{ messageChannel: make(chan *Message, size), plugins: make([]Plugin, 0, MaxPlugins), extensionPlugins: make([]ExtensionPlugin, 0, MaxExtensionPlugins), - ctx: pipeContext, - cancel: pipeCancel, + ctx: ctx, mu: sync.RWMutex{}, + bus: message_bus.New(size), } } @@ -64,10 +62,10 @@ func InitializePipe(ctx context.Context, corePlugins []Plugin, extensionPlugins func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []ExtensionPlugin) error { p.mu.Lock() + defer p.mu.Unlock() p.plugins = append(p.plugins, plugins...) p.extensionPlugins = append(p.extensionPlugins, extensionPlugins...) - p.bus = message_bus.New(size) pluginsRegistered := []string{} extensionPluginsRegistered := []string{} @@ -91,25 +89,26 @@ func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []Ex } extensionPluginsRegistered = append(extensionPluginsRegistered, *plugin.Info().name) } - log.Infof("The following core plugins have being registered: %q", pluginsRegistered) - log.Infof("The following extension plugins have being registered: %q", extensionPluginsRegistered) - p.mu.Unlock() + log.Infof("The following core plugins have been registered: %q", pluginsRegistered) + log.Infof("The following extension plugins have been registered: %q", extensionPluginsRegistered) + return nil } func (p *MessagePipe) DeRegister(pluginNames []string) error { p.mu.Lock() + defer p.mu.Unlock() - var plugins []Plugin + var pluginsToRemove []Plugin for _, name := range pluginNames { for _, plugin := range p.plugins { if plugin.Info().Name() == name { - plugins = append(plugins, plugin) + pluginsToRemove = append(pluginsToRemove, plugin) } } } - for _, plugin := range plugins { + for _, plugin := range pluginsToRemove { index := getIndex(plugin.Info().Name(), p.plugins) if index != -1 { @@ -124,10 +123,8 @@ func (p *MessagePipe) DeRegister(pluginNames []string) error { } } } - } - p.mu.Unlock() return nil } @@ -143,9 +140,11 @@ func getIndex(pluginName string, plugins []Plugin) int { func (p *MessagePipe) Process(messages ...*Message) { for _, m := range messages { select { - case p.messageChannel <- m: case <-p.ctx.Done(): return + case p.messageChannel <- m: + default: + return } } } @@ -156,20 +155,13 @@ func (p *MessagePipe) Run() { for { select { case <-p.ctx.Done(): - for _, r := range p.plugins { - r.Close() - } - - for _, r := range p.extensionPlugins { - r.Close() - } - - close(p.messageChannel) - + p.cleanup() return case m := <-p.messageChannel: p.mu.Lock() - p.bus.Publish(m.Topic(), m) + if p.bus != nil { + p.bus.Publish(m.Topic(), m) + } p.mu.Unlock() } } @@ -179,18 +171,47 @@ func (p *MessagePipe) Context() context.Context { return p.ctx } -func (p *MessagePipe) Cancel() context.CancelFunc { - return p.cancel -} - func (p *MessagePipe) GetPlugins() []Plugin { + p.mu.RLock() + defer p.mu.RUnlock() return p.plugins } func (p *MessagePipe) GetExtensionPlugins() []ExtensionPlugin { + p.mu.RLock() + defer p.mu.RUnlock() return p.extensionPlugins } +func (p *MessagePipe) cleanup() { + p.mu.RLock() + defer p.mu.RUnlock() + for _, r := range p.plugins { + for _, subscription := range r.Subscriptions() { + if p.bus != nil { + p.bus.Close(subscription) + } + } + r.Close() + } + + for _, r := range p.extensionPlugins { + for _, subscription := range r.Subscriptions() { + if p.bus != nil { + p.bus.Close(subscription) + } + } + r.Close() + } + + p.bus = nil + p.plugins = nil + if p.messageChannel != nil { + close(p.messageChannel) + } + p.messageChannel = nil +} + func (p *MessagePipe) initPlugins() { for _, r := range p.plugins { r.Init(p) @@ -202,11 +223,13 @@ func (p *MessagePipe) initPlugins() { } func (p *MessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { - pluginAlreadyRegistered := false + p.mu.RLock() + defer p.mu.RUnlock() + for _, plugin := range p.GetPlugins() { if plugin.Info().Name() == pluginName { - pluginAlreadyRegistered = true + return true } } - return pluginAlreadyRegistered + return false } diff --git a/test/integration/vendor/golang.org/x/sys/LICENSE b/test/integration/vendor/golang.org/x/sys/LICENSE index 6a66aea5ea..2a7cf70da6 100644 --- a/test/integration/vendor/golang.org/x/sys/LICENSE +++ b/test/integration/vendor/golang.org/x/sys/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/test/integration/vendor/golang.org/x/sys/cpu/cpu.go b/test/integration/vendor/golang.org/x/sys/cpu/cpu.go index 8fa707aa4b..ec07aab057 100644 --- a/test/integration/vendor/golang.org/x/sys/cpu/cpu.go +++ b/test/integration/vendor/golang.org/x/sys/cpu/cpu.go @@ -105,6 +105,8 @@ var ARM64 struct { HasSVE bool // Scalable Vector Extensions HasSVE2 bool // Scalable Vector Extensions 2 HasASIMDFHM bool // Advanced SIMD multiplication FP16 to FP32 + HasDIT bool // Data Independent Timing support + HasI8MM bool // Advanced SIMD Int8 matrix multiplication instructions _ CacheLinePad } diff --git a/test/integration/vendor/golang.org/x/sys/cpu/cpu_arm64.go b/test/integration/vendor/golang.org/x/sys/cpu/cpu_arm64.go index 0e27a21e1f..af2aa99f9f 100644 --- a/test/integration/vendor/golang.org/x/sys/cpu/cpu_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/cpu/cpu_arm64.go @@ -38,6 +38,8 @@ func initOptions() { {Name: "dcpop", Feature: &ARM64.HasDCPOP}, {Name: "asimddp", Feature: &ARM64.HasASIMDDP}, {Name: "asimdfhm", Feature: &ARM64.HasASIMDFHM}, + {Name: "dit", Feature: &ARM64.HasDIT}, + {Name: "i8mm", Feature: &ARM64.HasI8MM}, } } @@ -145,6 +147,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { ARM64.HasLRCPC = true } + switch extractBits(isar1, 52, 55) { + case 1: + ARM64.HasI8MM = true + } + // ID_AA64PFR0_EL1 switch extractBits(pfr0, 16, 19) { case 0: @@ -168,6 +175,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { parseARM64SVERegister(getzfr0()) } + + switch extractBits(pfr0, 48, 51) { + case 1: + ARM64.HasDIT = true + } } func parseARM64SVERegister(zfr0 uint64) { diff --git a/test/integration/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go b/test/integration/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go index 3d386d0fc2..08f35ea177 100644 --- a/test/integration/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go @@ -35,8 +35,10 @@ const ( hwcap_SHA512 = 1 << 21 hwcap_SVE = 1 << 22 hwcap_ASIMDFHM = 1 << 23 + hwcap_DIT = 1 << 24 hwcap2_SVE2 = 1 << 1 + hwcap2_I8MM = 1 << 13 ) // linuxKernelCanEmulateCPUID reports whether we're running @@ -106,9 +108,12 @@ func doinit() { ARM64.HasSHA512 = isSet(hwCap, hwcap_SHA512) ARM64.HasSVE = isSet(hwCap, hwcap_SVE) ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM) + ARM64.HasDIT = isSet(hwCap, hwcap_DIT) + // HWCAP2 feature bits ARM64.HasSVE2 = isSet(hwCap2, hwcap2_SVE2) + ARM64.HasI8MM = isSet(hwCap2, hwcap2_I8MM) } func isSet(hwc uint, value uint) bool { diff --git a/test/integration/vendor/golang.org/x/sys/unix/mkerrors.sh b/test/integration/vendor/golang.org/x/sys/unix/mkerrors.sh index 4ed2e488b6..d07dd09eb5 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/test/integration/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -58,6 +58,7 @@ includes_Darwin=' #define _DARWIN_USE_64_BIT_INODE #define __APPLE_USE_RFC_3542 #include +#include #include #include #include diff --git a/test/integration/vendor/golang.org/x/sys/unix/syscall_darwin.go b/test/integration/vendor/golang.org/x/sys/unix/syscall_darwin.go index 4cc7b00596..2d15200adb 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/test/integration/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -402,6 +402,18 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq)) } +//sys renamexNp(from string, to string, flag uint32) (err error) + +func RenamexNp(from string, to string, flag uint32) (err error) { + return renamexNp(from, to, flag) +} + +//sys renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) + +func RenameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + return renameatxNp(fromfd, from, tofd, to, flag) +} + //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL func Uname(uname *Utsname) error { diff --git a/test/integration/vendor/golang.org/x/sys/unix/syscall_linux.go b/test/integration/vendor/golang.org/x/sys/unix/syscall_linux.go index 5682e2628a..3f1d3d4cb2 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/test/integration/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -2592,3 +2592,4 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { } //sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) +//sys Mseal(b []byte, flags uint) (err error) diff --git a/test/integration/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/test/integration/vendor/golang.org/x/sys/unix/syscall_openbsd.go index b25343c71a..b86ded549c 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/test/integration/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -293,6 +293,7 @@ func Uname(uname *Utsname) error { //sys Mkfifoat(dirfd int, path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index e40fa85245..4308ac1772 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index bb02aa6c05..c8068a7a16 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux.go index 877a62b479..01a70b2463 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -457,6 +457,7 @@ const ( B600 = 0x8 B75 = 0x2 B9600 = 0xd + BCACHEFS_SUPER_MAGIC = 0xca451a4e BDEVFS_MAGIC = 0x62646576 BINDERFS_SUPER_MAGIC = 0x6c6f6f70 BINFMTFS_MAGIC = 0x42494e4d @@ -928,6 +929,7 @@ const ( EPOLL_CTL_ADD = 0x1 EPOLL_CTL_DEL = 0x2 EPOLL_CTL_MOD = 0x3 + EPOLL_IOC_TYPE = 0x8a EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2 ESP_V4_FLOW = 0xa ESP_V6_FLOW = 0xc @@ -941,9 +943,6 @@ const ( ETHTOOL_FEC_OFF = 0x4 ETHTOOL_FEC_RS = 0x8 ETHTOOL_FLAG_ALL = 0x7 - ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 - ETHTOOL_FLAG_OMIT_REPLY = 0x2 - ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_FLASHDEV = 0x33 ETHTOOL_FLASH_MAX_FILENAME = 0x80 ETHTOOL_FWVERS_LEN = 0x20 @@ -1705,6 +1704,7 @@ const ( KEXEC_ARCH_S390 = 0x160000 KEXEC_ARCH_SH = 0x2a0000 KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_CRASH_HOTPLUG_SUPPORT = 0x8 KEXEC_FILE_DEBUG = 0x8 KEXEC_FILE_NO_INITRAMFS = 0x4 KEXEC_FILE_ON_CRASH = 0x2 @@ -1780,6 +1780,7 @@ const ( KEY_SPEC_USER_KEYRING = -0x4 KEY_SPEC_USER_SESSION_KEYRING = -0x5 LANDLOCK_ACCESS_FS_EXECUTE = 0x1 + LANDLOCK_ACCESS_FS_IOCTL_DEV = 0x8000 LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800 LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40 LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80 @@ -1861,6 +1862,19 @@ const ( MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_FIXED_NOREPLACE = 0x100000 + MAP_HUGE_16GB = 0x88000000 + MAP_HUGE_16KB = 0x38000000 + MAP_HUGE_16MB = 0x60000000 + MAP_HUGE_1GB = 0x78000000 + MAP_HUGE_1MB = 0x50000000 + MAP_HUGE_256MB = 0x70000000 + MAP_HUGE_2GB = 0x7c000000 + MAP_HUGE_2MB = 0x54000000 + MAP_HUGE_32MB = 0x64000000 + MAP_HUGE_512KB = 0x4c000000 + MAP_HUGE_512MB = 0x74000000 + MAP_HUGE_64KB = 0x40000000 + MAP_HUGE_8MB = 0x5c000000 MAP_HUGE_MASK = 0x3f MAP_HUGE_SHIFT = 0x1a MAP_PRIVATE = 0x2 @@ -2498,6 +2512,23 @@ const ( PR_PAC_GET_ENABLED_KEYS = 0x3d PR_PAC_RESET_KEYS = 0x36 PR_PAC_SET_ENABLED_KEYS = 0x3c + PR_PPC_DEXCR_CTRL_CLEAR = 0x4 + PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10 + PR_PPC_DEXCR_CTRL_EDITABLE = 0x1 + PR_PPC_DEXCR_CTRL_MASK = 0x1f + PR_PPC_DEXCR_CTRL_SET = 0x2 + PR_PPC_DEXCR_CTRL_SET_ONEXEC = 0x8 + PR_PPC_DEXCR_IBRTPD = 0x1 + PR_PPC_DEXCR_NPHIE = 0x3 + PR_PPC_DEXCR_SBHE = 0x0 + PR_PPC_DEXCR_SRAPD = 0x2 + PR_PPC_GET_DEXCR = 0x48 + PR_PPC_SET_DEXCR = 0x49 + PR_RISCV_CTX_SW_FENCEI_OFF = 0x1 + PR_RISCV_CTX_SW_FENCEI_ON = 0x0 + PR_RISCV_SCOPE_PER_PROCESS = 0x0 + PR_RISCV_SCOPE_PER_THREAD = 0x1 + PR_RISCV_SET_ICACHE_FLUSH_CTX = 0x47 PR_RISCV_V_GET_CONTROL = 0x46 PR_RISCV_V_SET_CONTROL = 0x45 PR_RISCV_V_VSTATE_CTRL_CUR_MASK = 0x3 @@ -3192,6 +3223,7 @@ const ( STATX_MTIME = 0x40 STATX_NLINK = 0x4 STATX_SIZE = 0x200 + STATX_SUBVOL = 0x8000 STATX_TYPE = 0x1 STATX_UID = 0x8 STATX__RESERVED = 0x80000000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index e4bc0bd57c..684a5168da 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 689317afdb..61d74b592d 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 5cca668ac3..a28c9e3e89 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 14270508b0..ab5d1fe8ea 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 ESR_MAGIC = 0x45535201 EXTPROC = 0x10000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 28e39afdcb..c523090e7c 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index cd66e92cb4..01e6ea7804 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index c1595eba78..7aa610b1e7 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ee9456b0da..92af771b44 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 8cfca81e1b..b27ef5e6f1 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 60b0deb3af..237a2cefb3 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index f90aa7281b..4a5c555a36 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index ba9e015033..a02fb49a5f 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 07cdfd6e9f..e26a7c61b2 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 2f1dd214a7..c48f7c2103 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index f40519d901..ad4b9aace7 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -82,6 +82,8 @@ const ( EFD_CLOEXEC = 0x400000 EFD_NONBLOCK = 0x4000 EMT_TAGOVF = 0x1 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x400000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 07642c308d..b622533ef2 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 923e08cb79..cfe6646baf 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 7d73dda647..13f624f69f 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 057700111e..fe222b75df 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 87d8612a1d..1bc1a5adb2 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -2229,3 +2229,19 @@ func Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mseal(b []byte, flags uint) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSEAL, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 9dc42410b7..1851df14e8 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s index 41b5617316..0b43c69365 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 0d3a0751cd..e1ec0dbe4e 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s index 4019a656f6..880c6d6e31 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index c39f7776db..7c8452a63e 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s index ac4af24f90..b8ef95b0fa 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 57571d072f..2ffdf861f7 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s index f77d532121..2af3b5c762 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index e62963e67e..1da08d5267 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s index fae140b62c..b7a251353b 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 00831354c8..6e85b0aac9 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s index 9d1e0ff06d..f15dadf055 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -555,6 +555,12 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mount(SB) + RET +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_nanosleep(SB) RET diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 79029ed584..28b487df25 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s index da115f9a4b..1e7f321e43 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/test/integration/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 53aef5dc58..524b0820cb 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -457,4 +457,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 71d524763d..d3e38f681a 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -379,4 +379,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index c747706131..70b35bf3b0 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -421,4 +421,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index f96e214f6d..6c778c2327 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -324,4 +324,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go index 28425346cf..37281cf51a 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -318,4 +318,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index d0953018da..7e567f1eff 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 295c7f4b81..38ae55e5ef 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index d1a9eaca7a..55e92e60a8 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index bec157c39f..60658d6a02 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index 7ee7bdc435..e203e8a7ed 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -448,4 +448,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index fad1f25b44..5944b97d54 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 7d3e16357d..c66d416dad 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index 0ed53ad9f7..9889f6a559 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -325,4 +325,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 2fba04ad50..01d86825bb 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -386,4 +386,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 621d00d741..7b703e77cd 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/test/integration/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -399,4 +399,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/integration/vendor/golang.org/x/sys/unix/ztypes_linux.go b/test/integration/vendor/golang.org/x/sys/unix/ztypes_linux.go index 4740b83485..7f1961b907 100644 --- a/test/integration/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/test/integration/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -110,7 +110,8 @@ type Statx_t struct { Mnt_id uint64 Dio_mem_align uint32 Dio_offset_align uint32 - _ [12]uint64 + Subvol uint64 + _ [11]uint64 } type Fsid struct { @@ -3473,7 +3474,7 @@ const ( DEVLINK_PORT_FN_ATTR_STATE = 0x2 DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3 DEVLINK_PORT_FN_ATTR_CAPS = 0x4 - DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x5 + DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x6 ) type FsverityDigest struct { @@ -3806,6 +3807,9 @@ const ( ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 ETHTOOL_MSG_KERNEL_MAX = 0x2b + ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 + ETHTOOL_FLAG_OMIT_REPLY = 0x2 + ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 @@ -3975,7 +3979,7 @@ const ( ETHTOOL_A_TSINFO_TX_TYPES = 0x3 ETHTOOL_A_TSINFO_RX_FILTERS = 0x4 ETHTOOL_A_TSINFO_PHC_INDEX = 0x5 - ETHTOOL_A_TSINFO_MAX = 0x5 + ETHTOOL_A_TSINFO_MAX = 0x6 ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0 ETHTOOL_A_CABLE_TEST_HEADER = 0x1 ETHTOOL_A_CABLE_TEST_MAX = 0x1 diff --git a/test/integration/vendor/golang.org/x/sys/windows/security_windows.go b/test/integration/vendor/golang.org/x/sys/windows/security_windows.go index 97651b5bd0..b6e1ab76f8 100644 --- a/test/integration/vendor/golang.org/x/sys/windows/security_windows.go +++ b/test/integration/vendor/golang.org/x/sys/windows/security_windows.go @@ -1179,7 +1179,7 @@ type OBJECTS_AND_NAME struct { //sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD //sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW -//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) = advapi32.GetAce +//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) = advapi32.GetAce // Control returns the security descriptor control bits. func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { diff --git a/test/integration/vendor/golang.org/x/sys/windows/syscall_windows.go b/test/integration/vendor/golang.org/x/sys/windows/syscall_windows.go index 6525c62f3c..1fa34fd17c 100644 --- a/test/integration/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/test/integration/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -17,8 +17,10 @@ import ( "unsafe" ) -type Handle uintptr -type HWND uintptr +type ( + Handle uintptr + HWND uintptr +) const ( InvalidHandle = ^Handle(0) @@ -211,6 +213,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW //sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId +//sys LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) [failretval==0] = user32.LoadKeyboardLayoutW +//sys UnloadKeyboardLayout(hkl Handle) (err error) = user32.UnloadKeyboardLayout +//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout +//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx //sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow //sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW //sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx @@ -1368,9 +1374,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) { func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4) } + func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq))) } + func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { return syscall.EWINDOWS } diff --git a/test/integration/vendor/golang.org/x/sys/windows/types_windows.go b/test/integration/vendor/golang.org/x/sys/windows/types_windows.go index d8cb71db0a..3f03b3d57c 100644 --- a/test/integration/vendor/golang.org/x/sys/windows/types_windows.go +++ b/test/integration/vendor/golang.org/x/sys/windows/types_windows.go @@ -2003,7 +2003,21 @@ const ( MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20 ) -const GAA_FLAG_INCLUDE_PREFIX = 0x00000010 +// Flags for GetAdaptersAddresses, see +// https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses. +const ( + GAA_FLAG_SKIP_UNICAST = 0x1 + GAA_FLAG_SKIP_ANYCAST = 0x2 + GAA_FLAG_SKIP_MULTICAST = 0x4 + GAA_FLAG_SKIP_DNS_SERVER = 0x8 + GAA_FLAG_INCLUDE_PREFIX = 0x10 + GAA_FLAG_SKIP_FRIENDLY_NAME = 0x20 + GAA_FLAG_INCLUDE_WINS_INFO = 0x40 + GAA_FLAG_INCLUDE_GATEWAYS = 0x80 + GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x100 + GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x200 + GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400 +) const ( IF_TYPE_OTHER = 1 @@ -2017,6 +2031,50 @@ const ( IF_TYPE_IEEE1394 = 144 ) +// Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin +const ( + IpPrefixOriginOther = 0 + IpPrefixOriginManual = 1 + IpPrefixOriginWellKnown = 2 + IpPrefixOriginDhcp = 3 + IpPrefixOriginRouterAdvertisement = 4 + IpPrefixOriginUnchanged = 1 << 4 +) + +// Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin +const ( + NlsoOther = 0 + NlsoManual = 1 + NlsoWellKnown = 2 + NlsoDhcp = 3 + NlsoLinkLayerAddress = 4 + NlsoRandom = 5 + IpSuffixOriginOther = 0 + IpSuffixOriginManual = 1 + IpSuffixOriginWellKnown = 2 + IpSuffixOriginDhcp = 3 + IpSuffixOriginLinkLayerAddress = 4 + IpSuffixOriginRandom = 5 + IpSuffixOriginUnchanged = 1 << 4 +) + +// Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state +const ( + NldsInvalid = 0 + NldsTentative = 1 + NldsDuplicate = 2 + NldsDeprecated = 3 + NldsPreferred = 4 + IpDadStateInvalid = 0 + IpDadStateTentative = 1 + IpDadStateDuplicate = 2 + IpDadStateDeprecated = 3 + IpDadStatePreferred = 4 +) + type SocketAddress struct { Sockaddr *syscall.RawSockaddrAny SockaddrLength int32 @@ -3404,3 +3462,14 @@ type DCB struct { EvtChar byte wReserved1 uint16 } + +// Keyboard Layout Flags. +// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw +const ( + KLF_ACTIVATE = 0x00000001 + KLF_SUBSTITUTE_OK = 0x00000002 + KLF_REORDER = 0x00000008 + KLF_REPLACELANG = 0x00000010 + KLF_NOTELLSHELL = 0x00000080 + KLF_SETFORPROCESS = 0x00000100 +) diff --git a/test/integration/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/test/integration/vendor/golang.org/x/sys/windows/zsyscall_windows.go index eba761018a..9bb979a3e4 100644 --- a/test/integration/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/test/integration/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -478,12 +478,16 @@ var ( procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow") procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow") procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo") + procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout") procGetShellWindow = moduser32.NewProc("GetShellWindow") procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") procIsWindow = moduser32.NewProc("IsWindow") procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode") procIsWindowVisible = moduser32.NewProc("IsWindowVisible") + procLoadKeyboardLayoutW = moduser32.NewProc("LoadKeyboardLayoutW") procMessageBoxW = moduser32.NewProc("MessageBoxW") + procToUnicodeEx = moduser32.NewProc("ToUnicodeEx") + procUnloadKeyboardLayout = moduser32.NewProc("UnloadKeyboardLayout") procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") @@ -789,6 +793,14 @@ func FreeSid(sid *SID) (err error) { return } +func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) { + r1, _, e1 := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func GetLengthSid(sid *SID) (len uint32) { r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) len = uint32(r0) @@ -1225,14 +1237,6 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE return } -func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) { - r0, _, _ := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) - if r0 == 0 { - ret = GetLastError() - } - return -} - func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) { r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor))) if r1 == 0 { @@ -4082,6 +4086,12 @@ func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) { return } +func GetKeyboardLayout(tid uint32) (hkl Handle) { + r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(tid), 0, 0) + hkl = Handle(r0) + return +} + func GetShellWindow() (shellWindow HWND) { r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0) shellWindow = HWND(r0) @@ -4115,6 +4125,15 @@ func IsWindowVisible(hwnd HWND) (isVisible bool) { return } +func LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) { + r0, _, e1 := syscall.Syscall(procLoadKeyboardLayoutW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(flags), 0) + hkl = Handle(r0) + if hkl == 0 { + err = errnoErr(e1) + } + return +} + func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) ret = int32(r0) @@ -4124,6 +4143,20 @@ func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret i return } +func ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) { + r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(vkey), uintptr(scancode), uintptr(unsafe.Pointer(keystate)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(flags), uintptr(hkl), 0, 0) + ret = int32(r0) + return +} + +func UnloadKeyboardLayout(hkl Handle) (err error) { + r1, _, e1 := syscall.Syscall(procUnloadKeyboardLayout.Addr(), 1, uintptr(hkl), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) { var _p0 uint32 if inheritExisting { diff --git a/test/integration/vendor/modules.txt b/test/integration/vendor/modules.txt index 42170d97ab..8145f90040 100644 --- a/test/integration/vendor/modules.txt +++ b/test/integration/vendor/modules.txt @@ -1007,7 +1007,7 @@ golang.org/x/oauth2/internal golang.org/x/sync/errgroup golang.org/x/sync/semaphore golang.org/x/sync/singleflight -# golang.org/x/sys v0.22.0 +# golang.org/x/sys v0.24.0 ## explicit; go 1.18 golang.org/x/sys/cpu golang.org/x/sys/execabs diff --git a/test/performance/go.mod b/test/performance/go.mod index 6270306223..4986b7fbda 100644 --- a/test/performance/go.mod +++ b/test/performance/go.mod @@ -81,7 +81,7 @@ require ( golang.org/x/mod v0.19.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect + golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.23.0 // indirect diff --git a/test/performance/go.sum b/test/performance/go.sum index 91dbd3920d..d8f87fdb9c 100644 --- a/test/performance/go.sum +++ b/test/performance/go.sum @@ -201,6 +201,8 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -272,8 +274,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= diff --git a/test/performance/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go b/test/performance/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go index f5fa9e3b0a..6c26373b02 100644 --- a/test/performance/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go +++ b/test/performance/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go @@ -41,7 +41,7 @@ func WaitUntil( expoBackoffWithContext := backoff.WithContext(exponentialBackoff, ctx) - err := backoff.Retry(backoff.Operation(operation), expoBackoffWithContext) + err := backoff.Retry(operation, expoBackoffWithContext) if err != nil { return err } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/config/config.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/config/config.go index addc4604b4..dfee04b1bc 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/config/config.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/config/config.go @@ -429,12 +429,11 @@ func LoadPropertiesFromFile(cfg string) error { if err != nil { return fmt.Errorf("error attempting to open dynamic config (%s): %v", dynamicCfgPath, err) } - + defer dynCfg.Close() featuresAreSet, cleanDynCfgContent, err := removeFeatures(dynCfg) if err != nil { return fmt.Errorf("error updating dynamic config with features removed (%s): %v", dynamicCfgPath, err) } - dynCfg.Close() if featuresAreSet { err = os.WriteFile(dynamicCfgPath, cleanDynCfgContent, 0o640) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go index 7ddfb52690..5bb0355aa3 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go @@ -408,7 +408,7 @@ func getContainerID(mountInfo string) (string, error) { if err != nil { return "", fmt.Errorf("could not read %s: %v", mountInfo, err) } - + defer mInfoFile.Close() fileScanner := bufio.NewScanner(mInfoFile) fileScanner.Split(bufio.ScanLines) @@ -416,10 +416,6 @@ func getContainerID(mountInfo string) (string, error) { for fileScanner.Scan() { lines = append(lines, fileScanner.Text()) } - err = mInfoFile.Close() - if err != nil { - return "", fmt.Errorf("unable to close file %s: %v", mountInfo, err) - } for _, line := range lines { splitLine := strings.Split(line, " ") diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go index 663f995737..77d3f1e60e 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/aggregate.go @@ -30,8 +30,9 @@ type PerDimension struct { type MetricsHandler func(float64, int) float64 type Collections struct { - Count int // this is the number of collections run. Will use this to calculate the average. - Data map[string]PerDimension + Count int // this is the number of collections run. Will use this to calculate the average. + MetricsCount map[string]PerDimension + Data map[string]PerDimension } func dimChecksum(stats *proto.StatsEntity) string { @@ -59,15 +60,22 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe } } + if _, ok := metricsCollections.MetricsCount[dimensionsChecksum]; !ok { + metricsCollections.MetricsCount[dimensionsChecksum] = PerDimension{ + Dimensions: stats.GetDimensions(), + RunningSumMap: make(map[string]float64), + } + } + simpleMetrics := stats.GetSimplemetrics() - if simpleMetrics != nil { - for _, simpleMetric := range simpleMetrics { - if metrics, ok := metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name]; ok { - metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = metrics + simpleMetric.GetValue() - } else { - metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = simpleMetric.GetValue() - } + for _, simpleMetric := range simpleMetrics { + if metrics, ok := metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name]; ok { + metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name]++ + metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = metrics + simpleMetric.GetValue() + } else { + metricsCollections.MetricsCount[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = 1 + metricsCollections.Data[dimensionsChecksum].RunningSumMap[simpleMetric.Name] = simpleMetric.GetValue() } } } @@ -79,8 +87,8 @@ func SaveCollections(metricsCollections Collections, reports ...*proto.MetricsRe func GenerateMetrics(metricsCollections Collections) []*proto.StatsEntity { results := make([]*proto.StatsEntity, 0, 200) - for _, metricsPerDimension := range metricsCollections.Data { - simpleMetrics := getAggregatedSimpleMetric(metricsCollections.Count, metricsPerDimension.RunningSumMap) + for name, metricsPerDimension := range metricsCollections.Data { + simpleMetrics := getAggregatedSimpleMetric(metricsCollections.MetricsCount[name], metricsPerDimension.RunningSumMap) results = append(results, NewStatsEntity( metricsPerDimension.Dimensions, simpleMetrics, @@ -90,7 +98,7 @@ func GenerateMetrics(metricsCollections Collections) []*proto.StatsEntity { return results } -func getAggregatedSimpleMetric(count int, internalMap map[string]float64) (simpleMetrics []*proto.SimpleMetric) { +func getAggregatedSimpleMetric(count PerDimension, internalMap map[string]float64) (simpleMetrics []*proto.SimpleMetric) { variableMetrics := map[*regexp.Regexp]MetricsHandler{ failsRegex: sum, freeRegex: avg, @@ -105,13 +113,13 @@ func getAggregatedSimpleMetric(count int, internalMap map[string]float64) (simpl var aggregatedValue float64 switch valueType { case "sum": - aggregatedValue = sum(value, count) + aggregatedValue = sum(value, int(count.RunningSumMap[name])) case "avg": - aggregatedValue = avg(value, count) + aggregatedValue = avg(value, int(count.RunningSumMap[name])) case "boolean": - aggregatedValue = boolean(value, count) + aggregatedValue = boolean(value, int(count.RunningSumMap[name])) } // Only aggregate metrics when the aggregation method is defined @@ -122,7 +130,7 @@ func getAggregatedSimpleMetric(count int, internalMap map[string]float64) (simpl } else { for reg, calculation := range variableMetrics { if reg.MatchString(name) { - result := calculation(value, count) + result := calculation(value, int(count.RunningSumMap[name])) simpleMetrics = append(simpleMetrics, &proto.SimpleMetric{ Name: name, diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go index e0e60d4b75..1c7cf82292 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/container.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" log "github.com/sirupsen/logrus" @@ -46,18 +45,12 @@ func NewContainerCollector(env core.Environment, conf *config.Config) *Container } func (c *ContainerCollector) collectMetrics(ctx context.Context) { - // using a separate WaitGroup, since we need to wait for our own buffer to be filled - // this ensures the collection is done before our own for/select loop to pull things off the buf - wg := &sync.WaitGroup{} for _, containerSource := range c.sources { - wg.Add(1) - go containerSource.Collect(ctx, wg, c.buf) + go containerSource.Collect(ctx, c.buf) } - wg.Wait() } -func (c *ContainerCollector) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *ContainerCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectMetrics(ctx) commonDims := c.dim.ToDimensions() diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/nginx.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/nginx.go index f2e58ae505..b6355e6929 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/nginx.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/nginx.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" agent_config "github.com/nginx/agent/sdk/v2/agent/config" "github.com/nginx/agent/v2/src/core" @@ -73,18 +72,12 @@ func buildSources(dimensions *metrics.CommonDim, binary core.NginxBinary, collec } func (c *NginxCollector) collectMetrics(ctx context.Context) { - // using a separate WaitGroup, since we need to wait for our own buffer to be filled - // this ensures the collection is done before our own for/select loop to pull things off the buf - wg := &sync.WaitGroup{} for _, nginxSource := range c.sources { - wg.Add(1) - go nginxSource.Collect(ctx, wg, c.buf) + go nginxSource.Collect(ctx, c.buf) } - wg.Wait() } -func (c *NginxCollector) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectMetrics(ctx) for { select { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/system.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/system.go index a92c4a7b8e..cd91e7b1c7 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/system.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/collectors/system.go @@ -9,7 +9,6 @@ package collectors import ( "context" - "sync" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" @@ -57,18 +56,12 @@ func NewSystemCollector(env core.Environment, conf *config.Config) *SystemCollec } func (c *SystemCollector) collectMetrics(ctx context.Context) { - // using a separate WaitGroup, since we need to wait for our own buffer to be filled - // this ensures the collection is done before our own for/select loop to pull things off the buf - wg := &sync.WaitGroup{} for _, systemSource := range c.sources { - wg.Add(1) - go systemSource.Collect(ctx, wg, c.buf) + go systemSource.Collect(ctx, c.buf) } - wg.Wait() } -func (c *SystemCollector) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *SystemCollector) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectMetrics(ctx) commonDims := c.dim.ToDimensions() diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go index 43b2ea7381..4128c87e5e 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go @@ -11,7 +11,6 @@ import ( "context" "math" "sort" - "sync" "time" "github.com/nginx/agent/sdk/v2/proto" @@ -22,16 +21,16 @@ import ( ) type Collector interface { - Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *StatsEntityWrapper) + Collect(ctx context.Context, m chan<- *StatsEntityWrapper) UpdateConfig(config *config.Config) } type Source interface { - Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *StatsEntityWrapper) + Collect(ctx context.Context, m chan<- *StatsEntityWrapper) } type NginxSource interface { - Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *StatsEntityWrapper) + Collect(ctx context.Context, m chan<- *StatsEntityWrapper) Update(dimensions *CommonDim, collectorConf *NginxCollectorConfig) Stop() } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/common.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/common.go index 3041ee5121..1a942a1e9f 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/common.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/common.go @@ -13,6 +13,7 @@ import ( "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" + log "github.com/sirupsen/logrus" ) const ( @@ -91,6 +92,8 @@ func Delta(current, previous map[string]map[string]float64) map[string]map[strin func SendNginxDownStatus(ctx context.Context, dims []*proto.Dimension, m chan<- *metrics.StatsEntityWrapper) { simpleMetrics := []*proto.SimpleMetric{newFloatMetric("nginx.status", float64(0))} + log.Debugf("nginx down status %d", len(simpleMetrics)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper(dims, simpleMetrics, proto.MetricsReport_INSTANCE): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_cpu.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_cpu.go index 474f6871c0..998b1653fc 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_cpu.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_cpu.go @@ -13,7 +13,6 @@ import ( "path" "strconv" "strings" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" @@ -47,9 +46,8 @@ func NewContainerCPUSource(namespace string, basePath string) *ContainerCPU { return &ContainerCPU{basePath, cgroup.IsCgroupV2(basePath), NewMetricSourceLogger(), &namedMetric{namespace, CpuGroup}} } -func (c *ContainerCPU) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerCPU) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { log.Trace("Collecting container CPU metrics") - defer wg.Done() containerStats := map[string]float64{} diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_mem.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_mem.go index 01d0bcd7ce..086ac5b345 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_mem.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/container_mem.go @@ -13,7 +13,6 @@ import ( "path" "strconv" "strings" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" @@ -40,9 +39,8 @@ func NewContainerMemorySource(namespace string, basePath string) *ContainerMemor return &ContainerMemory{basePath, cgroup.IsCgroupV2(basePath), NewMetricSourceLogger(), &namedMetric{namespace, MemoryGroup}} } -func (c *ContainerMemory) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *ContainerMemory) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { log.Trace("Collecting container memory metrics") - defer wg.Done() var containerStats map[string]float64 diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/cpu.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/cpu.go index 520c8f550e..f7bb0046ca 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/cpu.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/cpu.go @@ -69,8 +69,7 @@ func diffTimeStat(t1, t2 cpu.TimesStat) cpu.TimesStat { } } -func (c *CPUTimes) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *CPUTimes) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { var simpleMetrics []*proto.SimpleMetric if c.isDocker { dockerCpuPercentages, err := c.cgroupCPUSource.Percentages() diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go index 4721330979..98a3847a2d 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk.go @@ -10,11 +10,11 @@ package sources import ( "context" "fmt" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/metrics" + log "github.com/sirupsen/logrus" ) const MOUNT_POINT = "mount_point" @@ -31,8 +31,7 @@ func NewDiskSource(namespace string, env core.Environment) *Disk { return &Disk{NewMetricSourceLogger(), &namedMetric{namespace, "disk"}, disks, env} } -func (c *Disk) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *Disk) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { for _, part := range c.disks { if part.Device == "" || part.FsType == "" { continue @@ -50,6 +49,8 @@ func (c *Disk) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metric "in_use": float64(usage.UsedPercentage), }) + log.Debugf("disk metrics collected: %v", len(simpleMetrics)) + select { case <-ctx.Done(): return diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go index eaa961cd25..3a8f692275 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/disk_io.go @@ -37,8 +37,7 @@ func NewDiskIOSource(namespace string, env core.Environment) *DiskIO { return &DiskIO{namedMetric: &namedMetric{namespace, "io"}, env: env, diskIOStatsFunc: disk.IOCountersWithContext} } -func (dio *DiskIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (dio *DiskIO) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { dio.init.Do(func() { dio.diskDevs, _ = dio.env.DiskDevices() dio.diskIOStats = dio.newDiskIOCounters(ctx, dio.diskDevs) @@ -52,6 +51,7 @@ func (dio *DiskIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *me for k, v := range diffDiskIOStats { simpleMetrics := dio.convertSamplesToSimpleMetrics(v) + log.Debugf("disk io metrics collected: %v", len(simpleMetrics)) select { case <-ctx.Done(): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go index ca1e7ab7d3..d71cde8a0e 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/load.go @@ -10,11 +10,11 @@ package sources import ( "context" "fmt" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core/metrics" "github.com/shirou/gopsutil/v3/load" + log "github.com/sirupsen/logrus" ) type Load struct { @@ -27,8 +27,7 @@ func NewLoadSource(namespace string) *Load { return &Load{logger: NewMetricSourceLogger(), namedMetric: &namedMetric{namespace, "load"}, avgStatsFunc: load.Avg} } -func (c *Load) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *Load) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { loadStats, err := c.avgStatsFunc() if err != nil { c.logger.Log(fmt.Sprintf("Failed to collect Load metrics, %v", err)) @@ -41,6 +40,8 @@ func (c *Load) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metric "15": loadStats.Load15, }) + log.Debugf("load metrics count: %v", len(simpleMetrics)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper([]*proto.Dimension{}, simpleMetrics, proto.MetricsReport_SYSTEM): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go index 77e801ca8e..a3177253d3 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/mem.go @@ -11,7 +11,6 @@ import ( "context" "fmt" "os" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -38,8 +37,7 @@ func NewVirtualMemorySource(namespace string, env core.Environment) *VirtualMemo return &VirtualMemory{NewMetricSourceLogger(), &namedMetric{namespace, MemoryGroup}, statFunc} } -func (c *VirtualMemory) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *VirtualMemory) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { memstats, err := c.statFunc(ctx) if err != nil { if e, ok := err.(*os.PathError); ok { @@ -61,7 +59,7 @@ func (c *VirtualMemory) Collect(ctx context.Context, wg *sync.WaitGroup, m chan< "available": float64(memstats.Available), }) - log.Debugf("Memory metrics collected: %v", simpleMetrics) + log.Debugf("Memory metrics count: %v", len(simpleMetrics)) select { case <-ctx.Done(): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go index 9ac04d4bcb..e3ef91cd83 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/net_io.go @@ -16,6 +16,7 @@ import ( "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/metrics" "github.com/shirou/gopsutil/v3/net" + log "github.com/sirupsen/logrus" ) const NETWORK_INTERFACE = "network_interface" @@ -45,8 +46,7 @@ func NewNetIOSource(namespace string, env core.Environment) *NetIO { } } -func (nio *NetIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (nio *NetIO) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { nio.init.Do(func() { ifs, err := nio.newNetInterfaces(ctx) if err != nil || ifs == nil { @@ -82,6 +82,8 @@ func (nio *NetIO) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *met } simpleMetrics := nio.convertSamplesToSimpleMetrics(v) + log.Debugf("net IO stats count: %d", len(simpleMetrics)) + select { case <-ctx.Done(): return diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go index 5cf9b19c8d..46c50b5830 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_access_log.go @@ -108,8 +108,7 @@ func NewNginxAccessLog( return nginxAccessLog } -func (c *NginxAccessLog) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxAccessLog) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectLogStats(ctx, m) } @@ -378,6 +377,8 @@ func (c *NginxAccessLog) logStats(ctx context.Context, logFile, logFormat string httpCounters, upstreamCounters, upstreamCacheCounters = map[string]float64{}, map[string]float64{}, map[string]float64{} gzipRatios, requestLengths, requestTimes, upstreamResponseLength, upstreamResponseTimes, upstreamConnectTimes, upstreamHeaderTimes = []float64{}, []float64{}, []float64{}, []float64{}, []float64{}, []float64{}, []float64{} + log.Debugf("access log stats count: %d", len(simpleMetrics)) + c.buf = append(c.buf, metrics.NewStatsEntityWrapper(c.baseDimensions.ToDimensions(), simpleMetrics, proto.MetricsReport_INSTANCE)) mu.Unlock() diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go index d985d78b5f..06368eb93a 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_error_log.go @@ -101,9 +101,7 @@ func NewNginxErrorLog( return nginxErrorLog } -func (c *NginxErrorLog) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() - +func (c *NginxErrorLog) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.collectLogStats(ctx, m) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go index 8bdd16c33e..a633cedd58 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_oss.go @@ -34,8 +34,7 @@ func NewNginxOSS(baseDimensions *metrics.CommonDim, namespace, stubStatus string return &NginxOSS{baseDimensions: baseDimensions, stubStatus: stubStatus, namedMetric: &namedMetric{namespace: namespace}, logger: NewMetricSourceLogger()} } -func (c *NginxOSS) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxOSS) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { var err error c.init.Do(func() { cl := client.NewNginxClient(&http.Client{}, c.stubStatus) @@ -106,6 +105,8 @@ func (c *NginxOSS) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *me simpleMetrics = append(simpleMetrics, &proto.SimpleMetric{Name: "nginx.status", Value: 1.0}) + log.Debugf("oss metrics count %d", len(simpleMetrics)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper(c.baseDimensions.ToDimensions(), simpleMetrics, proto.MetricsReport_INSTANCE): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go index 3077083ba8..105b063dfc 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_plus.go @@ -85,8 +85,7 @@ func NewNginxPlus(baseDimensions *metrics.CommonDim, nginxNamespace, plusNamespa return &NginxPlus{baseDimensions: baseDimensions, nginxNamespace: nginxNamespace, plusNamespace: plusNamespace, plusAPI: plusAPI, clientVersion: clientVersion, logger: NewMetricSourceLogger()} } -func (c *NginxPlus) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *NginxPlus) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { c.init.Do(func() { latestAPIVersion, err := c.getLatestAPIVersion(ctx, c.plusAPI) if err != nil { @@ -533,6 +532,8 @@ func (c *NginxPlus) commonMetrics(stats, prevStats *plusclient.Stats) *metrics.S "request.count": float64(requestCount), }) + log.Debugf("common metrics count %d", len(simpleMetrics)) + dims := c.baseDimensions.ToDimensions() return metrics.NewStatsEntityWrapper(dims, simpleMetrics, proto.MetricsReport_INSTANCE) } @@ -559,6 +560,8 @@ func (c *NginxPlus) sslMetrics(stats, prevStats *plusclient.Stats) *metrics.Stat "ssl.reuses": float64(sslReuses), }) + log.Debugf("SSL metrics count %d", len(simpleMetrics)) + dims := c.baseDimensions.ToDimensions() return metrics.NewStatsEntityWrapper(dims, simpleMetrics, proto.MetricsReport_INSTANCE) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go index da533967e3..61852b4eab 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_process.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -44,14 +43,14 @@ func (c *NginxProcess) getNginxCount() float64 { return 0.0 } -func (c *NginxProcess) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() - +func (c *NginxProcess) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { l := &namedMetric{namespace: PlusNamespace, group: ""} countSimpleMetric := l.convertSamplesToSimpleMetrics(map[string]float64{ "instance.count": c.getNginxCount(), }) + log.Debugf("instance metrics count %d", len(countSimpleMetric)) + select { case <-ctx.Done(): case m <- metrics.NewStatsEntityWrapper(c.baseDimensions.ToDimensions(), countSimpleMetric, proto.MetricsReport_INSTANCE): diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go index 82cdde4f4d..e7d6adfb18 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_static.go @@ -9,7 +9,6 @@ package sources import ( "context" - "sync" "github.com/nginx/agent/v2/src/core/metrics" log "github.com/sirupsen/logrus" @@ -26,9 +25,7 @@ func NewNginxStatic(baseDimensions *metrics.CommonDim, namespace string) *NginxS return &NginxStatic{baseDimensions: baseDimensions, namedMetric: &namedMetric{namespace: namespace}} } -func (c *NginxStatic) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() - +func (c *NginxStatic) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { SendNginxDownStatus(ctx, c.baseDimensions.ToDimensions(), m) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go index 12a64f8c58..e2312494bf 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go @@ -49,9 +49,8 @@ func NewNginxWorker(baseDimensions *metrics.CommonDim, } } -func (c *NginxWorker) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { +func (c *NginxWorker) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { var err error - defer wg.Done() childProcs := c.binary.GetChildProcesses() c.init.Do(func() { for pid, children := range childProcs { @@ -262,6 +261,8 @@ func (client *NginxWorkerClient) GetWorkerStats(childProcs []*proto.NginxDetails stats.Workers.KbsW = kbsw stats.Workers.FdsCount = fdSum + log.Debugf("worker stats for number of workers: %f", stats.Workers.Count) + return stats, nil } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go index 2197b0365a..a8d2e30223 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go @@ -12,7 +12,6 @@ import ( "fmt" "math/big" "os" - "sync" "github.com/nginx/agent/sdk/v2/proto" "github.com/nginx/agent/v2/src/core" @@ -49,8 +48,7 @@ func NewSwapSource(namespace string, env core.Environment) *Swap { return &Swap{NewMetricSourceLogger(), &namedMetric{namespace, "swap"}, statFunc} } -func (c *Swap) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *metrics.StatsEntityWrapper) { - defer wg.Done() +func (c *Swap) Collect(ctx context.Context, m chan<- *metrics.StatsEntityWrapper) { swapStats, err := c.statFunc() if err != nil { if e, ok := err.(*os.PathError); ok { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go index a11ccbb18e..91e087e5f7 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/mock_pipe.go @@ -146,3 +146,6 @@ func (p *MockMessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { } return pluginAlreadyRegistered } + +func (p *MockMessagePipe) Close() { +} diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go index e1f95cf324..885b91ba3c 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/os.go @@ -8,10 +8,16 @@ package core import ( + "context" "os" + "sync" "time" + + "github.com/nginx/agent/sdk/v2/backoff" ) +var chmodMutex sync.Mutex + // FileExists determines if the specified file given by the file path exists on the system. // If the file does NOT exist on the system the bool will be false and the error will be nil, // if the error is not nil then it's possible the file might exist but an error verifying it's @@ -42,19 +48,21 @@ func FilesExists(filePaths []string) (bool, error) { return true, nil } -func EnableWritePermissionForSocket(path string) error { - timeout := time.After(time.Second * 1) - var lastError error - for { - select { - case <-timeout: - return lastError - default: - lastError = os.Chmod(path, 0o660) - if lastError == nil { - return nil - } - } - <-time.After(time.Microsecond * 100) - } +// EnableWritePermissionForSocket attempts to set the write permissions for a socket file located at the specified path. +// The function continuously attempts the operation until either it succeeds or the timeout period elapses. +func EnableWritePermissionForSocket(ctx context.Context, path string) error { + err := backoff.WaitUntil(ctx, backoff.BackoffSettings{ + InitialInterval: time.Microsecond * 100, + MaxInterval: time.Microsecond * 100, + MaxElapsedTime: time.Second * 1, + Jitter: backoff.BACKOFF_JITTER, + Multiplier: backoff.BACKOFF_MULTIPLIER, + }, func() error { + chmodMutex.Lock() + lastError := os.Chmod(path, 0o660) + chmodMutex.Unlock() + return lastError + }) + + return err } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go index be4dff74ce..47311e79dc 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/pipe.go @@ -36,20 +36,18 @@ type MessagePipe struct { plugins []Plugin extensionPlugins []ExtensionPlugin ctx context.Context - cancel context.CancelFunc mu sync.RWMutex bus message_bus.MessageBus } func NewMessagePipe(ctx context.Context, size int) *MessagePipe { - pipeContext, pipeCancel := context.WithCancel(ctx) return &MessagePipe{ messageChannel: make(chan *Message, size), plugins: make([]Plugin, 0, MaxPlugins), extensionPlugins: make([]ExtensionPlugin, 0, MaxExtensionPlugins), - ctx: pipeContext, - cancel: pipeCancel, + ctx: ctx, mu: sync.RWMutex{}, + bus: message_bus.New(size), } } @@ -64,10 +62,10 @@ func InitializePipe(ctx context.Context, corePlugins []Plugin, extensionPlugins func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []ExtensionPlugin) error { p.mu.Lock() + defer p.mu.Unlock() p.plugins = append(p.plugins, plugins...) p.extensionPlugins = append(p.extensionPlugins, extensionPlugins...) - p.bus = message_bus.New(size) pluginsRegistered := []string{} extensionPluginsRegistered := []string{} @@ -91,25 +89,26 @@ func (p *MessagePipe) Register(size int, plugins []Plugin, extensionPlugins []Ex } extensionPluginsRegistered = append(extensionPluginsRegistered, *plugin.Info().name) } - log.Infof("The following core plugins have being registered: %q", pluginsRegistered) - log.Infof("The following extension plugins have being registered: %q", extensionPluginsRegistered) - p.mu.Unlock() + log.Infof("The following core plugins have been registered: %q", pluginsRegistered) + log.Infof("The following extension plugins have been registered: %q", extensionPluginsRegistered) + return nil } func (p *MessagePipe) DeRegister(pluginNames []string) error { p.mu.Lock() + defer p.mu.Unlock() - var plugins []Plugin + var pluginsToRemove []Plugin for _, name := range pluginNames { for _, plugin := range p.plugins { if plugin.Info().Name() == name { - plugins = append(plugins, plugin) + pluginsToRemove = append(pluginsToRemove, plugin) } } } - for _, plugin := range plugins { + for _, plugin := range pluginsToRemove { index := getIndex(plugin.Info().Name(), p.plugins) if index != -1 { @@ -124,10 +123,8 @@ func (p *MessagePipe) DeRegister(pluginNames []string) error { } } } - } - p.mu.Unlock() return nil } @@ -143,9 +140,11 @@ func getIndex(pluginName string, plugins []Plugin) int { func (p *MessagePipe) Process(messages ...*Message) { for _, m := range messages { select { - case p.messageChannel <- m: case <-p.ctx.Done(): return + case p.messageChannel <- m: + default: + return } } } @@ -156,20 +155,13 @@ func (p *MessagePipe) Run() { for { select { case <-p.ctx.Done(): - for _, r := range p.plugins { - r.Close() - } - - for _, r := range p.extensionPlugins { - r.Close() - } - - close(p.messageChannel) - + p.cleanup() return case m := <-p.messageChannel: p.mu.Lock() - p.bus.Publish(m.Topic(), m) + if p.bus != nil { + p.bus.Publish(m.Topic(), m) + } p.mu.Unlock() } } @@ -179,18 +171,47 @@ func (p *MessagePipe) Context() context.Context { return p.ctx } -func (p *MessagePipe) Cancel() context.CancelFunc { - return p.cancel -} - func (p *MessagePipe) GetPlugins() []Plugin { + p.mu.RLock() + defer p.mu.RUnlock() return p.plugins } func (p *MessagePipe) GetExtensionPlugins() []ExtensionPlugin { + p.mu.RLock() + defer p.mu.RUnlock() return p.extensionPlugins } +func (p *MessagePipe) cleanup() { + p.mu.RLock() + defer p.mu.RUnlock() + for _, r := range p.plugins { + for _, subscription := range r.Subscriptions() { + if p.bus != nil { + p.bus.Close(subscription) + } + } + r.Close() + } + + for _, r := range p.extensionPlugins { + for _, subscription := range r.Subscriptions() { + if p.bus != nil { + p.bus.Close(subscription) + } + } + r.Close() + } + + p.bus = nil + p.plugins = nil + if p.messageChannel != nil { + close(p.messageChannel) + } + p.messageChannel = nil +} + func (p *MessagePipe) initPlugins() { for _, r := range p.plugins { r.Init(p) @@ -202,11 +223,13 @@ func (p *MessagePipe) initPlugins() { } func (p *MessagePipe) IsPluginAlreadyRegistered(pluginName string) bool { - pluginAlreadyRegistered := false + p.mu.RLock() + defer p.mu.RUnlock() + for _, plugin := range p.GetPlugins() { if plugin.Info().Name() == pluginName { - pluginAlreadyRegistered = true + return true } } - return pluginAlreadyRegistered + return false } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go index 67b3074934..0609ee37ec 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/tailer/tailer.go @@ -127,6 +127,11 @@ func (t *Tailer) Tail(ctx context.Context, data chan<- string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } + stopErr := t.handle.Stop() + if stopErr != nil { + log.Tracef("Unable to stop tailer, %v", stopErr) + return + } log.Trace("Tailer is done") return } @@ -156,6 +161,13 @@ func (t *PatternTailer) Tail(ctx context.Context, data chan<- map[string]string) case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } + + stopErr := t.handle.Stop() + if stopErr != nil { + log.Tracef("Unable to stop tailer, %v", stopErr) + return + } + log.Tracef("Tailer is done") return } @@ -184,6 +196,12 @@ func (t *LTSVTailer) Tail(ctx context.Context, data chan<- map[string]string) { case context.Canceled: log.Tracef("Tailer forcibly cancelled, %v", ctxErr) } + stopErr := t.handle.Stop() + if stopErr != nil { + log.Tracef("Unable to stop tailer, %v", stopErr) + return + } + log.Tracef("Tailer is done") return } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/advanced_metrics.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/advanced_metrics.go index 33ad249be3..32b61fef2d 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/advanced_metrics.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/advanced_metrics.go @@ -259,9 +259,9 @@ func (m *AdvancedMetrics) run() { } }() defer m.ctxCancel() - err := core.EnableWritePermissionForSocket(m.cfg.Address) + err := core.EnableWritePermissionForSocket(m.ctx, m.cfg.Address) if err != nil { - log.Error("App centric metric plugin failed to change socket permissions") + log.Errorf("App centric metric plugin failed to change socket permissions: %v", err) } commonDimensions := append(m.commonDims.ToDimensions(), &proto.Dimension{ Name: aggregationDurationDimension, diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nap_monitoring.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nap_monitoring.go index a59d3bfdfa..061a31d5cd 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nap_monitoring.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nap_monitoring.go @@ -11,12 +11,13 @@ import ( "context" "time" + "github.com/nginx/agent/v2/src/core/metrics" + agent_config "github.com/nginx/agent/sdk/v2/agent/config" "github.com/nginx/agent/sdk/v2/proto" models "github.com/nginx/agent/sdk/v2/proto/events" "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/config" - "github.com/nginx/agent/v2/src/core/metrics" "github.com/nginx/agent/v2/src/core/payloads" "github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager" @@ -41,16 +42,18 @@ var nginxAppProtectMonitoringDefault = &manager.NginxAppProtectMonitoringConfig{ } type NAPMonitoring struct { - monitorMgr *manager.Manager - messagePipeline core.MessagePipeInterface - reportInterval time.Duration - reportCount int - ctx context.Context - ctxCancel context.CancelFunc + monitorMgr *manager.Manager + messagePipeline core.MessagePipeInterface + reportInterval time.Duration + reportCount int + ctx context.Context + ctxCancel context.CancelFunc + nginxAppProtectMonitoringConfig *manager.NginxAppProtectMonitoringConfig + env core.Environment + cfg *config.Config } func NewNAPMonitoring(env core.Environment, cfg *config.Config, nginxAppProtectMonitoringConf interface{}) (*NAPMonitoring, error) { - commonDims := metrics.NewCommonDim(env.NewHostInfo("agentVersion", &cfg.Tags, cfg.ConfigDirs, false), cfg, "") nginxAppProtectMonitoringConfig := nginxAppProtectMonitoringDefault if nginxAppProtectMonitoringConf != nil { @@ -62,11 +65,6 @@ func NewNAPMonitoring(env core.Environment, cfg *config.Config, nginxAppProtectM } } - m, err := manager.NewManager(nginxAppProtectMonitoringConfig, commonDims) - if err != nil { - return nil, err - } - if !(nginxAppProtectMonitoringConfig.ReportInterval > minReportIntervalDelimiter) { log.Warnf("NAP Monitoring report interval must be higher than %v. Defaulting to %v", minReportIntervalDelimiter, @@ -83,9 +81,11 @@ func NewNAPMonitoring(env core.Environment, cfg *config.Config, nginxAppProtectM } return &NAPMonitoring{ - monitorMgr: m, - reportInterval: nginxAppProtectMonitoringConfig.ReportInterval, - reportCount: nginxAppProtectMonitoringConfig.ReportCount, + cfg: cfg, + nginxAppProtectMonitoringConfig: nginxAppProtectMonitoringConfig, + env: env, + reportInterval: nginxAppProtectMonitoringConfig.ReportInterval, + reportCount: nginxAppProtectMonitoringConfig.ReportCount, }, nil } @@ -94,6 +94,15 @@ func (n *NAPMonitoring) Info() *core.Info { } func (n *NAPMonitoring) Init(pipeline core.MessagePipeInterface) { + commonDims := metrics.NewCommonDim(n.env.NewHostInfo("agentVersion", &n.cfg.Tags, n.cfg.ConfigDirs, false), n.cfg, "") + + m, err := manager.NewManager(n.nginxAppProtectMonitoringConfig, commonDims) + if err != nil { + log.Errorf("Could not initialize nginx-app-protect-monitoring: %v", err) + return + } + + n.monitorMgr = m log.Infof("%s initializing", napMonitoringPluginName) n.messagePipeline = pipeline ctx, cancel := context.WithCancel(n.messagePipeline.Context()) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/collector.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/collector.go index bc9f7e085e..dd18ccec2d 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/collector.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/collector.go @@ -9,7 +9,6 @@ package collector import ( "context" - "sync" "github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring" ) @@ -18,5 +17,5 @@ import ( // collect Raw Log data from WAF Instances. type Collector interface { // Collect starts collecting on collect chan until ctx.Done() chan gets a signal - Collect(ctx context.Context, wg *sync.WaitGroup, collect chan<- *monitoring.RawLog) + Collect(ctx context.Context, collect chan<- *monitoring.RawLog) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go index f7b71b2302..70af0ab9eb 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/collector/nap.go @@ -10,7 +10,6 @@ package collector import ( "context" "fmt" - "sync" "github.com/sirupsen/logrus" "gopkg.in/mcuadros/go-syslog.v2" @@ -84,9 +83,7 @@ func newSyslogServer(logger *logrus.Entry, ip string, port int) (*syslogServer, } // Collect starts collecting on collect chan until done chan gets a signal. -func (nap *NAPCollector) Collect(ctx context.Context, wg *sync.WaitGroup, collect chan<- *monitoring.RawLog) { - defer wg.Done() - +func (nap *NAPCollector) Collect(ctx context.Context, collect chan<- *monitoring.RawLog) { nap.logger.Infof("Starting collection for %s", monitoring.NAP) for { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go index 1c4e30f560..4c0700a00f 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/manager/manager.go @@ -10,7 +10,6 @@ package manager import ( "context" "runtime" - "sync" "time" log "github.com/sirupsen/logrus" @@ -152,17 +151,12 @@ func (s *Manager) Run(ctx context.Context) { chtx, cancel := context.WithCancel(ctx) defer cancel() - waitGroup := &sync.WaitGroup{} - waitGroup.Add(2) - - go s.collector.Collect(chtx, waitGroup, s.collectChan) - go s.processor.Process(chtx, waitGroup, s.collectChan, s.processorChan) + go s.collector.Collect(chtx, s.collectChan) + go s.processor.Process(chtx, s.collectChan, s.processorChan) <-ctx.Done() s.logger.Infof("Received Context cancellation, %s is wrapping up...", componentName) - waitGroup.Wait() - s.logger.Infof("Context cancellation, %s wrapped up...", componentName) } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go index da2065c8df..810f334e81 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/processor.go @@ -76,8 +76,6 @@ func GetClient(cfg *Config) (*Client, error) { // processorWorker is a worker process to process events. func (c *Client) processorWorker(ctx context.Context, wg *sync.WaitGroup, id int, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { - defer wg.Done() - c.logger.Debugf("Setting up Processor Worker: %d", id) for { @@ -121,14 +119,11 @@ func (c *Client) processorWorker(ctx context.Context, wg *sync.WaitGroup, id int } // Process processes the raw log entries from collected chan into Security Events on processed chan. -func (c *Client) Process(ctx context.Context, wg *sync.WaitGroup, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { - defer wg.Done() - +func (c *Client) Process(ctx context.Context, collected <-chan *monitoring.RawLog, processed chan<- *pb.Event) { c.logger.Info("Setting up Processor") for id := 1; id <= c.workers; id++ { - wg.Add(1) - go c.processorWorker(ctx, wg, id, collected, processed) + go c.processorWorker(ctx, nil, id, collected, processed) } c.logger.Infof("Done setting up %v Processor Workers", c.workers) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go index 2043859d77..49a486d10a 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go @@ -8,11 +8,13 @@ package nap import ( + "context" "fmt" "io/fs" "os" "path/filepath" "strings" + "sync" "time" "github.com/nginx/agent/v2/src/core" @@ -31,6 +33,7 @@ var ( requiredNAPFiles = []string{NAP_VERSION_FILE, NAP_RELEASE_FILE} requireNAPProcesses = []string{BD_SOCKET_PLUGIN_PROCESS} processCheckFunc = core.CheckForProcesses + mu = sync.Mutex{} ) // NewNginxAppProtect returns the object NginxAppProtect, which contains information related @@ -96,25 +99,27 @@ func NewNginxAppProtect(optDirPath, symLinkDir string) (*NginxAppProtect, error) // - NAP version changed // - Attack signature installed/version changed // - Threat campaign installed/version changed -func (nap *NginxAppProtect) Monitor(pollInterval time.Duration) chan NAPReportBundle { +func (nap *NginxAppProtect) Monitor(ctx context.Context, pollInterval time.Duration) chan NAPReportBundle { msgChannel := make(chan NAPReportBundle) - go nap.monitor(msgChannel, pollInterval) + go nap.monitor(ctx, msgChannel, pollInterval) return msgChannel } // monitor checks the system for any NAP related changes and communicates those changes with // a report message sent via the channel provided to it. -func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterval time.Duration) { +func (nap *NginxAppProtect) monitor(ctx context.Context, msgChannel chan NAPReportBundle, pollInterval time.Duration) { // Initial symlink sync + mu.Lock() if nap.Release.VersioningDetails.NAPRelease != "" { err := nap.syncSymLink("", nap.Release.VersioningDetails.NAPBuild) if err != nil { log.Errorf("Error occurred while performing initial sync for NAP symlink - %v", err) } } + mu.Unlock() ticker := time.NewTicker(pollInterval) - + defer ticker.Stop() for { select { case <-ticker.C: @@ -127,8 +132,10 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva newNAPReport := newNap.GenerateNAPReport() // Check if there has been any change in the NAP report + mu.Lock() if nap.napReportIsEqual(newNAPReport) { log.Debugf("No change in NAP detected... Checking NAP again in %v seconds", pollInterval.Seconds()) + mu.Unlock() break } @@ -140,6 +147,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva err = nap.syncSymLink(nap.Release.VersioningDetails.NAPBuild, newNAPReport.NAPVersion) if err != nil { log.Errorf("Got the following error syncing NAP symlink - %v", err) + mu.Unlock() break } @@ -148,12 +156,15 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva nap.Release = newNap.Release nap.AttackSignaturesVersion = newNap.AttackSignaturesVersion nap.ThreatCampaignsVersion = newNap.ThreatCampaignsVersion + mu.Unlock() // Send the update message through the channel msgChannel <- NAPReportBundle{ PreviousReport: previousReport, UpdatedReport: newNAPReport, } + case <-ctx.Done(): + return } } } @@ -236,6 +247,8 @@ func (nap *NginxAppProtect) removeNAPSymlinks(symlinkPatternToIgnore string) err // function has NOT called the Monitor function that is responsible for updating its values // to be in sync with the current system NAP values. func (nap *NginxAppProtect) GenerateNAPReport() NAPReport { + mu.Lock() + defer mu.Unlock() return NAPReport{ NAPVersion: nap.Release.VersioningDetails.NAPBuild, NAPRelease: nap.Release.VersioningDetails.NAPRelease, diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx_app_protect.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx_app_protect.go index 62c7e0328d..fccffa6a7b 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx_app_protect.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx_app_protect.go @@ -130,8 +130,8 @@ func (n *NginxAppProtect) monitor() { ), ) - napUpdateChannel := n.nap.Monitor(n.reportInterval) - + napUpdateChannel := n.nap.Monitor(n.ctx, n.reportInterval) + defer close(napUpdateChannel) for { select { case updateMsg := <-napUpdateChannel: diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/prometheus-metrics/prometheus_exporter.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/prometheus-metrics/prometheus_exporter.go index a7688a48d5..31b45ba333 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/prometheus-metrics/prometheus_exporter.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/prometheus-metrics/prometheus_exporter.go @@ -4,6 +4,7 @@ import ( "strings" "github.com/nginx/agent/sdk/v2/proto" + "github.com/nginx/agent/v2/src/core" "github.com/nginx/agent/v2/src/core/metrics" "github.com/prometheus/client_golang/prometheus" @@ -21,10 +22,16 @@ func (e *Exporter) SetLatestMetricReport(latest *metrics.MetricsReportBundle) { e.latestMetricReports = latest } -func (e *Exporter) GetLatestMetricReports() (reports []*proto.MetricsReport) { - for _, report := range e.latestMetricReports.Data { - reports = append(reports, report) +func (e *Exporter) SetLatestMetricReports(data []core.Payload) { + e.latestMetricReports.Data = nil + + for _, report := range data { + e.latestMetricReports.Data = append(e.latestMetricReports.Data, report.(*proto.MetricsReport)) } +} + +func (e *Exporter) GetLatestMetricReports() (reports []*proto.MetricsReport) { + reports = append(reports, e.latestMetricReports.Data...) return } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go index ba212bd7cc..e8e55899b0 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/agent_api.go @@ -204,10 +204,12 @@ func (a *AgentAPI) Process(message *core.Message) { default: log.Warnf("Unknown Command_NginxConfigResponse type: %T(%v)", message.Data(), message.Data()) } - case core.MetricReport: + case core.CommMetrics: switch response := message.Data().(type) { case *metrics.MetricsReportBundle: a.exporter.SetLatestMetricReport(response) + case []core.Payload: + a.exporter.SetLatestMetricReports(response) default: log.Warnf("Unknown MetricReportBundle type: %T(%v)", message.Data(), message.Data()) } @@ -240,7 +242,6 @@ func (a *AgentAPI) Info() *core.Info { func (a *AgentAPI) Subscriptions() []string { return []string{ core.AgentAPIConfigApplyResponse, - core.MetricReport, core.NginxConfigValidationPending, core.NginxConfigApplyFailed, core.NginxConfigApplySucceeded, @@ -248,6 +249,7 @@ func (a *AgentAPI) Subscriptions() []string { core.AgentConnected, core.CommandSent, core.MetricReportSent, + core.CommMetrics, } } @@ -383,7 +385,7 @@ func (h *NginxHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // // 200: []NginxDetails // 500 -func (h *NginxHandler) sendInstanceDetailsPayload(w http.ResponseWriter, r *http.Request) error { +func (h *NginxHandler) sendInstanceDetailsPayload(w http.ResponseWriter, _ *http.Request) error { nginxDetails := h.getNginxDetails() w.WriteHeader(http.StatusOK) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/features.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/features.go index 6beeee9f5d..1f38ab54f0 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/features.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/features.go @@ -133,7 +133,7 @@ func (f *Features) Process(msg *core.Message) { } } -func (f *Features) enableMetricsFeature(data string) []core.Plugin { +func (f *Features) enableMetricsFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) { conf, err := config.GetConfig(f.conf.ClientID) @@ -151,7 +151,7 @@ func (f *Features) enableMetricsFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableMetricsCollectionFeature(data string) []core.Plugin { +func (f *Features) enableMetricsCollectionFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) && !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsCollection) { @@ -168,7 +168,7 @@ func (f *Features) enableMetricsCollectionFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableMetricsThrottleFeature(data string) []core.Plugin { +func (f *Features) enableMetricsThrottleFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) && !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsThrottle) { @@ -185,7 +185,7 @@ func (f *Features) enableMetricsThrottleFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableMetricsSenderFeature(data string) []core.Plugin { +func (f *Features) enableMetricsSenderFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetrics) && !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureMetricsSender) { @@ -202,7 +202,7 @@ func (f *Features) enableMetricsSenderFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableAgentAPIFeature(data string) []core.Plugin { +func (f *Features) enableAgentAPIFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureAgentAPI) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -217,7 +217,7 @@ func (f *Features) enableAgentAPIFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableRegistrationFeature(data string) []core.Plugin { +func (f *Features) enableRegistrationFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureRegistration) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -232,7 +232,7 @@ func (f *Features) enableRegistrationFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableDataPlaneStatusFeature(data string) []core.Plugin { +func (f *Features) enableDataPlaneStatusFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureDataPlaneStatus) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -247,7 +247,7 @@ func (f *Features) enableDataPlaneStatusFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableProcessWatcherFeature(data string) []core.Plugin { +func (f *Features) enableProcessWatcherFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureProcessWatcher) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -262,7 +262,7 @@ func (f *Features) enableProcessWatcherFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableActivityEventsFeature(data string) []core.Plugin { +func (f *Features) enableActivityEventsFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureActivityEvents) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -277,7 +277,7 @@ func (f *Features) enableActivityEventsFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableFileWatcherFeature(data string) []core.Plugin { +func (f *Features) enableFileWatcherFeature(_ string) []core.Plugin { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureFileWatcher) { conf, err := config.GetConfig(f.conf.ClientID) if err != nil { @@ -293,7 +293,7 @@ func (f *Features) enableFileWatcherFeature(data string) []core.Plugin { return []core.Plugin{} } -func (f *Features) enableNginxCountingFeature(data string) []core.Plugin { +func (f *Features) enableNginxCountingFeature(_ string) []core.Plugin { countingPlugins := []core.Plugin{} if len(f.conf.Nginx.NginxCountingSocket) > 0 { if !f.pipeline.IsPluginAlreadyRegistered(agent_config.FeatureNginxCounting) { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/file_watcher.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/file_watcher.go index 74b3cfd2e6..9d3568c031 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/file_watcher.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/file_watcher.go @@ -51,15 +51,9 @@ const ( ) func NewFileWatcher(config *config.Config, env core.Environment) *FileWatcher { - watcher, err := fsnotify.NewWatcher() - if err != nil { - log.Errorf("Error creating file watcher: %v", err) - } - fw := &FileWatcher{ config: config, watching: &sync.Map{}, - watcher: watcher, wg: sync.WaitGroup{}, env: env, enabled: true, @@ -71,6 +65,14 @@ func NewFileWatcher(config *config.Config, env core.Environment) *FileWatcher { func (fw *FileWatcher) Init(pipeline core.MessagePipeInterface) { log.Info("FileWatcher initializing") + watcher, err := fsnotify.NewWatcher() + if err != nil { + log.Errorf("Error creating file watcher: %v", err) + return + } + + fw.watcher = watcher + fw.messagePipeline = pipeline fw.ctx, fw.cancelFunction = context.WithCancel(fw.messagePipeline.Context()) for dir := range fw.config.AllowedDirectoriesMap { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go index de869794bc..55238474c4 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics.go @@ -44,7 +44,7 @@ type Metrics struct { } func NewMetrics(config *config.Config, env core.Environment, binary core.NginxBinary, processes []*core.Process) *Metrics { - collectorConfigsMap := createCollectorConfigsMap(config, env, binary, processes) + collectorConfigsMap := createCollectorConfigsMap(config, binary, processes) return &Metrics{ collectorsUpdate: atomic.NewBool(false), ticker: time.NewTicker(config.AgentMetrics.CollectionInterval), @@ -67,6 +67,7 @@ func (m *Metrics) Init(pipeline core.MessagePipeInterface) { m.pipeline = pipeline m.ctx = pipeline.Context() go m.metricsGoroutine() + go m.drainBuffer(m.ctx) } func (m *Metrics) Close() { @@ -80,7 +81,7 @@ func (m *Metrics) Process(msg *core.Message) { case msg.Exact(core.AgentConfigChanged), msg.Exact(core.NginxConfigApplySucceeded): // If the agent config on disk changed or the NGINX statusAPI was updated // Then update Metrics with relevant config info - collectorConfigsMap := createCollectorConfigsMap(m.conf, m.env, m.binary, m.getNginxProccessInfo()) + collectorConfigsMap := createCollectorConfigsMap(m.conf, m.binary, m.getNginxProccessInfo()) m.collectorConfigsMapMutex.Lock() m.collectorConfigsMap = collectorConfigsMap m.collectorConfigsMapMutex.Unlock() @@ -101,7 +102,7 @@ func (m *Metrics) Process(msg *core.Message) { case msg.Exact(core.NginxDetailProcUpdate): m.syncProcessInfo(msg.Data().([]*core.Process)) - collectorConfigsMap := createCollectorConfigsMap(m.conf, m.env, m.binary, m.getNginxProccessInfo()) + collectorConfigsMap := createCollectorConfigsMap(m.conf, m.binary, m.getNginxProccessInfo()) for key, collectorConfig := range collectorConfigsMap { if _, ok := m.collectorConfigsMap[key]; !ok { log.Debugf("Adding new nginx collector for nginx id: %s", collectorConfig.NginxId) @@ -176,8 +177,33 @@ func (m *Metrics) metricsGoroutine() { } return case <-m.ticker.C: - stats := m.collectStats() - if bundlePayload := metrics.GenerateMetricsReportBundle(stats); bundlePayload != nil { + m.collectStats() + + if m.collectorsUpdate.Load() { + m.ticker = time.NewTicker(m.conf.AgentMetrics.CollectionInterval) + m.collectorsUpdate.Store(false) + } + + case err := <-m.errors: + log.Errorf("Error in metricsGoroutine %v", err) + } + } +} + +func (m *Metrics) drainBuffer(ctx context.Context) { + for { + // drain the buf, since our sources/collectors are all done, we can rely on buffer length + select { + case <-ctx.Done(): + log.Debug("context done in drainBuffer") + + err := ctx.Err() + if err != nil { + log.Errorf("error in done context collectStats %v", err) + } + return + case stats := <-m.buf: + if bundlePayload := metrics.GenerateMetricsReportBundle([]*metrics.StatsEntityWrapper{stats}); bundlePayload != nil { if m.conf.IsFeatureEnabled(agent_config.FeatureMetrics) || m.conf.IsFeatureEnabled(agent_config.FeatureMetricsThrottle) { m.pipeline.Process(core.NewMessage(core.MetricReport, bundlePayload)) } else { @@ -198,53 +224,22 @@ func (m *Metrics) metricsGoroutine() { } } } - - if m.collectorsUpdate.Load() { - m.ticker = time.NewTicker(m.conf.AgentMetrics.CollectionInterval) - m.collectorsUpdate.Store(false) - } - - case err := <-m.errors: - log.Errorf("Error in metricsGoroutine %v", err) } } } -func (m *Metrics) collectStats() (stats []*metrics.StatsEntityWrapper) { - // set a timeout for a millisecond less than the collection interval - ctx, cancel := context.WithTimeout(m.ctx, (m.interval - 1*time.Millisecond)) - defer cancel() +func (m *Metrics) collectStats() (stats chan *metrics.StatsEntityWrapper) { // locks the m.collectors to make sure it doesn't get deleted in the middle // of collection, as we will delete the old one if config changes. // maybe we can fine tune the lock later, but the collection has been very quick so far. m.collectorsMutex.Lock() defer m.collectorsMutex.Unlock() - wg := &sync.WaitGroup{} start := time.Now() for _, s := range m.collectors { - wg.Add(1) - go s.Collect(ctx, wg, m.buf) - } - // wait until all the collection go routines are done, which either context timeout or exit - wg.Wait() - - for len(m.buf) > 0 { - // drain the buf, since our sources/collectors are all done, we can rely on buffer length - select { - case <-ctx.Done(): - log.Debugf("context done in %s collectStats", time.Since(start)) - - err := ctx.Err() - if err != nil { - log.Errorf("error in done context collectStats %v", err) - } - return - case stat := <-m.buf: - stats = append(stats, stat) - } + go s.Collect(m.ctx, m.buf) } - log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), ctx.Err() != nil) + log.Debugf("collected %d entries in %s (ctx error=%t)", len(stats), time.Since(start), m.ctx.Err() != nil) return } @@ -304,7 +299,7 @@ func (m *Metrics) syncAgentConfigChange() { m.conf = conf } -func createCollectorConfigsMap(config *config.Config, env core.Environment, binary core.NginxBinary, processes []*core.Process) map[string]*metrics.NginxCollectorConfig { +func createCollectorConfigsMap(config *config.Config, binary core.NginxBinary, processes []*core.Process) map[string]*metrics.NginxCollectorConfig { collectorConfigsMap := make(map[string]*metrics.NginxCollectorConfig) for _, p := range processes { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go index 770bf27331..249ff15ef2 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/metrics_throlling.go @@ -4,7 +4,6 @@ * This source code is licensed under the Apache License, Version 2.0 license found in the * LICENSE file in the root directory of this source tree. */ - package plugins import ( @@ -37,6 +36,7 @@ type MetricsThrottle struct { metricsAggregation bool metricsCollections map[proto.MetricsReport_Type]*metrics.Collections ctx context.Context + cancel context.CancelFunc wg sync.WaitGroup mu sync.Mutex env core.Environment @@ -53,7 +53,6 @@ func NewMetricsThrottle(conf *config.Config, env core.Environment) *MetricsThrot collectorsUpdate: atomic.NewBool(false), metricsAggregation: conf.AgentMetrics.Mode == "aggregated", metricsCollections: make(map[proto.MetricsReport_Type]*metrics.Collections, 0), - wg: sync.WaitGroup{}, env: env, conf: conf, errors: make(chan error), @@ -62,10 +61,10 @@ func NewMetricsThrottle(conf *config.Config, env core.Environment) *MetricsThrot func (r *MetricsThrottle) Init(pipeline core.MessagePipeInterface) { r.messagePipeline = pipeline - r.ctx = pipeline.Context() + r.ctx, r.cancel = context.WithCancel(pipeline.Context()) if r.metricsAggregation { r.wg.Add(1) - go r.metricsReportGoroutine(r.ctx, &r.wg) + go r.metricsReportGoroutine() } log.Info("MetricsThrottle initializing") } @@ -73,6 +72,8 @@ func (r *MetricsThrottle) Init(pipeline core.MessagePipeInterface) { func (r *MetricsThrottle) Close() { log.Info("MetricsThrottle is wrapping up") r.reportsReady.Store(false) // allow metricsReportGoroutine to shutdown gracefully + r.cancel() + r.wg.Wait() r.ticker.Stop() } @@ -98,8 +99,9 @@ func (r *MetricsThrottle) Process(msg *core.Message) { if len(report.Data) > 0 { if _, ok := r.metricsCollections[report.Type]; !ok { r.metricsCollections[report.Type] = &metrics.Collections{ - Count: 0, - Data: make(map[string]metrics.PerDimension), + Count: 0, + MetricsCount: make(map[string]metrics.PerDimension), + Data: make(map[string]metrics.PerDimension), } } collection := metrics.SaveCollections(*r.metricsCollections[report.Type], report) @@ -136,19 +138,29 @@ func (r *MetricsThrottle) Subscriptions() []string { return []string{core.MetricReport, core.AgentConfigChanged} } -func (r *MetricsThrottle) metricsReportGoroutine(ctx context.Context, wg *sync.WaitGroup) { - defer wg.Done() +func (r *MetricsThrottle) metricsReportGoroutine() { + defer r.wg.Done() defer r.ticker.Stop() + defer close(r.errors) log.Info("MetricsThrottle waiting for report ready") for { - if !r.reportsReady.Load() { - continue + select { + case <-r.ctx.Done(): + err := r.ctx.Err() + if err != nil && err != context.Canceled { + log.Errorf("error in done context metricsReportGoroutine %v", err) + } + return + default: + if !r.reportsReady.Load() { + continue + } } select { - case <-ctx.Done(): + case <-r.ctx.Done(): err := r.ctx.Err() - if err != nil { + if err != nil && err != context.Canceled { log.Errorf("error in done context metricsReportGoroutine %v", err) } return @@ -167,7 +179,9 @@ func (r *MetricsThrottle) metricsReportGoroutine(ctx context.Context, wg *sync.W r.collectorsUpdate.Store(false) } case err := <-r.errors: - log.Errorf("Error in metricsReportGoroutine %v", err) + if err != nil { + log.Errorf("Error in metricsReportGoroutine %v", err) + } } } } @@ -192,16 +206,20 @@ func (r *MetricsThrottle) getAggregatedReports() (reports []core.Payload) { defer r.mu.Unlock() for reportType, collection := range r.metricsCollections { - reports = append(reports, &proto.MetricsReport{ + report := &proto.MetricsReport{ Meta: &proto.Metadata{ Timestamp: types.TimestampNow(), }, Type: reportType, Data: metrics.GenerateMetrics(*collection), - }) + } + + reports = append(reports, report) + r.metricsCollections[reportType] = &metrics.Collections{ - Count: 0, - Data: make(map[string]metrics.PerDimension), + Count: 0, + MetricsCount: map[string]metrics.PerDimension{}, + Data: make(map[string]metrics.PerDimension), } } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_counter.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_counter.go index 68f9b4fe7a..e4d3e1e53c 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_counter.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_counter.go @@ -84,7 +84,7 @@ func (nc *NginxCounter) agentServer(serverAddress []string) { log.Warn("failed to start NGINX counter listener") } - err = core.EnableWritePermissionForSocket(serverAddress[1]) + err = core.EnableWritePermissionForSocket(nc.ctx, serverAddress[1]) if err != nil { log.Warn("unable to set correct write permissions for NGINX counter socket") } @@ -115,6 +115,10 @@ func (nc *NginxCounter) Close() { if err := os.RemoveAll(nc.serverAddress[1]); err != nil { log.Warn("Error removing socket") } + + nc.processMutex.RLock() + nc.nginxes = nil + nc.processMutex.RUnlock() } func (nc *NginxCounter) Info() *core.Info { diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/registration.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/registration.go index 1f67865d36..7ec3a22ef8 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/registration.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/registration.go @@ -148,7 +148,7 @@ func (r *OneTimeRegistration) areDataplaneSoftwareDetailsReady() error { for _, extension := range r.config.Extensions { if _, ok := r.dataplaneSoftwareDetails[extension]; !ok { - return fmt.Errorf("Registration max retries has been met before the extension %s was ready for registration", extension) + return fmt.Errorf("registration max retries has been met before the extension %s was ready for registration", extension) } } diff --git a/test/performance/vendor/golang.org/x/sys/LICENSE b/test/performance/vendor/golang.org/x/sys/LICENSE index 6a66aea5ea..2a7cf70da6 100644 --- a/test/performance/vendor/golang.org/x/sys/LICENSE +++ b/test/performance/vendor/golang.org/x/sys/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/test/performance/vendor/golang.org/x/sys/cpu/cpu.go b/test/performance/vendor/golang.org/x/sys/cpu/cpu.go index 8fa707aa4b..ec07aab057 100644 --- a/test/performance/vendor/golang.org/x/sys/cpu/cpu.go +++ b/test/performance/vendor/golang.org/x/sys/cpu/cpu.go @@ -105,6 +105,8 @@ var ARM64 struct { HasSVE bool // Scalable Vector Extensions HasSVE2 bool // Scalable Vector Extensions 2 HasASIMDFHM bool // Advanced SIMD multiplication FP16 to FP32 + HasDIT bool // Data Independent Timing support + HasI8MM bool // Advanced SIMD Int8 matrix multiplication instructions _ CacheLinePad } diff --git a/test/performance/vendor/golang.org/x/sys/cpu/cpu_arm64.go b/test/performance/vendor/golang.org/x/sys/cpu/cpu_arm64.go index 0e27a21e1f..af2aa99f9f 100644 --- a/test/performance/vendor/golang.org/x/sys/cpu/cpu_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/cpu/cpu_arm64.go @@ -38,6 +38,8 @@ func initOptions() { {Name: "dcpop", Feature: &ARM64.HasDCPOP}, {Name: "asimddp", Feature: &ARM64.HasASIMDDP}, {Name: "asimdfhm", Feature: &ARM64.HasASIMDFHM}, + {Name: "dit", Feature: &ARM64.HasDIT}, + {Name: "i8mm", Feature: &ARM64.HasI8MM}, } } @@ -145,6 +147,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { ARM64.HasLRCPC = true } + switch extractBits(isar1, 52, 55) { + case 1: + ARM64.HasI8MM = true + } + // ID_AA64PFR0_EL1 switch extractBits(pfr0, 16, 19) { case 0: @@ -168,6 +175,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { parseARM64SVERegister(getzfr0()) } + + switch extractBits(pfr0, 48, 51) { + case 1: + ARM64.HasDIT = true + } } func parseARM64SVERegister(zfr0 uint64) { diff --git a/test/performance/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go b/test/performance/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go index 3d386d0fc2..08f35ea177 100644 --- a/test/performance/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go @@ -35,8 +35,10 @@ const ( hwcap_SHA512 = 1 << 21 hwcap_SVE = 1 << 22 hwcap_ASIMDFHM = 1 << 23 + hwcap_DIT = 1 << 24 hwcap2_SVE2 = 1 << 1 + hwcap2_I8MM = 1 << 13 ) // linuxKernelCanEmulateCPUID reports whether we're running @@ -106,9 +108,12 @@ func doinit() { ARM64.HasSHA512 = isSet(hwCap, hwcap_SHA512) ARM64.HasSVE = isSet(hwCap, hwcap_SVE) ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM) + ARM64.HasDIT = isSet(hwCap, hwcap_DIT) + // HWCAP2 feature bits ARM64.HasSVE2 = isSet(hwCap2, hwcap2_SVE2) + ARM64.HasI8MM = isSet(hwCap2, hwcap2_I8MM) } func isSet(hwc uint, value uint) bool { diff --git a/test/performance/vendor/golang.org/x/sys/unix/mkerrors.sh b/test/performance/vendor/golang.org/x/sys/unix/mkerrors.sh index 4ed2e488b6..d07dd09eb5 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/test/performance/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -58,6 +58,7 @@ includes_Darwin=' #define _DARWIN_USE_64_BIT_INODE #define __APPLE_USE_RFC_3542 #include +#include #include #include #include diff --git a/test/performance/vendor/golang.org/x/sys/unix/syscall_darwin.go b/test/performance/vendor/golang.org/x/sys/unix/syscall_darwin.go index 4cc7b00596..2d15200adb 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/test/performance/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -402,6 +402,18 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq)) } +//sys renamexNp(from string, to string, flag uint32) (err error) + +func RenamexNp(from string, to string, flag uint32) (err error) { + return renamexNp(from, to, flag) +} + +//sys renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) + +func RenameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + return renameatxNp(fromfd, from, tofd, to, flag) +} + //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL func Uname(uname *Utsname) error { diff --git a/test/performance/vendor/golang.org/x/sys/unix/syscall_linux.go b/test/performance/vendor/golang.org/x/sys/unix/syscall_linux.go index 5682e2628a..3f1d3d4cb2 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/test/performance/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -2592,3 +2592,4 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { } //sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) +//sys Mseal(b []byte, flags uint) (err error) diff --git a/test/performance/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/test/performance/vendor/golang.org/x/sys/unix/syscall_openbsd.go index b25343c71a..b86ded549c 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/test/performance/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -293,6 +293,7 @@ func Uname(uname *Utsname) error { //sys Mkfifoat(dirfd int, path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index e40fa85245..4308ac1772 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index bb02aa6c05..c8068a7a16 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux.go index 877a62b479..01a70b2463 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -457,6 +457,7 @@ const ( B600 = 0x8 B75 = 0x2 B9600 = 0xd + BCACHEFS_SUPER_MAGIC = 0xca451a4e BDEVFS_MAGIC = 0x62646576 BINDERFS_SUPER_MAGIC = 0x6c6f6f70 BINFMTFS_MAGIC = 0x42494e4d @@ -928,6 +929,7 @@ const ( EPOLL_CTL_ADD = 0x1 EPOLL_CTL_DEL = 0x2 EPOLL_CTL_MOD = 0x3 + EPOLL_IOC_TYPE = 0x8a EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2 ESP_V4_FLOW = 0xa ESP_V6_FLOW = 0xc @@ -941,9 +943,6 @@ const ( ETHTOOL_FEC_OFF = 0x4 ETHTOOL_FEC_RS = 0x8 ETHTOOL_FLAG_ALL = 0x7 - ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 - ETHTOOL_FLAG_OMIT_REPLY = 0x2 - ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_FLASHDEV = 0x33 ETHTOOL_FLASH_MAX_FILENAME = 0x80 ETHTOOL_FWVERS_LEN = 0x20 @@ -1705,6 +1704,7 @@ const ( KEXEC_ARCH_S390 = 0x160000 KEXEC_ARCH_SH = 0x2a0000 KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_CRASH_HOTPLUG_SUPPORT = 0x8 KEXEC_FILE_DEBUG = 0x8 KEXEC_FILE_NO_INITRAMFS = 0x4 KEXEC_FILE_ON_CRASH = 0x2 @@ -1780,6 +1780,7 @@ const ( KEY_SPEC_USER_KEYRING = -0x4 KEY_SPEC_USER_SESSION_KEYRING = -0x5 LANDLOCK_ACCESS_FS_EXECUTE = 0x1 + LANDLOCK_ACCESS_FS_IOCTL_DEV = 0x8000 LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800 LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40 LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80 @@ -1861,6 +1862,19 @@ const ( MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_FIXED_NOREPLACE = 0x100000 + MAP_HUGE_16GB = 0x88000000 + MAP_HUGE_16KB = 0x38000000 + MAP_HUGE_16MB = 0x60000000 + MAP_HUGE_1GB = 0x78000000 + MAP_HUGE_1MB = 0x50000000 + MAP_HUGE_256MB = 0x70000000 + MAP_HUGE_2GB = 0x7c000000 + MAP_HUGE_2MB = 0x54000000 + MAP_HUGE_32MB = 0x64000000 + MAP_HUGE_512KB = 0x4c000000 + MAP_HUGE_512MB = 0x74000000 + MAP_HUGE_64KB = 0x40000000 + MAP_HUGE_8MB = 0x5c000000 MAP_HUGE_MASK = 0x3f MAP_HUGE_SHIFT = 0x1a MAP_PRIVATE = 0x2 @@ -2498,6 +2512,23 @@ const ( PR_PAC_GET_ENABLED_KEYS = 0x3d PR_PAC_RESET_KEYS = 0x36 PR_PAC_SET_ENABLED_KEYS = 0x3c + PR_PPC_DEXCR_CTRL_CLEAR = 0x4 + PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10 + PR_PPC_DEXCR_CTRL_EDITABLE = 0x1 + PR_PPC_DEXCR_CTRL_MASK = 0x1f + PR_PPC_DEXCR_CTRL_SET = 0x2 + PR_PPC_DEXCR_CTRL_SET_ONEXEC = 0x8 + PR_PPC_DEXCR_IBRTPD = 0x1 + PR_PPC_DEXCR_NPHIE = 0x3 + PR_PPC_DEXCR_SBHE = 0x0 + PR_PPC_DEXCR_SRAPD = 0x2 + PR_PPC_GET_DEXCR = 0x48 + PR_PPC_SET_DEXCR = 0x49 + PR_RISCV_CTX_SW_FENCEI_OFF = 0x1 + PR_RISCV_CTX_SW_FENCEI_ON = 0x0 + PR_RISCV_SCOPE_PER_PROCESS = 0x0 + PR_RISCV_SCOPE_PER_THREAD = 0x1 + PR_RISCV_SET_ICACHE_FLUSH_CTX = 0x47 PR_RISCV_V_GET_CONTROL = 0x46 PR_RISCV_V_SET_CONTROL = 0x45 PR_RISCV_V_VSTATE_CTRL_CUR_MASK = 0x3 @@ -3192,6 +3223,7 @@ const ( STATX_MTIME = 0x40 STATX_NLINK = 0x4 STATX_SIZE = 0x200 + STATX_SUBVOL = 0x8000 STATX_TYPE = 0x1 STATX_UID = 0x8 STATX__RESERVED = 0x80000000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index e4bc0bd57c..684a5168da 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 689317afdb..61d74b592d 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 5cca668ac3..a28c9e3e89 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 14270508b0..ab5d1fe8ea 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 ESR_MAGIC = 0x45535201 EXTPROC = 0x10000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 28e39afdcb..c523090e7c 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index cd66e92cb4..01e6ea7804 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index c1595eba78..7aa610b1e7 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ee9456b0da..92af771b44 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 8cfca81e1b..b27ef5e6f1 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 60b0deb3af..237a2cefb3 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index f90aa7281b..4a5c555a36 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index ba9e015033..a02fb49a5f 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 07cdfd6e9f..e26a7c61b2 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 2f1dd214a7..c48f7c2103 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index f40519d901..ad4b9aace7 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -82,6 +82,8 @@ const ( EFD_CLOEXEC = 0x400000 EFD_NONBLOCK = 0x4000 EMT_TAGOVF = 0x1 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x400000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 07642c308d..b622533ef2 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 923e08cb79..cfe6646baf 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 7d73dda647..13f624f69f 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 057700111e..fe222b75df 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 87d8612a1d..1bc1a5adb2 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -2229,3 +2229,19 @@ func Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mseal(b []byte, flags uint) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSEAL, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 9dc42410b7..1851df14e8 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s index 41b5617316..0b43c69365 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 0d3a0751cd..e1ec0dbe4e 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s index 4019a656f6..880c6d6e31 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index c39f7776db..7c8452a63e 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s index ac4af24f90..b8ef95b0fa 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 57571d072f..2ffdf861f7 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s index f77d532121..2af3b5c762 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index e62963e67e..1da08d5267 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s index fae140b62c..b7a251353b 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 00831354c8..6e85b0aac9 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s index 9d1e0ff06d..f15dadf055 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -555,6 +555,12 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mount(SB) + RET +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_nanosleep(SB) RET diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 79029ed584..28b487df25 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s index da115f9a4b..1e7f321e43 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/test/performance/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 53aef5dc58..524b0820cb 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -457,4 +457,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 71d524763d..d3e38f681a 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -379,4 +379,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index c747706131..70b35bf3b0 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -421,4 +421,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index f96e214f6d..6c778c2327 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -324,4 +324,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go index 28425346cf..37281cf51a 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -318,4 +318,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index d0953018da..7e567f1eff 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 295c7f4b81..38ae55e5ef 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index d1a9eaca7a..55e92e60a8 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index bec157c39f..60658d6a02 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index 7ee7bdc435..e203e8a7ed 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -448,4 +448,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index fad1f25b44..5944b97d54 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 7d3e16357d..c66d416dad 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index 0ed53ad9f7..9889f6a559 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -325,4 +325,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 2fba04ad50..01d86825bb 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -386,4 +386,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 621d00d741..7b703e77cd 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/test/performance/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -399,4 +399,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/test/performance/vendor/golang.org/x/sys/unix/ztypes_linux.go b/test/performance/vendor/golang.org/x/sys/unix/ztypes_linux.go index 4740b83485..7f1961b907 100644 --- a/test/performance/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/test/performance/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -110,7 +110,8 @@ type Statx_t struct { Mnt_id uint64 Dio_mem_align uint32 Dio_offset_align uint32 - _ [12]uint64 + Subvol uint64 + _ [11]uint64 } type Fsid struct { @@ -3473,7 +3474,7 @@ const ( DEVLINK_PORT_FN_ATTR_STATE = 0x2 DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3 DEVLINK_PORT_FN_ATTR_CAPS = 0x4 - DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x5 + DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x6 ) type FsverityDigest struct { @@ -3806,6 +3807,9 @@ const ( ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 ETHTOOL_MSG_KERNEL_MAX = 0x2b + ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 + ETHTOOL_FLAG_OMIT_REPLY = 0x2 + ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 @@ -3975,7 +3979,7 @@ const ( ETHTOOL_A_TSINFO_TX_TYPES = 0x3 ETHTOOL_A_TSINFO_RX_FILTERS = 0x4 ETHTOOL_A_TSINFO_PHC_INDEX = 0x5 - ETHTOOL_A_TSINFO_MAX = 0x5 + ETHTOOL_A_TSINFO_MAX = 0x6 ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0 ETHTOOL_A_CABLE_TEST_HEADER = 0x1 ETHTOOL_A_CABLE_TEST_MAX = 0x1 diff --git a/test/performance/vendor/golang.org/x/sys/windows/security_windows.go b/test/performance/vendor/golang.org/x/sys/windows/security_windows.go index 97651b5bd0..b6e1ab76f8 100644 --- a/test/performance/vendor/golang.org/x/sys/windows/security_windows.go +++ b/test/performance/vendor/golang.org/x/sys/windows/security_windows.go @@ -1179,7 +1179,7 @@ type OBJECTS_AND_NAME struct { //sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD //sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW -//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) = advapi32.GetAce +//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) = advapi32.GetAce // Control returns the security descriptor control bits. func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { diff --git a/test/performance/vendor/golang.org/x/sys/windows/syscall_windows.go b/test/performance/vendor/golang.org/x/sys/windows/syscall_windows.go index 6525c62f3c..1fa34fd17c 100644 --- a/test/performance/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/test/performance/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -17,8 +17,10 @@ import ( "unsafe" ) -type Handle uintptr -type HWND uintptr +type ( + Handle uintptr + HWND uintptr +) const ( InvalidHandle = ^Handle(0) @@ -211,6 +213,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW //sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId +//sys LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) [failretval==0] = user32.LoadKeyboardLayoutW +//sys UnloadKeyboardLayout(hkl Handle) (err error) = user32.UnloadKeyboardLayout +//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout +//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx //sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow //sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW //sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx @@ -1368,9 +1374,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) { func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4) } + func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq))) } + func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { return syscall.EWINDOWS } diff --git a/test/performance/vendor/golang.org/x/sys/windows/types_windows.go b/test/performance/vendor/golang.org/x/sys/windows/types_windows.go index d8cb71db0a..3f03b3d57c 100644 --- a/test/performance/vendor/golang.org/x/sys/windows/types_windows.go +++ b/test/performance/vendor/golang.org/x/sys/windows/types_windows.go @@ -2003,7 +2003,21 @@ const ( MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20 ) -const GAA_FLAG_INCLUDE_PREFIX = 0x00000010 +// Flags for GetAdaptersAddresses, see +// https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses. +const ( + GAA_FLAG_SKIP_UNICAST = 0x1 + GAA_FLAG_SKIP_ANYCAST = 0x2 + GAA_FLAG_SKIP_MULTICAST = 0x4 + GAA_FLAG_SKIP_DNS_SERVER = 0x8 + GAA_FLAG_INCLUDE_PREFIX = 0x10 + GAA_FLAG_SKIP_FRIENDLY_NAME = 0x20 + GAA_FLAG_INCLUDE_WINS_INFO = 0x40 + GAA_FLAG_INCLUDE_GATEWAYS = 0x80 + GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x100 + GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x200 + GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400 +) const ( IF_TYPE_OTHER = 1 @@ -2017,6 +2031,50 @@ const ( IF_TYPE_IEEE1394 = 144 ) +// Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin +const ( + IpPrefixOriginOther = 0 + IpPrefixOriginManual = 1 + IpPrefixOriginWellKnown = 2 + IpPrefixOriginDhcp = 3 + IpPrefixOriginRouterAdvertisement = 4 + IpPrefixOriginUnchanged = 1 << 4 +) + +// Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin +const ( + NlsoOther = 0 + NlsoManual = 1 + NlsoWellKnown = 2 + NlsoDhcp = 3 + NlsoLinkLayerAddress = 4 + NlsoRandom = 5 + IpSuffixOriginOther = 0 + IpSuffixOriginManual = 1 + IpSuffixOriginWellKnown = 2 + IpSuffixOriginDhcp = 3 + IpSuffixOriginLinkLayerAddress = 4 + IpSuffixOriginRandom = 5 + IpSuffixOriginUnchanged = 1 << 4 +) + +// Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state +const ( + NldsInvalid = 0 + NldsTentative = 1 + NldsDuplicate = 2 + NldsDeprecated = 3 + NldsPreferred = 4 + IpDadStateInvalid = 0 + IpDadStateTentative = 1 + IpDadStateDuplicate = 2 + IpDadStateDeprecated = 3 + IpDadStatePreferred = 4 +) + type SocketAddress struct { Sockaddr *syscall.RawSockaddrAny SockaddrLength int32 @@ -3404,3 +3462,14 @@ type DCB struct { EvtChar byte wReserved1 uint16 } + +// Keyboard Layout Flags. +// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw +const ( + KLF_ACTIVATE = 0x00000001 + KLF_SUBSTITUTE_OK = 0x00000002 + KLF_REORDER = 0x00000008 + KLF_REPLACELANG = 0x00000010 + KLF_NOTELLSHELL = 0x00000080 + KLF_SETFORPROCESS = 0x00000100 +) diff --git a/test/performance/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/test/performance/vendor/golang.org/x/sys/windows/zsyscall_windows.go index eba761018a..9bb979a3e4 100644 --- a/test/performance/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/test/performance/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -478,12 +478,16 @@ var ( procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow") procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow") procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo") + procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout") procGetShellWindow = moduser32.NewProc("GetShellWindow") procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") procIsWindow = moduser32.NewProc("IsWindow") procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode") procIsWindowVisible = moduser32.NewProc("IsWindowVisible") + procLoadKeyboardLayoutW = moduser32.NewProc("LoadKeyboardLayoutW") procMessageBoxW = moduser32.NewProc("MessageBoxW") + procToUnicodeEx = moduser32.NewProc("ToUnicodeEx") + procUnloadKeyboardLayout = moduser32.NewProc("UnloadKeyboardLayout") procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") @@ -789,6 +793,14 @@ func FreeSid(sid *SID) (err error) { return } +func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) { + r1, _, e1 := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func GetLengthSid(sid *SID) (len uint32) { r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) len = uint32(r0) @@ -1225,14 +1237,6 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE return } -func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) { - r0, _, _ := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) - if r0 == 0 { - ret = GetLastError() - } - return -} - func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) { r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor))) if r1 == 0 { @@ -4082,6 +4086,12 @@ func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) { return } +func GetKeyboardLayout(tid uint32) (hkl Handle) { + r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(tid), 0, 0) + hkl = Handle(r0) + return +} + func GetShellWindow() (shellWindow HWND) { r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0) shellWindow = HWND(r0) @@ -4115,6 +4125,15 @@ func IsWindowVisible(hwnd HWND) (isVisible bool) { return } +func LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) { + r0, _, e1 := syscall.Syscall(procLoadKeyboardLayoutW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(flags), 0) + hkl = Handle(r0) + if hkl == 0 { + err = errnoErr(e1) + } + return +} + func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) ret = int32(r0) @@ -4124,6 +4143,20 @@ func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret i return } +func ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) { + r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(vkey), uintptr(scancode), uintptr(unsafe.Pointer(keystate)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(flags), uintptr(hkl), 0, 0) + ret = int32(r0) + return +} + +func UnloadKeyboardLayout(hkl Handle) (err error) { + r1, _, e1 := syscall.Syscall(procUnloadKeyboardLayout.Addr(), 1, uintptr(hkl), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) { var _p0 uint32 if inheritExisting { diff --git a/test/performance/vendor/modules.txt b/test/performance/vendor/modules.txt index 1106fc7f9d..c249f8da63 100644 --- a/test/performance/vendor/modules.txt +++ b/test/performance/vendor/modules.txt @@ -372,7 +372,7 @@ golang.org/x/net/trace ## explicit; go 1.18 golang.org/x/sync/errgroup golang.org/x/sync/singleflight -# golang.org/x/sys v0.22.0 +# golang.org/x/sys v0.24.0 ## explicit; go 1.18 golang.org/x/sys/cpu golang.org/x/sys/unix diff --git a/test/testdata/configs/nginx-agent.conf b/test/testdata/configs/nginx-agent.conf index 3f68fab64f..a58429c47a 100644 --- a/test/testdata/configs/nginx-agent.conf +++ b/test/testdata/configs/nginx-agent.conf @@ -14,4 +14,4 @@ dataplane: poll_interval: 30s metrics: bulk_size: 20 - poll_interval: 5s + poll_interval: 1s diff --git a/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go b/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go index f5fa9e3b0a..6c26373b02 100644 --- a/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go +++ b/vendor/github.com/nginx/agent/sdk/v2/backoff/backoff.go @@ -41,7 +41,7 @@ func WaitUntil( expoBackoffWithContext := backoff.WithContext(exponentialBackoff, ctx) - err := backoff.Retry(backoff.Operation(operation), expoBackoffWithContext) + err := backoff.Retry(operation, expoBackoffWithContext) if err != nil { return err } diff --git a/vendor/go.uber.org/goleak/.gitignore b/vendor/go.uber.org/goleak/.gitignore new file mode 100644 index 0000000000..0fff519a4a --- /dev/null +++ b/vendor/go.uber.org/goleak/.gitignore @@ -0,0 +1,5 @@ +vendor/ +/bin +/lint.log +/cover.out +/cover.html diff --git a/vendor/go.uber.org/goleak/.golangci.yml b/vendor/go.uber.org/goleak/.golangci.yml new file mode 100644 index 0000000000..f84e6da8bc --- /dev/null +++ b/vendor/go.uber.org/goleak/.golangci.yml @@ -0,0 +1,28 @@ +output: + # Make output more digestible with quickfix in vim/emacs/etc. + sort-results: true + print-issued-lines: false + +linters: + enable: + - gofumpt + - nolintlint + - revive + +linters-settings: + govet: + # These govet checks are disabled by default, but they're useful. + enable: + - niliness + - reflectvaluecompare + - sortslice + - unusedwrite + +issues: + # Print all issues reported by all linters. + max-issues-per-linter: 0 + max-same-issues: 0 + + # Don't ignore some of the issues that golangci-lint considers okay. + # This includes documenting all exported entities. + exclude-use-default: false diff --git a/vendor/go.uber.org/goleak/CHANGELOG.md b/vendor/go.uber.org/goleak/CHANGELOG.md new file mode 100644 index 0000000000..5cd3f88a58 --- /dev/null +++ b/vendor/go.uber.org/goleak/CHANGELOG.md @@ -0,0 +1,74 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [1.3.0] +### Fixed +- Built-in ignores now match function names more accurately. + They will no longer ignore stacks because of file names + that look similar to function names. (#112) +### Added +- Add an `IgnoreAnyFunction` option to ignore stack traces + that have the provided function anywhere in the stack. (#113) +- Ignore `testing.runFuzzing` and `testing.runFuzzTests` alongside + other already-ignored test functions (`testing.RunTests`, etc). (#105) +### Changed +- Miscellaneous CI-related fixes. (#103, #108, #114) + +[1.3.0]: https://github.com/uber-go/goleak/compare/v1.2.1...v1.3.0 + +## [1.2.1] +### Changed +- Drop golang/x/lint dependency. + +[1.2.1]: https://github.com/uber-go/goleak/compare/v1.2.0...v1.2.1 + +## [1.2.0] +### Added +- Add Cleanup option that can be used for registering cleanup callbacks. (#78) + +### Changed +- Mark VerifyNone as a test helper. (#75) + +Thanks to @tallclair for their contribution to this release. + +[1.2.0]: https://github.com/uber-go/goleak/compare/v1.1.12...v1.2.0 + +## [1.1.12] +### Fixed +- Fixed logic for ignoring trace related goroutines on Go versions 1.16 and above. + +[1.1.12]: https://github.com/uber-go/goleak/compare/v1.1.11...v1.1.12 + +## [1.1.11] +### Fixed +- Documentation fix on how to test. +- Update dependency on stretchr/testify to v1.7.0. (#59) +- Update dependency on golang.org/x/tools to address CVE-2020-14040. (#62) + +[1.1.11]: https://github.com/uber-go/goleak/compare/v1.1.10...v1.1.11 + +## [1.1.10] +### Added +- [#49]: Add option to ignore current goroutines, which checks for any additional leaks and allows for incremental adoption of goleak in larger projects. + +Thanks to @denis-tingajkin for their contributions to this release. + +[#49]: https://github.com/uber-go/goleak/pull/49 +[1.1.10]: https://github.com/uber-go/goleak/compare/v1.0.0...v1.1.10 + +## [1.0.0] +### Changed +- Migrate to Go modules. + +### Fixed +- Ignore trace related goroutines that cause false positives with -trace. + +[1.0.0]: https://github.com/uber-go/goleak/compare/v0.10.0...v1.0.0 + +## [0.10.0] +- Initial release. + +[0.10.0]: https://github.com/uber-go/goleak/compare/v0.10.0...HEAD diff --git a/vendor/go.uber.org/goleak/LICENSE b/vendor/go.uber.org/goleak/LICENSE new file mode 100644 index 0000000000..6c9bde216e --- /dev/null +++ b/vendor/go.uber.org/goleak/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/go.uber.org/goleak/Makefile b/vendor/go.uber.org/goleak/Makefile new file mode 100644 index 0000000000..eb7154af3a --- /dev/null +++ b/vendor/go.uber.org/goleak/Makefile @@ -0,0 +1,45 @@ +# Directory containing the Makefile. +PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + +export GOBIN = $(PROJECT_ROOT)/bin +export PATH := $(GOBIN):$(PATH) + +GO_FILES = $(shell find . \ + -path '*/.*' -prune -o \ + '(' -type f -a -name '*.go' ')' -print) + +# Additional test flags. +TEST_FLAGS ?= + +.PHONY: all +all: lint build test + +.PHONY: lint +lint: golangci-lint tidy-lint + +.PHONY: build +build: + go build ./... + +.PHONY: test +test: + go test -v -race ./... + go test -v -trace=/dev/null . + +.PHONY: cover +cover: + go test -race -coverprofile=cover.out -coverpkg=./... ./... + go tool cover -html=cover.out -o cover.html + +.PHONY: golangci-lint +golangci-lint: + golangci-lint run + +.PHONY: tidy +tidy: + go mod tidy + +.PHONY: tidy-lint +tidy-lint: + go mod tidy + git diff --exit-code -- go.mod go.sum diff --git a/vendor/go.uber.org/goleak/README.md b/vendor/go.uber.org/goleak/README.md new file mode 100644 index 0000000000..de3d7d51df --- /dev/null +++ b/vendor/go.uber.org/goleak/README.md @@ -0,0 +1,74 @@ +# goleak [![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] + +Goroutine leak detector to help avoid Goroutine leaks. + +## Installation + +You can use `go get` to get the latest version: + +`go get -u go.uber.org/goleak` + +`goleak` also supports semver releases. + +Note that go-leak only [supports][release] the two most recent minor versions of Go. + +## Quick Start + +To verify that there are no unexpected goroutines running at the end of a test: + +```go +func TestA(t *testing.T) { + defer goleak.VerifyNone(t) + + // test logic here. +} +``` + +Instead of checking for leaks at the end of every test, `goleak` can also be run +at the end of every test package by creating a `TestMain` function for your +package: + +```go +func TestMain(m *testing.M) { + goleak.VerifyTestMain(m) +} +``` + +## Determine Source of Package Leaks + +When verifying leaks using `TestMain`, the leak test is only run once after all tests +have been run. This is typically enough to ensure there's no goroutines leaked from +tests, but when there are leaks, it's hard to determine which test is causing them. + +You can use the following bash script to determine the source of the failing test: + +```sh +# Create a test binary which will be used to run each test individually +$ go test -c -o tests + +# Run each test individually, printing "." for successful tests, or the test name +# for failing tests. +$ for test in $(go test -list . | grep -E "^(Test|Example)"); do ./tests -test.run "^$test\$" &>/dev/null && echo -n "." || echo -e "\n$test failed"; done +``` + +This will only print names of failing tests which can be investigated individually. E.g., + +``` +..... +TestLeakyTest failed +....... +``` + +## Stability + +goleak is v1 and follows [SemVer](http://semver.org/) strictly. + +No breaking changes will be made to exported APIs before 2.0. + +[doc-img]: https://godoc.org/go.uber.org/goleak?status.svg +[doc]: https://godoc.org/go.uber.org/goleak +[ci-img]: https://github.com/uber-go/goleak/actions/workflows/ci.yml/badge.svg +[ci]: https://github.com/uber-go/goleak/actions/workflows/ci.yml +[cov-img]: https://codecov.io/gh/uber-go/goleak/branch/master/graph/badge.svg +[cov]: https://codecov.io/gh/uber-go/goleak +[release]: https://go.dev/doc/devel/release#policy diff --git a/vendor/go.uber.org/goleak/doc.go b/vendor/go.uber.org/goleak/doc.go new file mode 100644 index 0000000000..3832f8dbc5 --- /dev/null +++ b/vendor/go.uber.org/goleak/doc.go @@ -0,0 +1,22 @@ +// Copyright (c) 2018 Uber Technologies, Inc. + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// Package goleak is a Goroutine leak detector. +package goleak // import "go.uber.org/goleak" diff --git a/vendor/go.uber.org/goleak/internal/stack/doc.go b/vendor/go.uber.org/goleak/internal/stack/doc.go new file mode 100644 index 0000000000..9179a56549 --- /dev/null +++ b/vendor/go.uber.org/goleak/internal/stack/doc.go @@ -0,0 +1,22 @@ +// Copyright (c) 2017-2023 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// Package stack is used for parsing stacks from `runtime.Stack`. +package stack diff --git a/vendor/go.uber.org/goleak/internal/stack/scan.go b/vendor/go.uber.org/goleak/internal/stack/scan.go new file mode 100644 index 0000000000..4b7ac8423e --- /dev/null +++ b/vendor/go.uber.org/goleak/internal/stack/scan.go @@ -0,0 +1,56 @@ +// Copyright (c) 2023 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package stack + +import ( + "bufio" + "io" +) + +// scanner provides a bufio.Scanner the ability to Unscan, +// which allows the current token to be read again +// after the next Scan. +type scanner struct { + *bufio.Scanner + + unscanned bool +} + +func newScanner(r io.Reader) *scanner { + return &scanner{Scanner: bufio.NewScanner(r)} +} + +func (s *scanner) Scan() bool { + if s.unscanned { + s.unscanned = false + return true + } + return s.Scanner.Scan() +} + +// Unscan stops the scanner from advancing its position +// for the next Scan. +// +// Bytes and Text will return the same token after next Scan +// that they do right now. +func (s *scanner) Unscan() { + s.unscanned = true +} diff --git a/vendor/go.uber.org/goleak/internal/stack/stacks.go b/vendor/go.uber.org/goleak/internal/stack/stacks.go new file mode 100644 index 0000000000..241a9b8448 --- /dev/null +++ b/vendor/go.uber.org/goleak/internal/stack/stacks.go @@ -0,0 +1,298 @@ +// Copyright (c) 2017-2023 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package stack + +import ( + "bytes" + "errors" + "fmt" + "io" + "runtime" + "strconv" + "strings" +) + +const _defaultBufferSize = 64 * 1024 // 64 KiB + +// Stack represents a single Goroutine's stack. +type Stack struct { + id int + state string // e.g. 'running', 'chan receive' + + // The first function on the stack. + firstFunction string + + // A set of all functions in the stack, + allFunctions map[string]struct{} + + // Full, raw stack trace. + fullStack string +} + +// ID returns the goroutine ID. +func (s Stack) ID() int { + return s.id +} + +// State returns the Goroutine's state. +func (s Stack) State() string { + return s.state +} + +// Full returns the full stack trace for this goroutine. +func (s Stack) Full() string { + return s.fullStack +} + +// FirstFunction returns the name of the first function on the stack. +func (s Stack) FirstFunction() string { + return s.firstFunction +} + +// HasFunction reports whether the stack has the given function +// anywhere in it. +func (s Stack) HasFunction(name string) bool { + _, ok := s.allFunctions[name] + return ok +} + +func (s Stack) String() string { + return fmt.Sprintf( + "Goroutine %v in state %v, with %v on top of the stack:\n%s", + s.id, s.state, s.firstFunction, s.Full()) +} + +func getStacks(all bool) []Stack { + trace := getStackBuffer(all) + stacks, err := newStackParser(bytes.NewReader(trace)).Parse() + if err != nil { + // Well-formed stack traces should never fail to parse. + // If they do, it's a bug in this package. + // Panic so we can fix it. + panic(fmt.Sprintf("Failed to parse stack trace: %v\n%s", err, trace)) + } + return stacks +} + +type stackParser struct { + scan *scanner + stacks []Stack + errors []error +} + +func newStackParser(r io.Reader) *stackParser { + return &stackParser{ + scan: newScanner(r), + } +} + +func (p *stackParser) Parse() ([]Stack, error) { + for p.scan.Scan() { + line := p.scan.Text() + + // If we see the goroutine header, start a new stack. + if strings.HasPrefix(line, "goroutine ") { + stack, err := p.parseStack(line) + if err != nil { + p.errors = append(p.errors, err) + continue + } + p.stacks = append(p.stacks, stack) + } + } + + p.errors = append(p.errors, p.scan.Err()) + return p.stacks, errors.Join(p.errors...) +} + +// parseStack parses a single stack trace from the given scanner. +// line is the first line of the stack trace, which should look like: +// +// goroutine 123 [runnable]: +func (p *stackParser) parseStack(line string) (Stack, error) { + id, state, err := parseGoStackHeader(line) + if err != nil { + return Stack{}, fmt.Errorf("parse header: %w", err) + } + + // Read the rest of the stack trace. + var ( + firstFunction string + fullStack bytes.Buffer + ) + funcs := make(map[string]struct{}) + for p.scan.Scan() { + line := p.scan.Text() + if strings.HasPrefix(line, "goroutine ") { + // If we see the goroutine header, + // it's the end of this stack. + // Unscan so the next Scan sees the same line. + p.scan.Unscan() + break + } + + fullStack.WriteString(line) + fullStack.WriteByte('\n') // scanner trims the newline + + if len(line) == 0 { + // Empty line usually marks the end of the stack + // but we don't want to have to rely on that. + // Just skip it. + continue + } + + funcName, creator, err := parseFuncName(line) + if err != nil { + return Stack{}, fmt.Errorf("parse function: %w", err) + } + if !creator { + // A function is part of a goroutine's stack + // only if it's not a "created by" function. + // + // The creator function is part of a different stack. + // We don't care about it right now. + funcs[funcName] = struct{}{} + if firstFunction == "" { + firstFunction = funcName + } + + } + + // The function name followed by a line in the form: + // + // example.com/path/to/package/file.go:123 +0x123 + // + // We don't care about the position so we can skip this line. + if p.scan.Scan() { + // Be defensive: + // Skip the line only if it starts with a tab. + bs := p.scan.Bytes() + if len(bs) > 0 && bs[0] == '\t' { + fullStack.Write(bs) + fullStack.WriteByte('\n') + } else { + // Put it back and let the next iteration handle it + // if it doesn't start with a tab. + p.scan.Unscan() + } + } + + if creator { + // The "created by" line is the last line of the stack. + // We can stop parsing now. + // + // Note that if tracebackancestors=N is set, + // there may be more a traceback of the creator function + // following the "created by" line, + // but it should not be considered part of this stack. + // e.g., + // + // created by testing.(*T).Run in goroutine 1 + // /usr/lib/go/src/testing/testing.go:1648 +0x3ad + // [originating from goroutine 1]: + // testing.(*T).Run(...) + // /usr/lib/go/src/testing/testing.go:1649 +0x3ad + // + break + } + } + + return Stack{ + id: id, + state: state, + firstFunction: firstFunction, + allFunctions: funcs, + fullStack: fullStack.String(), + }, nil +} + +// All returns the stacks for all running goroutines. +func All() []Stack { + return getStacks(true) +} + +// Current returns the stack for the current goroutine. +func Current() Stack { + return getStacks(false)[0] +} + +func getStackBuffer(all bool) []byte { + for i := _defaultBufferSize; ; i *= 2 { + buf := make([]byte, i) + if n := runtime.Stack(buf, all); n < i { + return buf[:n] + } + } +} + +// Parses a single function from the given line. +// The line is in one of these formats: +// +// example.com/path/to/package.funcName(args...) +// example.com/path/to/package.(*typeName).funcName(args...) +// created by example.com/path/to/package.funcName +// created by example.com/path/to/package.funcName in goroutine [...] +// +// Also reports whether the line was a "created by" line. +func parseFuncName(line string) (name string, creator bool, err error) { + if after, ok := strings.CutPrefix(line, "created by "); ok { + // The function name is the part after "created by " + // and before " in goroutine [...]". + idx := strings.Index(after, " in goroutine") + if idx >= 0 { + after = after[:idx] + } + name = after + creator = true + } else if idx := strings.LastIndexByte(line, '('); idx >= 0 { + // The function name is the part before the last '('. + name = line[:idx] + } + + if name == "" { + return "", false, fmt.Errorf("no function found: %q", line) + } + + return name, creator, nil +} + +// parseGoStackHeader parses a stack header that looks like: +// goroutine 643 [runnable]:\n +// And returns the goroutine ID, and the state. +func parseGoStackHeader(line string) (goroutineID int, state string, err error) { + // The scanner will have already trimmed the "\n", + // but we'll guard against it just in case. + // + // Trimming them separately makes them both optional. + line = strings.TrimSuffix(strings.TrimSuffix(line, ":"), "\n") + parts := strings.SplitN(line, " ", 3) + if len(parts) != 3 { + return 0, "", fmt.Errorf("unexpected format: %q", line) + } + + id, err := strconv.Atoi(parts[1]) + if err != nil { + return 0, "", fmt.Errorf("bad goroutine ID %q in line %q", parts[1], line) + } + + state = strings.TrimSuffix(strings.TrimPrefix(parts[2], "["), "]") + return id, state, nil +} diff --git a/vendor/go.uber.org/goleak/leaks.go b/vendor/go.uber.org/goleak/leaks.go new file mode 100644 index 0000000000..cc206f1815 --- /dev/null +++ b/vendor/go.uber.org/goleak/leaks.go @@ -0,0 +1,108 @@ +// Copyright (c) 2017 Uber Technologies, Inc. + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package goleak + +import ( + "errors" + "fmt" + + "go.uber.org/goleak/internal/stack" +) + +// TestingT is the minimal subset of testing.TB that we use. +type TestingT interface { + Error(...interface{}) +} + +// filterStacks will filter any stacks excluded by the given opts. +// filterStacks modifies the passed in stacks slice. +func filterStacks(stacks []stack.Stack, skipID int, opts *opts) []stack.Stack { + filtered := stacks[:0] + for _, stack := range stacks { + // Always skip the running goroutine. + if stack.ID() == skipID { + continue + } + // Run any default or user-specified filters. + if opts.filter(stack) { + continue + } + filtered = append(filtered, stack) + } + return filtered +} + +// Find looks for extra goroutines, and returns a descriptive error if +// any are found. +func Find(options ...Option) error { + cur := stack.Current().ID() + + opts := buildOpts(options...) + if opts.cleanup != nil { + return errors.New("Cleanup can only be passed to VerifyNone or VerifyTestMain") + } + var stacks []stack.Stack + retry := true + for i := 0; retry; i++ { + stacks = filterStacks(stack.All(), cur, opts) + + if len(stacks) == 0 { + return nil + } + retry = opts.retry(i) + } + + return fmt.Errorf("found unexpected goroutines:\n%s", stacks) +} + +type testHelper interface { + Helper() +} + +// VerifyNone marks the given TestingT as failed if any extra goroutines are +// found by Find. This is a helper method to make it easier to integrate in +// tests by doing: +// +// defer VerifyNone(t) +// +// VerifyNone is currently incompatible with t.Parallel because it cannot +// associate specific goroutines with specific tests. Thus, non-leaking +// goroutines from other tests running in parallel could fail this check. +// If you need to run tests in parallel, use [VerifyTestMain] instead, +// which will verify that no leaking goroutines exist after ALL tests finish. +func VerifyNone(t TestingT, options ...Option) { + opts := buildOpts(options...) + var cleanup func(int) + cleanup, opts.cleanup = opts.cleanup, nil + + if h, ok := t.(testHelper); ok { + // Mark this function as a test helper, if available. + h.Helper() + } + + if err := Find(opts); err != nil { + t.Error(err) + } + + if cleanup != nil { + cleanup(0) + } +} diff --git a/vendor/go.uber.org/goleak/options.go b/vendor/go.uber.org/goleak/options.go new file mode 100644 index 0000000000..53fc0a1dec --- /dev/null +++ b/vendor/go.uber.org/goleak/options.go @@ -0,0 +1,198 @@ +// Copyright (c) 2017-2023 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package goleak + +import ( + "strings" + "time" + + "go.uber.org/goleak/internal/stack" +) + +// Option lets users specify custom verifications. +type Option interface { + apply(*opts) +} + +// We retry up to 20 times if we can't find the goroutine that +// we are looking for. In between each attempt, we will sleep for +// a short while to let any running goroutines complete. +const _defaultRetries = 20 + +type opts struct { + filters []func(stack.Stack) bool + maxRetries int + maxSleep time.Duration + cleanup func(int) +} + +// implement apply so that opts struct itself can be used as +// an Option. +func (o *opts) apply(opts *opts) { + opts.filters = o.filters + opts.maxRetries = o.maxRetries + opts.maxSleep = o.maxSleep + opts.cleanup = o.cleanup +} + +// optionFunc lets us easily write options without a custom type. +type optionFunc func(*opts) + +func (f optionFunc) apply(opts *opts) { f(opts) } + +// IgnoreTopFunction ignores any goroutines where the specified function +// is at the top of the stack. The function name should be fully qualified, +// e.g., go.uber.org/goleak.IgnoreTopFunction +func IgnoreTopFunction(f string) Option { + return addFilter(func(s stack.Stack) bool { + return s.FirstFunction() == f + }) +} + +// IgnoreAnyFunction ignores goroutines where the specified function +// is present anywhere in the stack. +// +// The function name must be fully qualified, e.g., +// +// go.uber.org/goleak.IgnoreAnyFunction +// +// For methods, the fully qualified form looks like: +// +// go.uber.org/goleak.(*MyType).MyMethod +func IgnoreAnyFunction(f string) Option { + return addFilter(func(s stack.Stack) bool { + return s.HasFunction(f) + }) +} + +// Cleanup sets up a cleanup function that will be executed at the +// end of the leak check. +// When passed to [VerifyTestMain], the exit code passed to cleanupFunc +// will be set to the exit code of TestMain. +// When passed to [VerifyNone], the exit code will be set to 0. +// This cannot be passed to [Find]. +func Cleanup(cleanupFunc func(exitCode int)) Option { + return optionFunc(func(opts *opts) { + opts.cleanup = cleanupFunc + }) +} + +// IgnoreCurrent records all current goroutines when the option is created, and ignores +// them in any future Find/Verify calls. +func IgnoreCurrent() Option { + excludeIDSet := map[int]bool{} + for _, s := range stack.All() { + excludeIDSet[s.ID()] = true + } + return addFilter(func(s stack.Stack) bool { + return excludeIDSet[s.ID()] + }) +} + +func maxSleep(d time.Duration) Option { + return optionFunc(func(opts *opts) { + opts.maxSleep = d + }) +} + +func addFilter(f func(stack.Stack) bool) Option { + return optionFunc(func(opts *opts) { + opts.filters = append(opts.filters, f) + }) +} + +func buildOpts(options ...Option) *opts { + opts := &opts{ + maxRetries: _defaultRetries, + maxSleep: 100 * time.Millisecond, + } + opts.filters = append(opts.filters, + isTestStack, + isSyscallStack, + isStdLibStack, + isTraceStack, + ) + for _, option := range options { + option.apply(opts) + } + return opts +} + +func (o *opts) filter(s stack.Stack) bool { + for _, filter := range o.filters { + if filter(s) { + return true + } + } + return false +} + +func (o *opts) retry(i int) bool { + if i >= o.maxRetries { + return false + } + + d := time.Duration(int(time.Microsecond) << uint(i)) + if d > o.maxSleep { + d = o.maxSleep + } + time.Sleep(d) + return true +} + +// isTestStack is a default filter installed to automatically skip goroutines +// that the testing package runs while the user's tests are running. +func isTestStack(s stack.Stack) bool { + // Until go1.7, the main goroutine ran RunTests, which started + // the test in a separate goroutine and waited for that test goroutine + // to end by waiting on a channel. + // Since go1.7, a separate goroutine is started to wait for signals. + // T.Parallel is for parallel tests, which are blocked until all serial + // tests have run with T.Parallel at the top of the stack. + // testing.runFuzzTests is for fuzz testing, it's blocked until the test + // function with all seed corpus have run. + // testing.runFuzzing is for fuzz testing, it's blocked until a failing + // input is found. + switch s.FirstFunction() { + case "testing.RunTests", "testing.(*T).Run", "testing.(*T).Parallel", "testing.runFuzzing", "testing.runFuzzTests": + // In pre1.7 and post-1.7, background goroutines started by the testing + // package are blocked waiting on a channel. + return strings.HasPrefix(s.State(), "chan receive") + } + return false +} + +func isSyscallStack(s stack.Stack) bool { + // Typically runs in the background when code uses CGo: + // https://github.com/golang/go/issues/16714 + return s.HasFunction("runtime.goexit") && strings.HasPrefix(s.State(), "syscall") +} + +func isStdLibStack(s stack.Stack) bool { + // Importing os/signal starts a background goroutine. + // The name of the function at the top has changed between versions. + if f := s.FirstFunction(); f == "os/signal.signal_recv" || f == "os/signal.loop" { + return true + } + + // Using signal.Notify will start a runtime goroutine. + return s.HasFunction("runtime.ensureSigM") +} diff --git a/vendor/go.uber.org/goleak/testmain.go b/vendor/go.uber.org/goleak/testmain.go new file mode 100644 index 0000000000..7b1a50b7af --- /dev/null +++ b/vendor/go.uber.org/goleak/testmain.go @@ -0,0 +1,69 @@ +// Copyright (c) 2017 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package goleak + +import ( + "fmt" + "io" + "os" +) + +// Variables for stubbing in unit tests. +var ( + _osExit = os.Exit + _osStderr io.Writer = os.Stderr +) + +// TestingM is the minimal subset of testing.M that we use. +type TestingM interface { + Run() int +} + +// VerifyTestMain can be used in a TestMain function for package tests to +// verify that there were no goroutine leaks. +// To use it, your TestMain function should look like: +// +// func TestMain(m *testing.M) { +// goleak.VerifyTestMain(m) +// } +// +// See https://golang.org/pkg/testing/#hdr-Main for more details. +// +// This will run all tests as per normal, and if they were successful, look +// for any goroutine leaks and fail the tests if any leaks were found. +func VerifyTestMain(m TestingM, options ...Option) { + exitCode := m.Run() + opts := buildOpts(options...) + + var cleanup func(int) + cleanup, opts.cleanup = opts.cleanup, nil + if cleanup == nil { + cleanup = _osExit + } + defer func() { cleanup(exitCode) }() + + if exitCode == 0 { + if err := Find(opts); err != nil { + fmt.Fprintf(_osStderr, "goleak: Errors on successful test run: %v\n", err) + exitCode = 1 + } + } +} diff --git a/vendor/go.uber.org/goleak/tracestack_new.go b/vendor/go.uber.org/goleak/tracestack_new.go new file mode 100644 index 0000000000..4fc6cefcea --- /dev/null +++ b/vendor/go.uber.org/goleak/tracestack_new.go @@ -0,0 +1,30 @@ +// Copyright (c) 2021-2023 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +//go:build go1.16 +// +build go1.16 + +package goleak + +import "go.uber.org/goleak/internal/stack" + +func isTraceStack(s stack.Stack) bool { + return s.HasFunction("runtime.ReadTrace") +} diff --git a/vendor/golang.org/x/sys/LICENSE b/vendor/golang.org/x/sys/LICENSE index 6a66aea5ea..2a7cf70da6 100644 --- a/vendor/golang.org/x/sys/LICENSE +++ b/vendor/golang.org/x/sys/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index 4ed2e488b6..d07dd09eb5 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -58,6 +58,7 @@ includes_Darwin=' #define _DARWIN_USE_64_BIT_INODE #define __APPLE_USE_RFC_3542 #include +#include #include #include #include diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index 4cc7b00596..2d15200adb 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -402,6 +402,18 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq)) } +//sys renamexNp(from string, to string, flag uint32) (err error) + +func RenamexNp(from string, to string, flag uint32) (err error) { + return renamexNp(from, to, flag) +} + +//sys renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) + +func RenameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + return renameatxNp(fromfd, from, tofd, to, flag) +} + //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL func Uname(uname *Utsname) error { diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index 5682e2628a..3f1d3d4cb2 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -2592,3 +2592,4 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { } //sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) +//sys Mseal(b []byte, flags uint) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go index b25343c71a..b86ded549c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -293,6 +293,7 @@ func Uname(uname *Utsname) error { //sys Mkfifoat(dirfd int, path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index e40fa85245..4308ac1772 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index bb02aa6c05..c8068a7a16 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -1169,6 +1169,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 877a62b479..01a70b2463 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -457,6 +457,7 @@ const ( B600 = 0x8 B75 = 0x2 B9600 = 0xd + BCACHEFS_SUPER_MAGIC = 0xca451a4e BDEVFS_MAGIC = 0x62646576 BINDERFS_SUPER_MAGIC = 0x6c6f6f70 BINFMTFS_MAGIC = 0x42494e4d @@ -928,6 +929,7 @@ const ( EPOLL_CTL_ADD = 0x1 EPOLL_CTL_DEL = 0x2 EPOLL_CTL_MOD = 0x3 + EPOLL_IOC_TYPE = 0x8a EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2 ESP_V4_FLOW = 0xa ESP_V6_FLOW = 0xc @@ -941,9 +943,6 @@ const ( ETHTOOL_FEC_OFF = 0x4 ETHTOOL_FEC_RS = 0x8 ETHTOOL_FLAG_ALL = 0x7 - ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 - ETHTOOL_FLAG_OMIT_REPLY = 0x2 - ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_FLASHDEV = 0x33 ETHTOOL_FLASH_MAX_FILENAME = 0x80 ETHTOOL_FWVERS_LEN = 0x20 @@ -1705,6 +1704,7 @@ const ( KEXEC_ARCH_S390 = 0x160000 KEXEC_ARCH_SH = 0x2a0000 KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_CRASH_HOTPLUG_SUPPORT = 0x8 KEXEC_FILE_DEBUG = 0x8 KEXEC_FILE_NO_INITRAMFS = 0x4 KEXEC_FILE_ON_CRASH = 0x2 @@ -1780,6 +1780,7 @@ const ( KEY_SPEC_USER_KEYRING = -0x4 KEY_SPEC_USER_SESSION_KEYRING = -0x5 LANDLOCK_ACCESS_FS_EXECUTE = 0x1 + LANDLOCK_ACCESS_FS_IOCTL_DEV = 0x8000 LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800 LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40 LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80 @@ -1861,6 +1862,19 @@ const ( MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_FIXED_NOREPLACE = 0x100000 + MAP_HUGE_16GB = 0x88000000 + MAP_HUGE_16KB = 0x38000000 + MAP_HUGE_16MB = 0x60000000 + MAP_HUGE_1GB = 0x78000000 + MAP_HUGE_1MB = 0x50000000 + MAP_HUGE_256MB = 0x70000000 + MAP_HUGE_2GB = 0x7c000000 + MAP_HUGE_2MB = 0x54000000 + MAP_HUGE_32MB = 0x64000000 + MAP_HUGE_512KB = 0x4c000000 + MAP_HUGE_512MB = 0x74000000 + MAP_HUGE_64KB = 0x40000000 + MAP_HUGE_8MB = 0x5c000000 MAP_HUGE_MASK = 0x3f MAP_HUGE_SHIFT = 0x1a MAP_PRIVATE = 0x2 @@ -2498,6 +2512,23 @@ const ( PR_PAC_GET_ENABLED_KEYS = 0x3d PR_PAC_RESET_KEYS = 0x36 PR_PAC_SET_ENABLED_KEYS = 0x3c + PR_PPC_DEXCR_CTRL_CLEAR = 0x4 + PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10 + PR_PPC_DEXCR_CTRL_EDITABLE = 0x1 + PR_PPC_DEXCR_CTRL_MASK = 0x1f + PR_PPC_DEXCR_CTRL_SET = 0x2 + PR_PPC_DEXCR_CTRL_SET_ONEXEC = 0x8 + PR_PPC_DEXCR_IBRTPD = 0x1 + PR_PPC_DEXCR_NPHIE = 0x3 + PR_PPC_DEXCR_SBHE = 0x0 + PR_PPC_DEXCR_SRAPD = 0x2 + PR_PPC_GET_DEXCR = 0x48 + PR_PPC_SET_DEXCR = 0x49 + PR_RISCV_CTX_SW_FENCEI_OFF = 0x1 + PR_RISCV_CTX_SW_FENCEI_ON = 0x0 + PR_RISCV_SCOPE_PER_PROCESS = 0x0 + PR_RISCV_SCOPE_PER_THREAD = 0x1 + PR_RISCV_SET_ICACHE_FLUSH_CTX = 0x47 PR_RISCV_V_GET_CONTROL = 0x46 PR_RISCV_V_SET_CONTROL = 0x45 PR_RISCV_V_VSTATE_CTRL_CUR_MASK = 0x3 @@ -3192,6 +3223,7 @@ const ( STATX_MTIME = 0x40 STATX_NLINK = 0x4 STATX_SIZE = 0x200 + STATX_SUBVOL = 0x8000 STATX_TYPE = 0x1 STATX_UID = 0x8 STATX__RESERVED = 0x80000000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index e4bc0bd57c..684a5168da 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 689317afdb..61d74b592d 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 5cca668ac3..a28c9e3e89 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 14270508b0..ab5d1fe8ea 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 ESR_MAGIC = 0x45535201 EXTPROC = 0x10000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 28e39afdcb..c523090e7c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index cd66e92cb4..01e6ea7804 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index c1595eba78..7aa610b1e7 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ee9456b0da..92af771b44 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 8cfca81e1b..b27ef5e6f1 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 60b0deb3af..237a2cefb3 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index f90aa7281b..4a5c555a36 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index ba9e015033..a02fb49a5f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 07cdfd6e9f..e26a7c61b2 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 2f1dd214a7..c48f7c2103 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index f40519d901..ad4b9aace7 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -82,6 +82,8 @@ const ( EFD_CLOEXEC = 0x400000 EFD_NONBLOCK = 0x4000 EMT_TAGOVF = 0x1 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x400000 EXTPROC = 0x10000 FF1 = 0x8000 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 07642c308d..b622533ef2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 923e08cb79..cfe6646baf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 7d73dda647..13f624f69f 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 057700111e..fe222b75df 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 87d8612a1d..1bc1a5adb2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -2229,3 +2229,19 @@ func Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mseal(b []byte, flags uint) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSEAL, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 9dc42410b7..1851df14e8 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s index 41b5617316..0b43c69365 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 0d3a0751cd..e1ec0dbe4e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s index 4019a656f6..880c6d6e31 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index c39f7776db..7c8452a63e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s index ac4af24f90..b8ef95b0fa 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 57571d072f..2ffdf861f7 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s index f77d532121..2af3b5c762 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index e62963e67e..1da08d5267 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s index fae140b62c..b7a251353b 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 00831354c8..6e85b0aac9 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s index 9d1e0ff06d..f15dadf055 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -555,6 +555,12 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mount(SB) + RET +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_nanosleep(SB) RET diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 79029ed584..28b487df25 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s index da115f9a4b..1e7f321e43 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 53aef5dc58..524b0820cb 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -457,4 +457,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 71d524763d..d3e38f681a 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -379,4 +379,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index c747706131..70b35bf3b0 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -421,4 +421,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index f96e214f6d..6c778c2327 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -324,4 +324,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go index 28425346cf..37281cf51a 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -318,4 +318,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index d0953018da..7e567f1eff 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 295c7f4b81..38ae55e5ef 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index d1a9eaca7a..55e92e60a8 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index bec157c39f..60658d6a02 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index 7ee7bdc435..e203e8a7ed 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -448,4 +448,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index fad1f25b44..5944b97d54 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 7d3e16357d..c66d416dad 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index 0ed53ad9f7..9889f6a559 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -325,4 +325,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 2fba04ad50..01d86825bb 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -386,4 +386,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 621d00d741..7b703e77cd 100644 --- a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -399,4 +399,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 4740b83485..7f1961b907 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -110,7 +110,8 @@ type Statx_t struct { Mnt_id uint64 Dio_mem_align uint32 Dio_offset_align uint32 - _ [12]uint64 + Subvol uint64 + _ [11]uint64 } type Fsid struct { @@ -3473,7 +3474,7 @@ const ( DEVLINK_PORT_FN_ATTR_STATE = 0x2 DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3 DEVLINK_PORT_FN_ATTR_CAPS = 0x4 - DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x5 + DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x6 ) type FsverityDigest struct { @@ -3806,6 +3807,9 @@ const ( ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 ETHTOOL_MSG_KERNEL_MAX = 0x2b + ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 + ETHTOOL_FLAG_OMIT_REPLY = 0x2 + ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 @@ -3975,7 +3979,7 @@ const ( ETHTOOL_A_TSINFO_TX_TYPES = 0x3 ETHTOOL_A_TSINFO_RX_FILTERS = 0x4 ETHTOOL_A_TSINFO_PHC_INDEX = 0x5 - ETHTOOL_A_TSINFO_MAX = 0x5 + ETHTOOL_A_TSINFO_MAX = 0x6 ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0 ETHTOOL_A_CABLE_TEST_HEADER = 0x1 ETHTOOL_A_CABLE_TEST_MAX = 0x1 diff --git a/vendor/golang.org/x/sys/windows/security_windows.go b/vendor/golang.org/x/sys/windows/security_windows.go index 97651b5bd0..b6e1ab76f8 100644 --- a/vendor/golang.org/x/sys/windows/security_windows.go +++ b/vendor/golang.org/x/sys/windows/security_windows.go @@ -1179,7 +1179,7 @@ type OBJECTS_AND_NAME struct { //sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD //sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW -//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) = advapi32.GetAce +//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) = advapi32.GetAce // Control returns the security descriptor control bits. func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index 6525c62f3c..1fa34fd17c 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -17,8 +17,10 @@ import ( "unsafe" ) -type Handle uintptr -type HWND uintptr +type ( + Handle uintptr + HWND uintptr +) const ( InvalidHandle = ^Handle(0) @@ -211,6 +213,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW //sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId +//sys LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) [failretval==0] = user32.LoadKeyboardLayoutW +//sys UnloadKeyboardLayout(hkl Handle) (err error) = user32.UnloadKeyboardLayout +//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout +//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx //sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow //sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW //sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx @@ -1368,9 +1374,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) { func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4) } + func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq))) } + func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { return syscall.EWINDOWS } diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index d8cb71db0a..3f03b3d57c 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -2003,7 +2003,21 @@ const ( MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20 ) -const GAA_FLAG_INCLUDE_PREFIX = 0x00000010 +// Flags for GetAdaptersAddresses, see +// https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses. +const ( + GAA_FLAG_SKIP_UNICAST = 0x1 + GAA_FLAG_SKIP_ANYCAST = 0x2 + GAA_FLAG_SKIP_MULTICAST = 0x4 + GAA_FLAG_SKIP_DNS_SERVER = 0x8 + GAA_FLAG_INCLUDE_PREFIX = 0x10 + GAA_FLAG_SKIP_FRIENDLY_NAME = 0x20 + GAA_FLAG_INCLUDE_WINS_INFO = 0x40 + GAA_FLAG_INCLUDE_GATEWAYS = 0x80 + GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x100 + GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x200 + GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400 +) const ( IF_TYPE_OTHER = 1 @@ -2017,6 +2031,50 @@ const ( IF_TYPE_IEEE1394 = 144 ) +// Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin +const ( + IpPrefixOriginOther = 0 + IpPrefixOriginManual = 1 + IpPrefixOriginWellKnown = 2 + IpPrefixOriginDhcp = 3 + IpPrefixOriginRouterAdvertisement = 4 + IpPrefixOriginUnchanged = 1 << 4 +) + +// Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin +const ( + NlsoOther = 0 + NlsoManual = 1 + NlsoWellKnown = 2 + NlsoDhcp = 3 + NlsoLinkLayerAddress = 4 + NlsoRandom = 5 + IpSuffixOriginOther = 0 + IpSuffixOriginManual = 1 + IpSuffixOriginWellKnown = 2 + IpSuffixOriginDhcp = 3 + IpSuffixOriginLinkLayerAddress = 4 + IpSuffixOriginRandom = 5 + IpSuffixOriginUnchanged = 1 << 4 +) + +// Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state +const ( + NldsInvalid = 0 + NldsTentative = 1 + NldsDuplicate = 2 + NldsDeprecated = 3 + NldsPreferred = 4 + IpDadStateInvalid = 0 + IpDadStateTentative = 1 + IpDadStateDuplicate = 2 + IpDadStateDeprecated = 3 + IpDadStatePreferred = 4 +) + type SocketAddress struct { Sockaddr *syscall.RawSockaddrAny SockaddrLength int32 @@ -3404,3 +3462,14 @@ type DCB struct { EvtChar byte wReserved1 uint16 } + +// Keyboard Layout Flags. +// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw +const ( + KLF_ACTIVATE = 0x00000001 + KLF_SUBSTITUTE_OK = 0x00000002 + KLF_REORDER = 0x00000008 + KLF_REPLACELANG = 0x00000010 + KLF_NOTELLSHELL = 0x00000080 + KLF_SETFORPROCESS = 0x00000100 +) diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index eba761018a..9bb979a3e4 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -478,12 +478,16 @@ var ( procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow") procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow") procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo") + procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout") procGetShellWindow = moduser32.NewProc("GetShellWindow") procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") procIsWindow = moduser32.NewProc("IsWindow") procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode") procIsWindowVisible = moduser32.NewProc("IsWindowVisible") + procLoadKeyboardLayoutW = moduser32.NewProc("LoadKeyboardLayoutW") procMessageBoxW = moduser32.NewProc("MessageBoxW") + procToUnicodeEx = moduser32.NewProc("ToUnicodeEx") + procUnloadKeyboardLayout = moduser32.NewProc("UnloadKeyboardLayout") procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") @@ -789,6 +793,14 @@ func FreeSid(sid *SID) (err error) { return } +func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) { + r1, _, e1 := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func GetLengthSid(sid *SID) (len uint32) { r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) len = uint32(r0) @@ -1225,14 +1237,6 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE return } -func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) { - r0, _, _ := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) - if r0 == 0 { - ret = GetLastError() - } - return -} - func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) { r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor))) if r1 == 0 { @@ -4082,6 +4086,12 @@ func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) { return } +func GetKeyboardLayout(tid uint32) (hkl Handle) { + r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(tid), 0, 0) + hkl = Handle(r0) + return +} + func GetShellWindow() (shellWindow HWND) { r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0) shellWindow = HWND(r0) @@ -4115,6 +4125,15 @@ func IsWindowVisible(hwnd HWND) (isVisible bool) { return } +func LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) { + r0, _, e1 := syscall.Syscall(procLoadKeyboardLayoutW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(flags), 0) + hkl = Handle(r0) + if hkl == 0 { + err = errnoErr(e1) + } + return +} + func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) ret = int32(r0) @@ -4124,6 +4143,20 @@ func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret i return } +func ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) { + r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(vkey), uintptr(scancode), uintptr(unsafe.Pointer(keystate)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(flags), uintptr(hkl), 0, 0) + ret = int32(r0) + return +} + +func UnloadKeyboardLayout(hkl Handle) (err error) { + r1, _, e1 := syscall.Syscall(procUnloadKeyboardLayout.Addr(), 1, uintptr(hkl), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) { var _p0 uint32 if inheritExisting { diff --git a/vendor/modules.txt b/vendor/modules.txt index 73aa79e0b3..cef883482e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -254,6 +254,10 @@ github.com/yusufpapurcu/wmi # go.uber.org/atomic v1.11.0 ## explicit; go 1.18 go.uber.org/atomic +# go.uber.org/goleak v1.3.0 +## explicit; go 1.20 +go.uber.org/goleak +go.uber.org/goleak/internal/stack # go.uber.org/mock v0.4.0 ## explicit; go 1.20 go.uber.org/mock/gomock @@ -285,7 +289,7 @@ golang.org/x/net/trace ## explicit; go 1.18 golang.org/x/sync/errgroup golang.org/x/sync/singleflight -# golang.org/x/sys v0.22.0 +# golang.org/x/sys v0.24.0 ## explicit; go 1.18 golang.org/x/sys/unix golang.org/x/sys/windows