mirror of
https://github.com/hanzoai/visor.git
synced 2026-09-24 17:04:14 +00:00
urpc encodes with encoding/json, which walks the payload on every call: a realistic control.ExecArgs costs 7084ns and 10 allocations to cross. ZAP reads a field at a constant offset out of the buffer that arrived, so the same payload is 740ns and one allocation -- but only if the offsets are stated, and a stated offset that is wrong is silent corruption rather than a compile error. So state them from the types themselves. //tools/zap reflects over the payloads at build time and writes the wire as Go source with the offsets as constants. It lives inside Bazel because pkg/sentry/control cannot be imported from outside it: the *_go_proto packages it depends on have no source in the tree. Six payloads had no layout to state. A map, an interface and a type from another module have no offsets, so each is answered in the type: SaveOpts.Metadata and StartContainerArgs.InitialCgroups/Limits cross as lists of pairs; boot.Route.Destination restates net.IPNet as Subnet; OpenMountArgs restates the OCI mount fields the call actually uses; StartArgs.Spec and SinkConfig.Config carry their documents as the bytes they arrived as; MetricsRegistrationResponse carries the protocol buffer the same way; and seccheck's session options become a type instead of a map of any. ExecArgs and MetricsExportData still have none: ExecArgs holds live kernel objects behind an interface, and MetricsExportData reaches a prometheus snapshot whose labels are a map. Co-authored-by: Hanzo Dev <[email protected]>
85 lines
2.3 KiB
Python
85 lines
2.3 KiB
Python
load("//tools:defs.bzl", "go_library", "go_test")
|
|
|
|
package(
|
|
default_applicable_licenses = ["//:license"],
|
|
licenses = ["notice"],
|
|
)
|
|
|
|
go_library(
|
|
name = "sandbox",
|
|
srcs = [
|
|
"network.go",
|
|
"network_unsafe.go",
|
|
"no_xdp.go",
|
|
"sandbox.go",
|
|
"xdp.go",
|
|
],
|
|
visibility = [
|
|
"//runsc:__subpackages__",
|
|
"//test:__subpackages__",
|
|
],
|
|
deps = [
|
|
"//pkg/abi/linux",
|
|
"//pkg/atomicbitops",
|
|
"//pkg/cleanup",
|
|
"//pkg/control/client",
|
|
"//pkg/control/server",
|
|
"//pkg/coverage",
|
|
"//pkg/fd",
|
|
"//pkg/hostos",
|
|
"//pkg/log",
|
|
"//pkg/metric:metric_go_proto",
|
|
"//pkg/prometheus",
|
|
"//pkg/sentry/checkpoint",
|
|
"//pkg/sentry/control",
|
|
"//pkg/sentry/devices/nvproxy",
|
|
"//pkg/sentry/devices/nvproxy/nvconf",
|
|
"//pkg/sentry/fsimpl/erofs",
|
|
"//pkg/sentry/platform",
|
|
"//pkg/sentry/seccheck",
|
|
"//pkg/sentry/socket/plugin",
|
|
"//pkg/sentry/state/checkpointfiles",
|
|
"//pkg/state/statefile",
|
|
"//pkg/sync",
|
|
"//pkg/tcpip/header",
|
|
"//pkg/tcpip/stack",
|
|
"//pkg/urpc",
|
|
"//pkg/xdp",
|
|
"//runsc/boot",
|
|
"//runsc/boot/procfs",
|
|
"//runsc/cgroup",
|
|
"//runsc/config",
|
|
"//runsc/console",
|
|
"//runsc/donation",
|
|
"//runsc/gvisorbinaries",
|
|
"//runsc/hostsettings",
|
|
"//runsc/profile",
|
|
"//runsc/sandbox/bpf",
|
|
"//runsc/specutils",
|
|
"//runsc/starttime",
|
|
"//tools/xdp/cmd",
|
|
"@com_github_cilium_ebpf//:go_default_library",
|
|
"@com_github_cilium_ebpf//link:go_default_library",
|
|
"@com_github_moby_sys_capability//:go_default_library",
|
|
"@com_github_opencontainers_runtime_spec//specs-go:go_default_library",
|
|
"@com_github_vishvananda_netlink//:go_default_library",
|
|
"@org_golang_google_protobuf//proto:go_default_library",
|
|
"@org_golang_x_sys//unix:go_default_library",
|
|
],
|
|
)
|
|
|
|
go_test(
|
|
name = "sandbox_test",
|
|
size = "small",
|
|
srcs = [
|
|
"network_test.go",
|
|
],
|
|
library = ":sandbox",
|
|
deps = [
|
|
"//runsc/boot",
|
|
"//runsc/config",
|
|
"@com_github_vishvananda_netlink//:go_default_library",
|
|
"@org_golang_x_sys//unix:go_default_library",
|
|
],
|
|
)
|