Commit Graph

2505 Commits

Author SHA1 Message Date
moricho d8ed784311 add profile option 2020-02-26 16:49:51 +09:00
Adin Scannell 160d5751ab Add default behavior for gtest runner.
PiperOrigin-RevId: 297009116
2020-02-24 17:29:34 -08:00
gVisor bot 93626a28e4 Merge pull request #1886 from avagin:arm64-travis-ci
PiperOrigin-RevId: 296975376
2020-02-24 14:34:13 -08:00
Brad Burlage ededa90d07 Internal change.
PiperOrigin-RevId: 296972565
2020-02-24 14:22:32 -08:00
Ian Gudger c37b196455 Add support for tearing down protocol dispatchers and TIME_WAIT endpoints.
Protocol dispatchers were previously leaked. Bypassing TIME_WAIT is required to
test this change.

Also fix a race when a socket in SYN-RCVD is closed. This is also required to
test this change.

PiperOrigin-RevId: 296922548
2020-02-24 10:32:17 -08:00
Andrei Vagin 75d7f76a6c arm64: add a travis build ci
Build runsc and run "runsc do ls".

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-21 22:44:19 -08:00
Ting-Yu Wang b8f56c79be Implement tap/tun device in vfs.
PiperOrigin-RevId: 296526279
2020-02-21 15:42:56 -08:00
Adin Scannell 10aa4d3b34 Factor platform tags.
PiperOrigin-RevId: 296519566
2020-02-21 15:06:08 -08:00
Zach Koopmans 3733499952 Fix master installer.
Sometimes, when we start a new instance, the file
lock on "apt" is locked. Add a loop to the master
installer.

In addition, the "apt-get install" fails to register
runsc in docker, so run the appropriate scripts to
get that to happen.

Also, add some helpful log messages.

PiperOrigin-RevId: 296497357
2020-02-21 13:18:51 -08:00
Ghanan Gowripalan a155a23480 Attach LinkEndpoint to NetworkDispatcher immediately
Tests: stack_test.TestAttachToLinkEndpointImmediately
PiperOrigin-RevId: 296474068
2020-02-21 11:21:23 -08:00
Copybara-Service d8e60e7867 Merge pull request #1911 from xiaobo55x:x_sys
PiperOrigin-RevId: 296472477
2020-02-21 11:14:05 -08:00
Ghanan Gowripalan 97c07242c3 Use Route.MaxHeaderLength when constructing NDP RS
Test: stack_test.TestRouterSolicitation
PiperOrigin-RevId: 296454766
2020-02-21 09:54:55 -08:00
Haibo Xu 5d711c329a Force downloading new version of org_golang_x_sys.
ARM64 PTRACE_SYSEMU support was added to Linux kernal from
v5.3 and the corresponding support in golang is also enabled
in the latest org.golang/x/sys repository.

Updates #1876

Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: I10750c4c8b68f6f68d0a4d828e266966434c92fe
2020-02-21 01:51:14 +00:00
gVisor bot f1b72752e5 Implement automated marshalling for newtypes on primitives.
PiperOrigin-RevId: 296322954
2020-02-20 16:23:56 -08:00
gVisor bot 4a73bae269 Initial network namespace support.
TCP/IP will work with netstack networking. hostinet doesn't work, and sockets
will have the same behavior as it is now.

Before the userspace is able to create device, the default loopback device can
be used to test.

/proc/net and /sys/net will still be connected to the root network stack; this
is the same behavior now.

Issue #1833

PiperOrigin-RevId: 296309389
2020-02-20 15:20:40 -08:00
gVisor bot 67b615b86f Support disabling a NIC
- Disabled NICs will have their associated NDP state cleared.
- Disabled NICs will not accept incoming packets.
- Writes through a Route with a disabled NIC will return an invalid
  endpoint state error.
- stack.Stack.FindRoute will not return a route with a disabled NIC.
- NIC's Running flag will report the NIC's enabled status.

Tests:
- stack_test.TestDisableUnknownNIC
- stack_test.TestDisabledNICsNICInfoAndCheckNIC
- stack_test.TestRoutesWithDisabledNIC
- stack_test.TestRouteWritePacketWithDisabledNIC
- stack_test.TestStopStartSolicitingRouters
- stack_test.TestCleanupNDPState
- stack_test.TestAddRemoveIPv4BroadcastAddressOnNICEnableDisable
- stack_test.TestJoinLeaveAllNodesMulticastOnNICEnableDisable
PiperOrigin-RevId: 296298588
2020-02-20 14:32:49 -08:00
gVisor bot d90d71474f Remove bytes read/written from marshal.Marshallable API.
Users of the API only care about whether the copy in/out succeeds in
their entirety, which is already signalled by the returned error.

PiperOrigin-RevId: 296297843
2020-02-20 14:29:26 -08:00
gVisor bot 1bb0195079 Add placeholder .travis.yml for #1886
PiperOrigin-RevId: 296279095
2020-02-20 13:07:24 -08:00
Adin Scannell 72187fa7a9 Import tags.bzl directly from tools/defs.bzl.
This simplifies the script slightly.

PiperOrigin-RevId: 296272077
2020-02-20 12:33:35 -08:00
gVisor bot 9bad87339a Better strace logging for epoll syscalls.
Example:

epoll_ctl(0x3 anon_inode:[eventpoll], EPOLL_CTL_ADD, 0x6 anon_inode:[eventfd], 0x7efe2fd92a80 {events=EPOLLIN|EPOLLOUT data=0x10203040506070a}) = 0x0 (4.411µs)

epoll_wait(0x3 anon_inode:[eventpoll], 0x7efe2fd92b50 {{events=EPOLLOUT data=0x102030405060708}{events=EPOLLOUT data=0x102030405060708}{events=EPOLLOUT data=0x102030405060708}}, 0x3, 0xffffffff) = 0x3 (29.891µs)

PiperOrigin-RevId: 296258146
2020-02-20 11:31:00 -08:00
gVisor bot 9a4e3e63ef Re-add atomicbitops_arm64.s to BUILD.
This was inadverently dropped by cl/295811743.

PiperOrigin-RevId: 296254482
2020-02-20 11:16:08 -08:00
gVisor bot 10ed60e477 VFS2: Support memory mapping in tmpfs.
tmpfs.fileDescription now implements ConfigureMMap. And tmpfs.regularFile
implement memmap.Mappable. The methods are mostly unchanged from VFS1 tmpfs.

PiperOrigin-RevId: 296234557
2020-02-20 09:58:10 -08:00
Adin Scannell ec5630527b Add statefile command to runsc.
PiperOrigin-RevId: 296105337
2020-02-19 18:28:42 -08:00
Adin Scannell 30794512d3 Add basic microbenchmarks.
PiperOrigin-RevId: 296104390
2020-02-19 18:21:54 -08:00
gVisor bot 2daa21e4d7 Internal change.
PiperOrigin-RevId: 296088213
2020-02-19 16:48:57 -08:00
gVisor bot 660cfdff3f Handle situations where go-marshal generates an empty test file.
This can happen due to conditional compilation, where a subset of the
source files contain no marshallable types. go-marshal is still
required to write an output file in these cases, since bazel defines
the output package before calling go-marshal.

PiperOrigin-RevId: 296074321
2020-02-19 15:42:19 -08:00
gVisor bot 3a20eccf8b Internal change.
PiperOrigin-RevId: 296055452
2020-02-19 14:18:11 -08:00
gVisor bot ddc02e489c Internal change.
PiperOrigin-RevId: 296039442
2020-02-19 13:12:31 -08:00
gVisor bot 55c99ce106 Include more test files in exports_files
So that they can be included by Fuchsia's syscall tests

PiperOrigin-RevId: 296030383
2020-02-19 12:32:44 -08:00
Copybara-Service dbf37bf8b4 Merge pull request #1896 from kevinGC:parseports
PiperOrigin-RevId: 296017834
2020-02-19 11:40:36 -08:00
gVisor bot 90d0851c0e Internal change.
PiperOrigin-RevId: 296016675
2020-02-19 11:36:20 -08:00
Kevin Krakauer 92d2d78876 Fix mis-named comment. 2020-02-18 21:20:41 -08:00
gVisor bot 8dae8a10f0 Internal change.
PiperOrigin-RevId: 295857142
2020-02-18 17:04:58 -08:00
gVisor bot 56fd9504aa Enable IPV6_RECVTCLASS socket option for datagram sockets
Added the ability to get/set the IP_RECVTCLASS socket option on UDP endpoints.
If enabled, traffic class from the incoming Network Header passed as ancillary
data in the ControlMessages.

Adding Get/SetSockOptBool to decrease the overhead of getting/setting simple
options. (This was absorbed in a CL that will be landing before this one).

Test:
* Added unit test to udp_test.go that tests getting/setting as well as
verifying that we receive expected TOS from incoming packet.
* Added a syscall test for verifying getting/setting
* Removed test skip for existing syscall test to enable end to end test.
PiperOrigin-RevId: 295840218
2020-02-18 15:45:36 -08:00
gVisor bot 247843bbc5 iptables: use "-t nat" for NAT tests
PiperOrigin-RevId: 295835807
2020-02-18 15:25:51 -08:00
gVisor bot 55c553ae8c Add //pkg/syncevent.
Package syncevent is intended to subsume ~all uses of channels in the sentry
(including //pkg/waiter), as well as //pkg/sleep.

Compared to channels:

- Delivery of events to a syncevent.Receiver allows *synchronous* execution of
  an arbitrary callback, whereas delivery of events to a channel requires a
  goroutine to receive from that channel, resulting in substantial scheduling
  overhead. (This is also part of the motivation for the waiter package.)

- syncevent.Waiter can wait on multiple event sources without the high O(N)
  overhead of select. (This is the same motivation as for the sleep package.)

Compared to the waiter package:

- syncevent.Waiters are intended to be persistent (i.e. per-kernel.Task), and
  syncevent.Broadcaster (analogous to waiter.Queue) is a hash table rather than
  a linked list, such that blocking is (usually) allocation-free.

- syncevent.Source (analogous to waiter.Waitable) does not include an equivalent
  to waiter.Waitable.Readiness(), since this is inappropriate for transient
  events (see e.g. //pkg/sentry/kernel/time.ClockEventSource).

Compared to the sleep package:

- syncevent events are represented by bits in a bitmask rather than discrete
  sleep.Waker objects, reducing overhead and making it feasible to broadcast
  events to multiple syncevent.Receivers.

- syncevent.Receiver invokes an arbitrary callback, which is required by the
  sentry's epoll implementation. (syncevent.Waiter, which is analogous to
  sleep.Sleeper, pairs a syncevent.Receiver with a callback that wakes a
  waiting goroutine; the implementation of this aspect is nearly identical to
  that of sleep.Sleeper, except that it represents *runtime.g as unsafe.Pointer
  rather than uintptr.)

- syncevent.Waiter.Wait (analogous to sleep.Sleeper.Fetch(block=true)) does not
  automatically un-assert returned events. This is useful in cases where the
  path for handling an event is not the same as the path that observes it, such
  as for application signals (a la Linux's TIF_SIGPENDING).

- Unlike sleep.Sleeper, which Fetches Wakers in the order that they were
  Asserted, the event bitmasks used by syncevent.Receiver have no way of
  preserving event arrival order. (This is similar to select, which goes out of
  its way to randomize event ordering.)

The disadvantage of the syncevent package is that, since events are represented
by bits in a uint64 bitmask, each syncevent.Receiver can "only" multiplex
between 64 distinct events; this does not affect any known use case.

Benchmarks:

BenchmarkBroadcasterSubscribeUnsubscribe
BenchmarkBroadcasterSubscribeUnsubscribe-12         	45133884	        26.3 ns/op
BenchmarkMapSubscribeUnsubscribe
BenchmarkMapSubscribeUnsubscribe-12                 	28504662	        41.8 ns/op
BenchmarkQueueSubscribeUnsubscribe
BenchmarkQueueSubscribeUnsubscribe-12               	22747668	        45.6 ns/op
BenchmarkBroadcasterSubscribeUnsubscribeBatch
BenchmarkBroadcasterSubscribeUnsubscribeBatch-12    	31609177	        37.8 ns/op
BenchmarkMapSubscribeUnsubscribeBatch
BenchmarkMapSubscribeUnsubscribeBatch-12            	17563906	        62.1 ns/op
BenchmarkQueueSubscribeUnsubscribeBatch
BenchmarkQueueSubscribeUnsubscribeBatch-12          	26248838	        46.6 ns/op
BenchmarkBroadcasterBroadcastRedundant
BenchmarkBroadcasterBroadcastRedundant/0
BenchmarkBroadcasterBroadcastRedundant/0-12         	100907563	        11.8 ns/op
BenchmarkBroadcasterBroadcastRedundant/1
BenchmarkBroadcasterBroadcastRedundant/1-12         	85103068	        13.3 ns/op
BenchmarkBroadcasterBroadcastRedundant/4
BenchmarkBroadcasterBroadcastRedundant/4-12         	52716502	        22.3 ns/op
BenchmarkBroadcasterBroadcastRedundant/16
BenchmarkBroadcasterBroadcastRedundant/16-12        	20278165	        58.7 ns/op
BenchmarkBroadcasterBroadcastRedundant/64
BenchmarkBroadcasterBroadcastRedundant/64-12        	 5905428	       205 ns/op
BenchmarkMapBroadcastRedundant
BenchmarkMapBroadcastRedundant/0
BenchmarkMapBroadcastRedundant/0-12                 	87532734	        13.5 ns/op
BenchmarkMapBroadcastRedundant/1
BenchmarkMapBroadcastRedundant/1-12                 	28488411	        36.3 ns/op
BenchmarkMapBroadcastRedundant/4
BenchmarkMapBroadcastRedundant/4-12                 	19628920	        60.9 ns/op
BenchmarkMapBroadcastRedundant/16
BenchmarkMapBroadcastRedundant/16-12                	 6026980	       192 ns/op
BenchmarkMapBroadcastRedundant/64
BenchmarkMapBroadcastRedundant/64-12                	 1640858	       754 ns/op
BenchmarkQueueBroadcastRedundant
BenchmarkQueueBroadcastRedundant/0
BenchmarkQueueBroadcastRedundant/0-12               	96904807	        12.0 ns/op
BenchmarkQueueBroadcastRedundant/1
BenchmarkQueueBroadcastRedundant/1-12               	73521873	        16.3 ns/op
BenchmarkQueueBroadcastRedundant/4
BenchmarkQueueBroadcastRedundant/4-12               	39209468	        31.2 ns/op
BenchmarkQueueBroadcastRedundant/16
BenchmarkQueueBroadcastRedundant/16-12              	10810058	       105 ns/op
BenchmarkQueueBroadcastRedundant/64
BenchmarkQueueBroadcastRedundant/64-12              	 2998046	       376 ns/op
BenchmarkBroadcasterBroadcastAck
BenchmarkBroadcasterBroadcastAck/1
BenchmarkBroadcasterBroadcastAck/1-12               	44472397	        26.4 ns/op
BenchmarkBroadcasterBroadcastAck/4
BenchmarkBroadcasterBroadcastAck/4-12               	17653509	        69.7 ns/op
BenchmarkBroadcasterBroadcastAck/16
BenchmarkBroadcasterBroadcastAck/16-12              	 4082617	       260 ns/op
BenchmarkBroadcasterBroadcastAck/64
BenchmarkBroadcasterBroadcastAck/64-12              	 1220534	      1027 ns/op
BenchmarkMapBroadcastAck
BenchmarkMapBroadcastAck/1
BenchmarkMapBroadcastAck/1-12                       	26760705	        44.2 ns/op
BenchmarkMapBroadcastAck/4
BenchmarkMapBroadcastAck/4-12                       	11495636	       100 ns/op
BenchmarkMapBroadcastAck/16
BenchmarkMapBroadcastAck/16-12                      	 2937590	       343 ns/op
BenchmarkMapBroadcastAck/64
BenchmarkMapBroadcastAck/64-12                      	  861037	      1344 ns/op
BenchmarkQueueBroadcastAck
BenchmarkQueueBroadcastAck/1
BenchmarkQueueBroadcastAck/1-12                     	19832679	        55.0 ns/op
BenchmarkQueueBroadcastAck/4
BenchmarkQueueBroadcastAck/4-12                     	 5618214	       189 ns/op
BenchmarkQueueBroadcastAck/16
BenchmarkQueueBroadcastAck/16-12                    	 1569980	       713 ns/op
BenchmarkQueueBroadcastAck/64
BenchmarkQueueBroadcastAck/64-12                    	  437672	      2814 ns/op
BenchmarkWaiterNotifyRedundant
BenchmarkWaiterNotifyRedundant-12                   	650823090	         1.96 ns/op
BenchmarkSleeperNotifyRedundant
BenchmarkSleeperNotifyRedundant-12                  	619871544	         1.61 ns/op
BenchmarkChannelNotifyRedundant
BenchmarkChannelNotifyRedundant-12                  	298903778	         3.67 ns/op
BenchmarkWaiterNotifyWaitAck
BenchmarkWaiterNotifyWaitAck-12                     	68358360	        17.8 ns/op
BenchmarkSleeperNotifyWaitAck
BenchmarkSleeperNotifyWaitAck-12                    	25044883	        41.2 ns/op
BenchmarkChannelNotifyWaitAck
BenchmarkChannelNotifyWaitAck-12                    	29572404	        40.2 ns/op
BenchmarkSleeperMultiNotifyWaitAck
BenchmarkSleeperMultiNotifyWaitAck-12               	16122969	        73.8 ns/op
BenchmarkWaiterTempNotifyWaitAck
BenchmarkWaiterTempNotifyWaitAck-12                 	46111489	        25.8 ns/op
BenchmarkSleeperTempNotifyWaitAck
BenchmarkSleeperTempNotifyWaitAck-12                	15541882	        73.6 ns/op
BenchmarkWaiterNotifyWaitMultiAck
BenchmarkWaiterNotifyWaitMultiAck-12                	65878500	        18.2 ns/op
BenchmarkSleeperNotifyWaitMultiAck
BenchmarkSleeperNotifyWaitMultiAck-12               	28798623	        41.5 ns/op
BenchmarkChannelNotifyWaitMultiAck
BenchmarkChannelNotifyWaitMultiAck-12               	11308468	       101 ns/op
BenchmarkWaiterNotifyAsyncWaitAck
BenchmarkWaiterNotifyAsyncWaitAck-12                	 2475387	       492 ns/op
BenchmarkSleeperNotifyAsyncWaitAck
BenchmarkSleeperNotifyAsyncWaitAck-12               	 2184507	       518 ns/op
BenchmarkChannelNotifyAsyncWaitAck
BenchmarkChannelNotifyAsyncWaitAck-12               	 2120365	       562 ns/op
BenchmarkWaiterNotifyAsyncWaitMultiAck
BenchmarkWaiterNotifyAsyncWaitMultiAck-12           	 2351247	       494 ns/op
BenchmarkSleeperNotifyAsyncWaitMultiAck
BenchmarkSleeperNotifyAsyncWaitMultiAck-12          	 2205799	       522 ns/op
BenchmarkChannelNotifyAsyncWaitMultiAck
BenchmarkChannelNotifyAsyncWaitMultiAck-12          	 1238079	       928 ns/op

Updates #1074

PiperOrigin-RevId: 295834087
2020-02-18 15:18:48 -08:00
gVisor bot 737a3d072e go-marshal: Stop complaining about files with no +marshal types.
Since we tag entire packages as marshallable, due to conditional
compiling for different architectures we can end up with sets of
source files that don't contain any marshallable types. It's safe to
silently ignore this scenario.

PiperOrigin-RevId: 295831871
2020-02-18 15:09:17 -08:00
gVisor bot a3582de618 cpuid: cache the maximum size of xsave state
perf shows that ExtendedStateSize cosumes more than 20% of cpu:

    23.61%    23.61%  [.] pkg/cpuid/cpuid.HostID

PiperOrigin-RevId: 295813263
2020-02-18 13:50:07 -08:00
gVisor bot 906eb6295d atomicbitops package cleanups
- Redocument memory ordering from "no ordering" to "acquire-release". (No
  functional change: both LOCK WHATEVER on x86, and LDAXR/STLXR loops on ARM64,
  already have this property.)

- Remove IncUnlessZeroInt32 and DecUnlessOneInt32, which were only faster than
  the equivalent loops using sync/atomic before the Go compiler inlined
  non-unsafe.Pointer atomics many releases ago.

PiperOrigin-RevId: 295811743
2020-02-18 13:43:28 -08:00
gVisor bot c841373013 Deflake fallocate syscall test.
- Retry if fallocate returns EINTR.

- If fallocate fails, don't try to fstat and confirm the result.

PiperOrigin-RevId: 295789790
2020-02-18 12:02:05 -08:00
gVisor bot 7fdb609b3e Merge pull request #1850 from kevinGC:jump2
PiperOrigin-RevId: 295785052
2020-02-18 11:41:54 -08:00
gVisor bot fae3de21af ring0/pagetables: fix typo
PiperOrigin-RevId: 295770717
2020-02-18 10:50:46 -08:00
gVisor bot fe92fb36ac Add flag to run without building baked images.
Adds flag to :benchmarks to allow running without
building "baked images", which depends on gcloud.

Users can skip gcloud workflows using the following:

blaze run --define gcloud=off :benchmarks -- my-command-without-gcloud

"run-gcp" will not work with the flag set, but all other commands will.

PiperOrigin-RevId: 295627718
2020-02-17 15:02:20 -08:00
gVisor bot 5cc0bbbafb Ensure Marshallable.SizeBytes() always works on a typed nil pointer.
This lets go-marshal replace various calls to binary.Size() throughout
the sentry without requiring concrete objects.

PiperOrigin-RevId: 295299965
2020-02-15 00:01:02 -08:00
gVisor bot 3d32ad1367 Generate implementation of io.WriterTo via go-marshal.
PiperOrigin-RevId: 295269654
2020-02-14 18:32:49 -08:00
gVisor bot a5069f820f Remove linux.EpollEvent.Fd.
glibc defines struct epoll_event in such a way that epoll_event.data.fd exists.
However, the kernel's definition of struct epoll_event makes epoll_event.data
an opaque uint64, so naming half of it "fd" just introduces confusion. Remove
the Fd field, and make Data a [2]int32 to compensate.

Also add required padding to linux.EpollEvent on ARM64.

PiperOrigin-RevId: 295250424
2020-02-14 16:19:48 -08:00
gVisor bot 5baf9dc2fb Synchronize signalling with S/R
This is to fix a data race between sending an external signal to
a ThreadGroup and kernel saving state for S/R.

PiperOrigin-RevId: 295244281
2020-02-14 15:49:09 -08:00
gVisor bot 48d9aa7ab3 Add a minimal binary target for escape analysis on go-marshal.
Note that this is not an automated test.

PiperOrigin-RevId: 295238672
2020-02-14 15:21:03 -08:00
gVisor bot 3557b26651 Allow vfs.IterDirentsCallback.Handle() to return an error.
This is easier than storing errors from e.g. CopyOut in the callback.

PiperOrigin-RevId: 295230021
2020-02-14 14:40:35 -08:00
gVisor bot 87bc2834c9 Enable automated marshalling for RSeqCriticalSection.
PiperOrigin-RevId: 295226468
2020-02-14 14:24:27 -08:00