mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Merge branch 'master' into iptables
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
language: minimal
|
||||
sudo: required
|
||||
dist: xenial
|
||||
cache:
|
||||
directories:
|
||||
- /home/travis/.cache/bazel/
|
||||
services:
|
||||
- docker
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
arch: amd64
|
||||
env: RUNSC_PATH=./bazel-bin/runsc/linux_amd64_pure_stripped/runsc
|
||||
- os: linux
|
||||
arch: arm64
|
||||
env: RUNSC_PATH=./bazel-bin/runsc/linux_arm64_pure_stripped/runsc
|
||||
script:
|
||||
- uname -a
|
||||
- make DOCKER_RUN_OPTIONS="" BAZEL_OPTIONS="build runsc:runsc" bazel && $RUNSC_PATH --alsologtostderr --network none --debug --TESTONLY-unsafe-nonroot=true --rootless do ls
|
||||
+6
-5
@@ -1,8 +1,9 @@
|
||||
FROM ubuntu:bionic
|
||||
FROM fedora:31
|
||||
|
||||
RUN apt-get update && apt-get install -y curl gnupg2 git python python3 python3-distutils python3-pip
|
||||
RUN echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list && \
|
||||
curl https://bazel.build/bazel-release.pub.gpg | apt-key add -
|
||||
RUN apt-get update && apt-get install -y bazel && apt-get clean
|
||||
RUN dnf install -y dnf-plugins-core && dnf copr enable -y vbatts/bazel
|
||||
|
||||
RUN dnf install -y bazel2 git gcc make golang gcc-c++ glibc-devel python3 which python3-pip python3-devel libffi-devel openssl-devel pkg-config glibc-static
|
||||
|
||||
RUN pip install pycparser
|
||||
|
||||
WORKDIR /gvisor
|
||||
|
||||
@@ -2,6 +2,9 @@ UID := $(shell id -u ${USER})
|
||||
GID := $(shell id -g ${USER})
|
||||
GVISOR_BAZEL_CACHE := $(shell readlink -f ~/.cache/bazel/)
|
||||
|
||||
# The --privileged is required to run tests.
|
||||
DOCKER_RUN_OPTIONS ?= --privileged
|
||||
|
||||
all: runsc
|
||||
|
||||
docker-build:
|
||||
@@ -19,7 +22,7 @@ bazel-server-start: docker-build
|
||||
-v "$(CURDIR):$(CURDIR)" \
|
||||
--workdir "$(CURDIR)" \
|
||||
--tmpfs /tmp:rw,exec \
|
||||
--privileged \
|
||||
$(DOCKER_RUN_OPTIONS) \
|
||||
gvisor-bazel \
|
||||
sh -c "while :; do sleep 100; done" && \
|
||||
docker exec --user 0:0 -i gvisor-bazel sh -c "groupadd --gid $(GID) --non-unique gvisor && useradd --uid $(UID) --non-unique --gid $(GID) -d $(HOME) gvisor"
|
||||
|
||||
@@ -33,6 +33,20 @@ load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
|
||||
|
||||
gazelle_dependencies()
|
||||
|
||||
# TODO(gvisor.dev/issue/1876): Move the statement to "External repositories"
|
||||
# block below once 1876 is fixed.
|
||||
#
|
||||
# The com_google_protobuf repository below would trigger downloading a older
|
||||
# version of org_golang_x_sys. If putting this repository statment in a place
|
||||
# after that of the com_google_protobuf, this statement will not work as
|
||||
# expectd to download a new version of org_golang_x_sys.
|
||||
go_repository(
|
||||
name = "org_golang_x_sys",
|
||||
importpath = "golang.org/x/sys",
|
||||
sum = "h1:72l8qCJ1nGxMGH26QVBVIxKd/D34cfGt0OvrPtpemyY=",
|
||||
version = "v0.0.0-20191220220014-0732a990476f",
|
||||
)
|
||||
|
||||
# Load C++ rules.
|
||||
http_archive(
|
||||
name = "rules_cc",
|
||||
@@ -256,13 +270,6 @@ go_repository(
|
||||
version = "v0.0.0-20190423024810-112230192c58",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "org_golang_x_sys",
|
||||
importpath = "golang.org/x/sys",
|
||||
sum = "h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=",
|
||||
version = "v0.0.0-20190215142949-d0b11bdaac8a",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
name = "org_golang_x_time",
|
||||
commit = "c4c64cad1fd0a1a8dab2523e04e61d35308e131e",
|
||||
@@ -330,3 +337,13 @@ http_archive(
|
||||
"https://github.com/google/googletest/archive/565f1b848215b77c3732bca345fe76a0431d8b34.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "com_google_benchmark",
|
||||
sha256 = "3c6a165b6ecc948967a1ead710d4a181d7b0fbcaa183ef7ea84604994966221a",
|
||||
strip_prefix = "benchmark-1.5.0",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/google/benchmark/archive/v1.5.0.tar.gz",
|
||||
"https://github.com/google/benchmark/archive/v1.5.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -43,6 +43,8 @@ from benchmarks.harness import machine_mocks
|
||||
from benchmarks.harness import ssh_connection
|
||||
from benchmarks.harness import tunnel_dispatcher
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Machine(object):
|
||||
"""The machine object is the primary object for benchmarks.
|
||||
@@ -236,9 +238,10 @@ class RemoteMachine(Machine):
|
||||
archive=archive, dir=harness.REMOTE_INSTALLERS_PATH))
|
||||
self._has_installers = True
|
||||
|
||||
# Execute the remote installer.
|
||||
self.run("sudo {dir}/{file}".format(
|
||||
dir=harness.REMOTE_INSTALLERS_PATH, file=installer))
|
||||
# Execute the remote installer.
|
||||
self.run("sudo {dir}/{file}".format(
|
||||
dir=harness.REMOTE_INSTALLERS_PATH, file=installer))
|
||||
|
||||
if results:
|
||||
results[index] = True
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# limitations under the License.
|
||||
"""SSHConnection handles the details of SSH connections."""
|
||||
|
||||
|
||||
import logging
|
||||
import os
|
||||
import warnings
|
||||
|
||||
@@ -24,6 +24,8 @@ from benchmarks import harness
|
||||
# Get rid of paramiko Cryptography Warnings.
|
||||
warnings.filterwarnings(action="ignore", module=".*paramiko.*")
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def send_one_file(client: paramiko.SSHClient, path: str,
|
||||
remote_dir: str) -> str:
|
||||
@@ -94,10 +96,13 @@ class SSHConnection:
|
||||
The contents of stdout and stderr.
|
||||
"""
|
||||
with self._client() as client:
|
||||
log.info("running command: %s", cmd)
|
||||
_, stdout, stderr = client.exec_command(command=cmd)
|
||||
stdout.channel.recv_exit_status()
|
||||
log.info("returned status: %d", stdout.channel.recv_exit_status())
|
||||
stdout = stdout.read().decode("utf-8")
|
||||
stderr = stderr.read().decode("utf-8")
|
||||
log.info("stdout: %s", stdout)
|
||||
log.info("stderr: %s", stderr)
|
||||
return stdout, stderr
|
||||
|
||||
def send_workload(self, name: str) -> str:
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
build_file : 'repo/scripts/benchmark.sh'
|
||||
|
||||
|
||||
before_action {
|
||||
fetch_keystore {
|
||||
keystore_resource {
|
||||
keystore_config_id : 73898
|
||||
keyname : 'kokoro-rbe-service-account'
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
env_vars {
|
||||
key : 'PROJECT'
|
||||
value : 'gvisor-kokoro-testing'
|
||||
}
|
||||
|
||||
env_vars {
|
||||
key : 'ZONE'
|
||||
value : 'us-central1-b'
|
||||
}
|
||||
|
||||
env_vars {
|
||||
key : 'KOKORO_SERVICE_ACCOUNT'
|
||||
value : '73898_kokoro-rbe-service-account'
|
||||
}
|
||||
@@ -4,3 +4,13 @@ env_vars {
|
||||
key: "RUNTIME_TEST_NAME"
|
||||
value: "go1.12"
|
||||
}
|
||||
|
||||
action {
|
||||
define_artifacts {
|
||||
regex: "**/sponge_log.xml"
|
||||
regex: "**/sponge_log.log"
|
||||
regex: "**/outputs.zip"
|
||||
regex: "**/runsc"
|
||||
regex: "**/runsc.*"
|
||||
}
|
||||
}
|
||||
@@ -4,3 +4,13 @@ env_vars {
|
||||
key: "RUNTIME_TEST_NAME"
|
||||
value: "java11"
|
||||
}
|
||||
|
||||
action {
|
||||
define_artifacts {
|
||||
regex: "**/sponge_log.xml"
|
||||
regex: "**/sponge_log.log"
|
||||
regex: "**/outputs.zip"
|
||||
regex: "**/runsc"
|
||||
regex: "**/runsc.*"
|
||||
}
|
||||
}
|
||||
@@ -4,3 +4,13 @@ env_vars {
|
||||
key: "RUNTIME_TEST_NAME"
|
||||
value: "nodejs12.4.0"
|
||||
}
|
||||
|
||||
action {
|
||||
define_artifacts {
|
||||
regex: "**/sponge_log.xml"
|
||||
regex: "**/sponge_log.log"
|
||||
regex: "**/outputs.zip"
|
||||
regex: "**/runsc"
|
||||
regex: "**/runsc.*"
|
||||
}
|
||||
}
|
||||
@@ -4,3 +4,13 @@ env_vars {
|
||||
key: "RUNTIME_TEST_NAME"
|
||||
value: "php7.3.6"
|
||||
}
|
||||
|
||||
action {
|
||||
define_artifacts {
|
||||
regex: "**/sponge_log.xml"
|
||||
regex: "**/sponge_log.log"
|
||||
regex: "**/outputs.zip"
|
||||
regex: "**/runsc"
|
||||
regex: "**/runsc.*"
|
||||
}
|
||||
}
|
||||
@@ -4,3 +4,13 @@ env_vars {
|
||||
key: "RUNTIME_TEST_NAME"
|
||||
value: "python3.7.3"
|
||||
}
|
||||
|
||||
action {
|
||||
define_artifacts {
|
||||
regex: "**/sponge_log.xml"
|
||||
regex: "**/sponge_log.log"
|
||||
regex: "**/outputs.zip"
|
||||
regex: "**/runsc"
|
||||
regex: "**/runsc.*"
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ go_library(
|
||||
"futex.go",
|
||||
"inotify.go",
|
||||
"ioctl.go",
|
||||
"ioctl_tun.go",
|
||||
"ip.go",
|
||||
"ipc.go",
|
||||
"limits.go",
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"gvisor.dev/gvisor/pkg/binary"
|
||||
)
|
||||
|
||||
// Event masks.
|
||||
const (
|
||||
EPOLLIN = 0x1
|
||||
@@ -53,3 +57,6 @@ const (
|
||||
EPOLL_CTL_DEL = 0x2
|
||||
EPOLL_CTL_MOD = 0x3
|
||||
)
|
||||
|
||||
// SizeOfEpollEvent is the size of EpollEvent struct.
|
||||
var SizeOfEpollEvent = int(binary.Size(EpollEvent{}))
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package linux
|
||||
|
||||
// EpollEvent is equivalent to struct epoll_event from epoll(2).
|
||||
//
|
||||
// +marshal
|
||||
type EpollEvent struct {
|
||||
Events uint32
|
||||
// Linux makes struct epoll_event::data a __u64. We represent it as
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package linux
|
||||
|
||||
// EpollEvent is equivalent to struct epoll_event from epoll(2).
|
||||
//
|
||||
// +marshal
|
||||
type EpollEvent struct {
|
||||
Events uint32
|
||||
// Linux makes struct epoll_event a __u64, necessitating 4 bytes of padding
|
||||
|
||||
@@ -241,6 +241,8 @@ const (
|
||||
)
|
||||
|
||||
// Statx represents struct statx.
|
||||
//
|
||||
// +marshal
|
||||
type Statx struct {
|
||||
Mask uint32
|
||||
Blksize uint32
|
||||
|
||||
@@ -38,6 +38,8 @@ const (
|
||||
)
|
||||
|
||||
// Statfs is struct statfs, from uapi/asm-generic/statfs.h.
|
||||
//
|
||||
// +marshal
|
||||
type Statfs struct {
|
||||
// Type is one of the filesystem magic values, defined above.
|
||||
Type uint64
|
||||
|
||||
@@ -72,3 +72,29 @@ const (
|
||||
SIOCGMIIPHY = 0x8947
|
||||
SIOCGMIIREG = 0x8948
|
||||
)
|
||||
|
||||
// ioctl(2) directions. Used to calculate requests number.
|
||||
// Constants from asm-generic/ioctl.h.
|
||||
const (
|
||||
_IOC_NONE = 0
|
||||
_IOC_WRITE = 1
|
||||
_IOC_READ = 2
|
||||
)
|
||||
|
||||
// Constants from asm-generic/ioctl.h.
|
||||
const (
|
||||
_IOC_NRBITS = 8
|
||||
_IOC_TYPEBITS = 8
|
||||
_IOC_SIZEBITS = 14
|
||||
_IOC_DIRBITS = 2
|
||||
|
||||
_IOC_NRSHIFT = 0
|
||||
_IOC_TYPESHIFT = _IOC_NRSHIFT + _IOC_NRBITS
|
||||
_IOC_SIZESHIFT = _IOC_TYPESHIFT + _IOC_TYPEBITS
|
||||
_IOC_DIRSHIFT = _IOC_SIZESHIFT + _IOC_SIZEBITS
|
||||
)
|
||||
|
||||
// IOC outputs the result of _IOC macro in asm-generic/ioctl.h.
|
||||
func IOC(dir, typ, nr, size uint32) uint32 {
|
||||
return uint32(dir)<<_IOC_DIRSHIFT | typ<<_IOC_TYPESHIFT | nr<<_IOC_NRSHIFT | size<<_IOC_SIZESHIFT
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2019 The gVisor Authors.
|
||||
// Copyright 2020 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -12,16 +12,18 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package usermem
|
||||
package linux
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
// ioctl(2) request numbers from linux/if_tun.h
|
||||
var (
|
||||
TUNSETIFF = IOC(_IOC_WRITE, 'T', 202, 4)
|
||||
TUNGETIFF = IOC(_IOC_READ, 'T', 210, 4)
|
||||
)
|
||||
|
||||
// stringFromImmutableBytes is equivalent to string(bs), except that it never
|
||||
// copies even if escape analysis can't prove that bs does not escape. This is
|
||||
// only valid if bs is never mutated after stringFromImmutableBytes returns.
|
||||
func stringFromImmutableBytes(bs []byte) string {
|
||||
// Compare strings.Builder.String().
|
||||
return *(*string)(unsafe.Pointer(&bs))
|
||||
}
|
||||
// Flags from net/if_tun.h
|
||||
const (
|
||||
IFF_TUN = 0x0001
|
||||
IFF_TAP = 0x0002
|
||||
IFF_NO_PI = 0x1000
|
||||
IFF_NOFILTER = 0x1000
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user