Commit Graph

2045 Commits

Author SHA1 Message Date
Mithun Iyer b1d44be7ad Add TCP stats for connection close and keep-alive timeouts.
Fix bugs in updates to TCP CurrentEstablished stat.

Fixes #1277

PiperOrigin-RevId: 284292459
2019-12-06 17:17:33 -08:00
Adin Scannell 371e210b83 Add runtime tracing.
This adds meaningful annotations to the trace generated by the runtime/trace
package.

PiperOrigin-RevId: 284290115
2019-12-06 17:00:07 -08:00
Bhasker Hariharan 3e84777d2e Fix flakiness in tcp_test.
This change marks the socket as ESTABLISHED and creates the receiver and sender
the moment we send the final ACK in case of an active TCP handshake or when we
receive the final ACK for a passive TCP handshake. Before this change there was
a short window in which an ACK can be received and processed but the state on
the socket is not yet ESTABLISHED.

This can be seen in TestConnectBindToDevice which is flaky because sometimes
the socket is in SYN-SENT and not ESTABLISHED even though the other side has
already received the final ACK of the handshake.

PiperOrigin-RevId: 284277713
2019-12-06 15:46:26 -08:00
Michael Pratt 7b81633ff8 Build with C++17
This will require a reasonably modern toolchain. I've put minimum compiler
versions in the README based on versions in
https://en.cppreference.com/w/cpp/compiler_support that have mostly complete
language and library support.

The minimum Bazel version bump is unrelated, but 0.28 is definitely not
supported anymore.

Please report issues on gvisor.dev/issue/1349.

Fixes #1349

PiperOrigin-RevId: 284274250
2019-12-06 15:26:47 -08:00
Ghanan Gowripalan ab3f7bc393 Do IPv6 Stateless Address Auto-Configuration (SLAAC)
This change allows the netstack to do SLAAC as outlined by RFC 4862 section 5.5.

Note, this change will not break existing uses of netstack as the default
configuration for the stack options is set in such a way that SLAAC
will not be performed. See `stack.Options` and `stack.NDPConfigurations` for
more details.

This change reuses 1 option and introduces a new one that is required to take
advantage of SLAAC, all available under NDPConfigurations:
- HandleRAs: Whether or not NDP RAs are processes
- AutoGenGlobalAddresses: Whether or not SLAAC is performed.

Also note, this change does not deprecate SLAAC generated addresses after the
preferred lifetime. That will come in a later change (b/143713887). Currently,
only the valid lifetime is honoured.

Tests: Unittest to make sure that SLAAC generates and adds addresses only when
configured to do so. Tests also makes sure that conflicts with static addresses
do not modify the static address.
PiperOrigin-RevId: 284265317
2019-12-06 14:41:30 -08:00
Nicolas Lacasse 663fe840f7 Implement TTY field in control.Processes().
Threadgroups already know their TTY (if they have one), which now contains the
TTY Index, and is returned in the Processes() call.

PiperOrigin-RevId: 284263850
2019-12-06 14:34:13 -08:00
Fabricio Voznika ea7a100202 Make annotations OCI compliant
Changed annotation to follow the standard defined here:
https://github.com/opencontainers/image-spec/blob/master/annotations.md

PiperOrigin-RevId: 284254847
2019-12-06 13:51:38 -08:00
Dean Deng b0066217ec Add hostinet tests for UDP sockets.
We need to skip a subset of the tests, because of features that hostinet does
not currently support.

Fixes #1209

PiperOrigin-RevId: 284235911
2019-12-06 12:14:23 -08:00
gVisor bot 6780740081 Merge pull request #1314 from google:dependabot/npm_and_yarn/benchmarks/workloads/node_template/lodash-4.17.15
PiperOrigin-RevId: 284210333
2019-12-06 10:19:56 -08:00
Michael Pratt f8bb3f7904 Document ELF PT_LOAD difference from Linux
PiperOrigin-RevId: 284191345
2019-12-06 08:37:14 -08:00
Fabricio Voznika 40035d7d9c Fix possible race condition destroying container
When the sandbox is destroyed, making URPC calls to destroy the
container will fail. The code was checking if the sandbox was
running before attempting to make the URPC call, but that is racy.

PiperOrigin-RevId: 284093764
2019-12-05 17:58:36 -08:00
Ian Gudger 13f0f6069a Implement F_GETOWN_EX and F_SETOWN_EX.
Some versions of glibc will convert F_GETOWN fcntl(2) calls into F_GETOWN_EX in
some cases.

PiperOrigin-RevId: 284089373
2019-12-05 17:28:52 -08:00
Bhasker Hariharan f053c52812 Reduce flakiness under gotsan runs.
TcpPortReuseMultiThread creates lots of connections which result in
a lot of goroutines in the sentry. This can cause gotsan runs to
take really long and timeout. Increasing listen backlog and
reducing number of connections should help the connections complete
faster as well as reduce the number of goroutines that gotsan needs
to track.

PiperOrigin-RevId: 284046018
2019-12-05 13:57:08 -08:00
Zach Koopmans 0a32c02357 Create correct file for /proc/[pid]/task/[tid]/io
PiperOrigin-RevId: 284038840
2019-12-05 13:24:05 -08:00
Jamie Liu 02258607f9 Add vfs.CheckSetStat() and its dependencies.
PiperOrigin-RevId: 284033820
2019-12-05 12:58:07 -08:00
Ghanan Gowripalan 10f7b109ab Add a type to represent the NDP Recursive DNS Server option
This change adds a type to represent the NDP Recursive DNS Server option, as
defined by RFC 8106 section 5.1.

PiperOrigin-RevId: 284005493
2019-12-05 10:41:45 -08:00
gVisor bot 05758f34b2 Explicitly export files needed by other packages
PiperOrigin-RevId: 283955946
2019-12-05 05:45:09 -08:00
Dean Deng 6ae64d7935 Allow syscall tests to run with hostinet.
Fixes #1207

PiperOrigin-RevId: 283914438
2019-12-04 23:45:49 -08:00
Fabricio Voznika 1eda90d084 Remove TODO since we don't plan to support debug registers
PiperOrigin-RevId: 283828423
2019-12-04 13:54:38 -08:00
Dean Deng 80b7ba0c97 Clean up readv_socket test suite.
Get rid of the SocketTest class, which is only extended by ReadvSocketTest.
Also, get rid of TCP sockets (which were unused anyway) from readv_socket.cc.
This is a very old test suite that isn't the right place for TCP loopback
tests.

PiperOrigin-RevId: 283672772
2019-12-03 19:42:20 -08:00
Fabricio Voznika bb641c5403 Point TODO to gvisor.dev
PiperOrigin-RevId: 283657725
2019-12-03 17:33:50 -08:00
dependabot[bot] 4c1fa402b3
Bump lodash in /benchmarks/workloads/node_template
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.15.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.15)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-04 01:31:08 +00:00
Andrei Vagin cf7f27c167 net/udp: return a local route address as the bound-to address
If the socket is bound to ANY and connected to a loopback address,
getsockname() has to return the loopback address. Without this fix,
getsockname() returns ANY.

PiperOrigin-RevId: 283647781
2019-12-03 16:32:13 -08:00
Zach Koopmans 0354071539 Fix printing /proc/[pid]/io for /proc/[pid]/task/[tid]/io.
PiperOrigin-RevId: 283630669
2019-12-03 15:07:49 -08:00
Bhasker Hariharan 27e2c4ddca Fix panic due to early transition to Closed.
The code in rcv.consumeSegment incorrectly transitions to
CLOSED state from LAST-ACK before the final ACK for the FIN.

Further if receiving a segment changes a socket to a closed state
then we should not invoke the sender as the socket is now closed
and sending any segments is incorrect.

PiperOrigin-RevId: 283625300
2019-12-03 14:41:55 -08:00
Andrei Vagin 43643752f0 strace: don't create a slice with a negative value
PiperOrigin-RevId: 283613824
2019-12-03 13:49:38 -08:00
Fabricio Voznika 154dcdec07 Remove watchdog TODO
I have not seen a false positive stuck task yet.
Biggest offender was whitelistfs which is going away.

PiperOrigin-RevId: 283613064
2019-12-03 13:44:06 -08:00
Fabricio Voznika 3e832bec1b Point TODOs to gvisor.dev
PiperOrigin-RevId: 283610781
2019-12-03 13:32:31 -08:00
Michael Pratt d7cc2480cb Add RunfilesPath to test_util
A few tests have their own ad-hoc implementations. Add a single common one.

PiperOrigin-RevId: 283601666
2019-12-03 12:47:03 -08:00
Zach Koopmans 812189664c Remove TODO for obsolete bug.
PiperOrigin-RevId: 283571456
2019-12-03 10:23:19 -08:00
Dean Deng 19b2d997ec Support IP_TOS and IPV6_TCLASS socket options for hostinet sockets.
There are two potential ways of sending a TOS byte with outgoing packets:
including a control message in sendmsg, or setting the IP_TOS/IPV6_TCLASS
socket options (for IPV4 and IPV6 respectively). This change lets hostinet
support the latter.

Fixes #1188

PiperOrigin-RevId: 283550925
2019-12-03 08:33:22 -08:00
Zach Koopmans ce32c06843 Import benchmark-tools to main repository.
This has adapted for use with bazel from the original commit
a26e93769ebefd82593a43e22fb13a09717cfa6d.

In particular, the style has been made consistent with internal python style
guidelines, and the packages (including the main entrypoint) have been
refactored in order to allow bazel testing targets.

PiperOrigin-RevId: 283484433
2019-12-02 22:53:26 -08:00
Ian Lewis 7ac46c5048 Allow non-unique UIDs in bazel docker containers
Allow non-unique UIDs in the bazel docker container in order to avoid failures
using host UIDs that are already present in the image.

Issue #1267

PiperOrigin-RevId: 283456369
2019-12-02 18:00:33 -08:00
Andrei Vagin b41277049c test/syscal: Don't skip ClockGettime.CputimeId
We skipped it due to the issue in the golang scheduler
which has been fixed in go1.13.

PiperOrigin-RevId: 283432226
2019-12-02 15:37:17 -08:00
Dean Deng 9194aab2aa Support sending IP_TOS and IPV6_TCLASS control messages with hostinet sockets.
There are two potential ways of sending a TOS byte with outgoing packets:
including a control message in sendmsg, or setting the IP_TOS/IPV6_TCLASS
socket options (for IPV4 and IPV6 respectively). This change lets hostinet
support the former.

PiperOrigin-RevId: 283346737
2019-12-02 08:40:16 -08:00
Jay Zhuang 1518f7fd38 Fix typo, s/Convertable/Convertible/g
PiperOrigin-RevId: 283345791
2019-12-02 08:33:43 -08:00
Jay Zhuang aa70523da2 Port tests in udp_socket.cc to Fuchsia
Separate out a test in udp_socket.cc that depends on <linux/errqueue.h> so the
rest of the tests can run on Fuchsia.

PiperOrigin-RevId: 283322633
2019-12-02 05:38:30 -08:00
Ghanan Gowripalan 10bbcf97d2 Test handling segments on completed but not yet accepted TCP connections
This change does not introduce any new features, or modify existing ones.

This change tests handling TCP segments right away for connections that were
completed from a listening endpoint.

PiperOrigin-RevId: 282986457
2019-11-28 17:15:07 -08:00
Dean Deng 684f757a22 Add support for receiving TOS and TCLASS control messages in hostinet.
This involves allowing getsockopt/setsockopt for the corresponding socket
options, as well as allowing hostinet to process control messages received from
the actual recvmsg syscall.

PiperOrigin-RevId: 282851425
2019-11-27 16:21:05 -08:00
Michael Pratt 58afb4be69 Add floating point exception tests
PiperOrigin-RevId: 282828273
2019-11-27 13:49:12 -08:00
Ian Lewis 20279c305e Allow open(O_TRUNC) and (f)truncate for proc files.
This allows writable proc and devices files to be opened with O_CREAT|O_TRUNC.
This is encountered most frequently when interacting with proc or devices files
via the command line.
e.g. $ echo 8192 1048576 4194304 > /proc/sys/net/ipv4/tcp_rmem

Also adds a test to test the behavior of open(O_TRUNC), truncate, and ftruncate
on named pipes.

Fixes #1116

PiperOrigin-RevId: 282677425
2019-11-26 18:21:09 -08:00
gVisor bot 4a620c436d Merge pull request #981 from tanjianfeng:fix-898
PiperOrigin-RevId: 282669859
2019-11-26 17:21:43 -08:00
Dean Deng 519ceabdf9 Mark execveat as supported for linux64_arm64.
PiperOrigin-RevId: 282667122
2019-11-26 17:03:26 -08:00
Jamie Liu b72e1b3c08 Minor VFS2 interface changes.
- Remove the Filesystem argument from DentryImpl.*Ref(); in general DentryImpls
  that need the Filesystem for reference counting will probably also need it
  for other interface methods that don't plumb Filesystem, so it's easier to
  just store a pointer to the filesystem in the DentryImpl.

- Add a pointer to the VirtualFilesystem to Filesystem, which is needed by the
  gofer client to disown dentries for cache eviction triggered by dentry
  reference count changes.

- Rename FilesystemType.NewFilesystem to GetFilesystem; in some cases (e.g.
  sysfs, cgroupfs) it's much cleaner for there to be only one Filesystem that
  is used by all mounts, and in at least one case (devtmpfs) it's visibly
  incorrect not to do so, so NewFilesystem doesn't always actually create and
  return a *new* Filesystem.

- Require callers of FileDescription.Init() to increment Mount/Dentry
  references. This is because the gofer client may, in the OpenAt() path, take
  a reference on a dentry with 0 references, which is safe due to
  synchronization that is outside the scope of this CL, and it would be safer
  to still have its implementation of DentryImpl.IncRef() check for an
  increment for 0 references in other cases.

- Add FileDescription.TryIncRef. This is used by the gofer client to take
  references on "special file descriptions" (FDs for files such as pipes,
  sockets, and devices), which use per-FD handles (fids) instead of
  dentry-shared handles, for sync() and syncfs().

PiperOrigin-RevId: 282473364
2019-11-25 18:10:31 -08:00
Jamie Liu 128948d6ae Implement basic umounting for vfs2.
This is required to test filesystems with a non-trivial implementation of
FilesystemImpl.Release(). Propagation isn't handled yet, and umount isn't yet
plumbed out to VirtualFilesystem.UmountAt(), but otherwise the implementation
of umount is believed to be correct.

- Move entering mountTable.seq writer critical sections to callers of
  mountTable.{insert,remove}Seqed. This is required since umount(2) must ensure
  that no new references are taken on the candidate mount after checking that
  it isn't busy, which is only possible by entering a vfs.mountTable.seq writer
  critical section before the check and remaining in it until after
  VFS.umountRecursiveLocked() is complete. (Linux does the same thing:
  fs/namespace.c:do_umount() => lock_mount_hash(),
  fs/pnode.c:propagate_mount_busy(), umount_tree(), unlock_mount_hash().)

- It's not possible for dentry deletion to umount while only holding
  VFS.mountMu for reading, but it's also very unappealing to hold VFS.mountMu
  exclusively around e.g. gofer unlink RPCs. Introduce dentry.mu to avoid these
  problems. This means that VFS.mountMu is never acquired for reading, so
  change it to a sync.Mutex.

PiperOrigin-RevId: 282444343
2019-11-25 15:21:49 -08:00
Adin Scannell d92dc065fd Fix typo in go_branch.sh script.
With the ticks, the command `master` is actually be run and the output included
(which is nothing). This is confusing, as we actually mean to say "master" in
the description of the Go branch.

PiperOrigin-RevId: 282426081
2019-11-25 13:53:27 -08:00
Fabricio Voznika 97d2c9a94e Use mount hints to determine FileAccessType
PiperOrigin-RevId: 282401165
2019-11-25 11:43:05 -08:00
Adin Scannell a5f7b82036 Internal change.
PiperOrigin-RevId: 282396322
2019-11-25 11:20:30 -08:00
gVisor bot 0416c247ec Merge pull request #1176 from xiaobo55x:runsc_boot
PiperOrigin-RevId: 282382564
2019-11-25 11:01:22 -08:00
Kevin Krakauer 1641338b14 Set transport and network headers on outbound packets.
These are necessary for iptables to read and parse headers for packet filtering.

PiperOrigin-RevId: 282372811
2019-11-25 09:37:53 -08:00