Commit Graph

1109 Commits

Author SHA1 Message Date
Ayush Ranjan 2eaf54dd59 Refactor tty codebase to use master-replica terminology.
Updates #2972

PiperOrigin-RevId: 329584905
2020-09-01 14:43:41 -07:00
Nayana Bidari 0eae08bc9e Automated rollback of changelist 328350576
PiperOrigin-RevId: 329526153
2020-09-01 09:54:55 -07:00
Zach Koopmans 6748438493 Fix bug in bazel build benchmark.
PiperOrigin-RevId: 329409802
2020-08-31 17:17:09 -07:00
Jay Zhuang 170560cec0 Set errno on response when syscall actually fails
This prevents setting stale errno on responses.

Also fixes TestDiscardsUDPPacketsWithMcastSourceAddressV6 to use correct
multicast addresses in test.

Fixes #3793

PiperOrigin-RevId: 329391155
2020-08-31 15:31:42 -07:00
Tamir Duberstein 9d0d82088a Remove __fuchsia__ defines
These mostly guard linux-only headers; check for linux instead.

PiperOrigin-RevId: 329362762
2020-08-31 13:10:56 -07:00
Rahat Mahmood a3d189301d Run syscall tests in uts namespaces.
Some syscall tests, namely uname_test_* modify the host and domain
name, which modifies the execution environment and can have unintended
consequences on other tests. For example, modifying the hostname
causes some networking tests to fail DNS lookups. Run all syscall
tests in their own uts namespaces to isolate these changes.

PiperOrigin-RevId: 329348127
2020-08-31 11:58:45 -07:00
Tamir Duberstein d3057717dc Include command output on error
Currently the logs produce

  TestOne: packetimpact_test.go:182: listing devices on ... container: process terminated with status: 126

which is not actionable; presumably the `ip` command output is interesting.

PiperOrigin-RevId: 329032105
2020-08-28 16:45:18 -07:00
Ghanan Gowripalan d5787f628c Don't bind loopback to all IPs in an IPv6 subnet
An earlier change considered the loopback bound to all addresses in an
assigned subnet. This should have only be done for IPv4 to maintain
compatability with Linux:

```
$ ip addr show dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group ...
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
$ ping 2001:db8::1
PING 2001:db8::1(2001:db8::1) 56 data bytes
^C
--- 2001:db8::1 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3062ms

$ ping 2001:db8::2
PING 2001:db8::2(2001:db8::2) 56 data bytes
^C
--- 2001:db8::2 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2030ms

$ sudo ip addr add 2001:db8::1/64 dev lo
$ ping 2001:db8::1
PING 2001:db8::1(2001:db8::1) 56 data bytes
64 bytes from 2001:db8::1: icmp_seq=1 ttl=64 time=0.055 ms
64 bytes from 2001:db8::1: icmp_seq=2 ttl=64 time=0.074 ms
64 bytes from 2001:db8::1: icmp_seq=3 ttl=64 time=0.073 ms
64 bytes from 2001:db8::1: icmp_seq=4 ttl=64 time=0.071 ms
^C
--- 2001:db8::1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3075ms
rtt min/avg/max/mdev = 0.055/0.068/0.074/0.007 ms
$ ping 2001:db8::2
PING 2001:db8::2(2001:db8::2) 56 data bytes
From 2001:db8::1 icmp_seq=1 Destination unreachable: No route
From 2001:db8::1 icmp_seq=2 Destination unreachable: No route
From 2001:db8::1 icmp_seq=3 Destination unreachable: No route
From 2001:db8::1 icmp_seq=4 Destination unreachable: No route
^C
--- 2001:db8::2 ping statistics ---
4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 3070ms
```

Test: integration_test.TestLoopbackAcceptAllInSubnet
PiperOrigin-RevId: 329011566
2020-08-28 14:39:30 -07:00
Rahat Mahmood b4820e5986 Implement StatFS for various VFS2 filesystems.
This mainly involved enabling kernfs' client filesystems to provide a
StatFS implementation.

Fixes #3411, #3515.

PiperOrigin-RevId: 329009864
2020-08-28 14:31:11 -07:00
Dean Deng 8b9cb36d1c Fix EOF handling for splice.
Also, add corresponding EOF tests for splice/sendfile.

Discovered by syzkaller.

PiperOrigin-RevId: 328975990
2020-08-28 11:28:28 -07:00
Kevin Krakauer b3ff31d041 fix panic when calling SO_ORIGINAL_DST without initializing iptables
Reported-by: syzbot+074ec22c42305725b79f@syzkaller.appspotmail.com
PiperOrigin-RevId: 328963899
2020-08-28 10:35:18 -07:00
Tamir Duberstein 7bc9f9b47f Add test demonstrating accept bug
Updates #3780.

PiperOrigin-RevId: 328922573
2020-08-28 05:33:49 -07:00
Dean Deng 84f04909c2 Fix vfs2 pipe behavior when splicing to a non-pipe.
Fixes *.sh Java runtime tests, where splice()-ing from a pipe to /dev/zero
would not actually empty the pipe.

There was no guarantee that the data would actually be consumed on a splice
operation unless the output file's implementation of Write/PWrite actually
called VFSPipeFD.CopyIn. Now, whatever bytes are "written" are consumed
regardless of whether CopyIn is called or not.

Furthermore, the number of bytes in the IOSequence for reads is now capped at
the amount of data actually available. Before, splicing to /dev/zero would
always return the requested splice size without taking the actual available
data into account.

This change also refactors the case where an input file is spliced into an
output pipe so that it follows a similar pattern, which is arguably cleaner
anyway.

Updates #3576.

PiperOrigin-RevId: 328843954
2020-08-27 16:57:40 -07:00
Andrei Vagin dc008fbbcc unix: return ECONNREFUSE if a socket file exists but a socket isn't bound to it
PiperOrigin-RevId: 328843560
2020-08-27 16:52:02 -07:00
gVisor bot 29d528399c Merge pull request #3077 from jinmouil:beef-write-syscall
PiperOrigin-RevId: 328824023
2020-08-27 15:03:40 -07:00
Zach Koopmans 26c588f063 Fix BadSocketPair for open source.
BadSocketPair test will return several errnos (EPREM, ESOCKTNOSUPPORT,
EAFNOSUPPORT) meaning the test is just too specific. Checking the syscall
fails is appropriate.

PiperOrigin-RevId: 328813071
2020-08-27 14:11:23 -07:00
Ghanan Gowripalan a5f1e74260 Skip IPv6UDPUnboundSocketNetlinkTest on native linux
...while we figure out of we want to consider the loopback interface
bound to all IPs in an assigned IPv6 subnet, or not (to maintain
compatibility with Linux).

PiperOrigin-RevId: 328807974
2020-08-27 13:45:36 -07:00
Kevin Krakauer 01a35a2f19 ip6tables: (de)serialize ip6tables structs
More implementation+testing to follow.

#3549.

PiperOrigin-RevId: 328770160
2020-08-27 10:53:49 -07:00
Zach Koopmans 140ffb6007 Fix JobControl tests for open source.
ioctl calls with TIOCSCTTY fail if the calling process already has a
controlling terminal, which occurs on a 5.4 kernel like our Ubuntu 18 CI.
Thus, run tests calling ioctl TTOCSCTTY in clean subprocess.

Also, while we're here, switch out non-inclusive master/slave for main/replica.

PiperOrigin-RevId: 328756598
2020-08-27 09:52:49 -07:00
Jinmou Li 5c491164f9 beef up write syscall tests
Added a few tests for write(2) and pwrite(2)

1. Regular Files

For write(2)

- write zero bytes should not move the offset
- write non-zero bytes should increment the offset the exact amount
- write non-zero bytes after a lseek() should move the offset the exact amount after the seek
- write non-zero bytes with O_APPEND should move the offset the exact amount after original EOF

For pwrite(2), offset is not affected when

- pwrite zero bytes
- pwrite non-zero bytes

For EOF, added a test asserting the EOF (indicated by lseek(SEEK_END)) is updated properly after writing non-zero bytes

2. Symlink

Added one pwite64() call for symlink that is written as a counterpart of the existing test using pread64()
2020-08-26 22:54:03 +00:00
Ayush Ranjan b03e0ee802 [runtime-tests] Exclude flaky nodejs test.
PiperOrigin-RevId: 328579755
2020-08-26 12:11:43 -07:00
Nicolas Lacasse 83a8b309e9 tmpfs: Allow xattrs in the trusted namespace if creds has CAP_SYS_ADMIN.
This is needed to support the overlay opaque attribute.

PiperOrigin-RevId: 328552985
2020-08-26 10:05:34 -07:00
Zach Koopmans ebf5293374 Fix SocketPairTest and BadSocketPairTest in opensource.
PiperOrigin-RevId: 328467152
2020-08-25 22:03:04 -07:00
Dean Deng cb573c8e0b Expose basic coverage information to userspace through kcov interface.
In Linux, a kernel configuration is set that compiles the kernel with a
custom function that is called at the beginning of every basic block, which
updates the memory-mapped coverage information. The Go coverage tool does not
allow us to inject arbitrary instructions into basic blocks, but it does
provide data that we can convert to a kcov-like format and transfer them to
userspace through a memory mapping.

Note that this is not a strict implementation of kcov, which is especially
tricky to do because we do not have the same coverage tools available in Go
that that are available for the actual Linux kernel. In Linux, a kernel
configuration is set that compiles the kernel with a custom function that is
called at the beginning of every basic block to write program counters to the
kcov memory mapping. In Go, however, coverage tools only give us a count of
basic blocks as they are executed. Every time we return to userspace, we
collect the coverage information and write out PCs for each block that was
executed, providing userspace with the illusion that the kcov data is always
up to date. For convenience, we also generate a unique synthetic PC for each
block instead of using actual PCs. Finally, we do not provide thread-specific
coverage data (each kcov instance only contains PCs executed by the thread
owning it); instead, we will supply data for any file specified by --
instrumentation_filter.

Also, fix issue in nogo that was causing pkg/coverage:coverage_nogo
compilation to fail.

PiperOrigin-RevId: 328426526
2020-08-25 16:28:45 -07:00
Jamie Liu bee07a2d68 Link to PHP bug for disabled disk space tests.
PiperOrigin-RevId: 328410399
2020-08-25 15:06:57 -07:00
Kevin Krakauer 3cba0a41d9 remove iptables sockopt special cases
iptables sockopts were kludged into an unnecessary check, this properly
relegates them to the {get,set}SockOptIP functions.

PiperOrigin-RevId: 328395135
2020-08-25 13:43:26 -07:00
Adin Scannell b0c53f8475 Add nogo support to go_binary and go_test targets.
Updates #3374

PiperOrigin-RevId: 328378700
2020-08-25 12:18:25 -07:00
Nayana Bidari b26f7503b5 Support SO_LINGER socket option.
When SO_LINGER option is enabled, the close will not return until all the
queued messages are sent and acknowledged for the socket or linger timeout is
reached. If the option is not set, close will return immediately. This option
is mainly supported for connection oriented protocols such as TCP.

PiperOrigin-RevId: 328350576
2020-08-25 10:04:07 -07:00
Jamie Liu 10fa583c36 Disable PHP disk space tests.
These tests print disk_free_space()/disk_total_space() and expect the printed
result to be an integer (despite the fact that both the documented and returned
type is float). After cl/297213789, free/total disk space on tmpfs is
sufficiently large that PHP prints the result in scientific notation instead:

        ========DIFF========
        012+ float(9.2233720368548E+18)
        013+ float(9.2233720368548E+18)
        012- float(%d)
        013- float(%d)
        ========DONE========
        FAIL disk_total_space() and disk_free_space() tests [ext/standard/tests/file/disk.phpt]

PiperOrigin-RevId: 328349906
2020-08-25 09:57:59 -07:00
Bhasker Hariharan ae332d96e4 Fix TCP_LINGER2 behavior to match linux.
We still deviate a bit from linux in how long we will actually wait in
FIN-WAIT-2. Linux seems to cap it with TIME_WAIT_LEN and it's not completely
obvious as to why it's done that way. For now I think we can ignore that and
fix it if it really is an issue.

PiperOrigin-RevId: 328324922
2020-08-25 07:17:32 -07:00
Ghanan Gowripalan 339d266be4 Consider loopback bound to all addresses in subnet
When a loopback interface is configurd with an address and associated
subnet, the loopback should treat all addresses in that subnet as an
address it owns.

This is mimicking linux behaviour as seen below:
```
$ ip addr show dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group ...
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
$ ping 192.0.2.1
PING 192.0.2.1 (192.0.2.1) 56(84) bytes of data.
^C
--- 192.0.2.1 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1018ms

$ ping 192.0.2.2
PING 192.0.2.2 (192.0.2.2) 56(84) bytes of data.
^C
--- 192.0.2.2 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2039ms

$ sudo ip addr add 192.0.2.1/24 dev lo
$ ip addr show dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group ...
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet 192.0.2.1/24 scope global lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
$ ping 192.0.2.1
PING 192.0.2.1 (192.0.2.1) 56(84) bytes of data.
64 bytes from 192.0.2.1: icmp_seq=1 ttl=64 time=0.131 ms
64 bytes from 192.0.2.1: icmp_seq=2 ttl=64 time=0.046 ms
64 bytes from 192.0.2.1: icmp_seq=3 ttl=64 time=0.048 ms
^C
--- 192.0.2.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2042ms
rtt min/avg/max/mdev = 0.046/0.075/0.131/0.039 ms
$ ping 192.0.2.2
PING 192.0.2.2 (192.0.2.2) 56(84) bytes of data.
64 bytes from 192.0.2.2: icmp_seq=1 ttl=64 time=0.131 ms
64 bytes from 192.0.2.2: icmp_seq=2 ttl=64 time=0.069 ms
64 bytes from 192.0.2.2: icmp_seq=3 ttl=64 time=0.049 ms
64 bytes from 192.0.2.2: icmp_seq=4 ttl=64 time=0.035 ms
^C
--- 192.0.2.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3049ms
rtt min/avg/max/mdev = 0.035/0.071/0.131/0.036 ms
```

Test: integration_test.TestLoopbackAcceptAllInSubnet
PiperOrigin-RevId: 328188546
2020-08-24 12:28:35 -07:00
gVisor bot 89791a79bf Internal change.
PiperOrigin-RevId: 328157101
2020-08-24 09:51:32 -07:00
Mithun Iyer 69008b68b0 Add syscall tests for SO_REUSEADDR.
Add tests for socket re-bind/listen of client and server sockets
with the older connection still in TIME_WAIT state and with
SO_REUSEADDR enabled.

PiperOrigin-RevId: 327924702
2020-08-21 22:49:16 -07:00
Ting-Yu Wang bd3383a7e2 Move udp port exhaustion tests to a 'nogotsan' one.
It frequently times out under GoTSAN.

PiperOrigin-RevId: 327894343
2020-08-21 16:34:50 -07:00
Zach Koopmans c9e752b644 Fix Inotify tests in open source.
The order of unlink events (dir event/file event) is undefined,
so make tests accept both orderings.

PiperOrigin-RevId: 327873316
2020-08-21 14:21:44 -07:00
Zach Koopmans c24db90be5 Skip ElfInterpreterStaticTest for 5.X kernels.
gVisor emulates 4.6 kernel versions, and test doesn't work on 5.0 versions
(observed on our Ubuntu18.04 image). Skip it.

PiperOrigin-RevId: 327845037
2020-08-21 11:39:04 -07:00
Nicolas Lacasse 0324b94a73 Skip socket stress tests on KVM platform.
They time out.

PiperOrigin-RevId: 327830892
2020-08-21 10:23:43 -07:00
Fabricio Voznika e8a25a2834 Enable strace+debug in syscall tests
This is done to ease troubleshooting when tests fail. runsc
logs are not stored when tests passe, so this will only
affect failing tests and should not increase log storage
too badly.

PiperOrigin-RevId: 327717551
2020-08-20 16:19:10 -07:00
Bhasker Hariharan f12b545d8f Skip listening TCP ports when trying to bind a free port.
PiperOrigin-RevId: 327686558
2020-08-20 13:25:23 -07:00
Zach Koopmans f8a9483002 Fix return for rseq_test.
Accept 128 + SIGNAL as well as SIGNAL as valid
returns for fork/exec tests.

Also, make changes so that test compiles in opensource. Test
had compile errors on latest Ubuntu 16.04 image with updated bazel to
3.4.0 (as well as base 2.0) used for Kokoro tests.

PiperOrigin-RevId: 327510310
2020-08-19 14:46:55 -07:00
Kevin Krakauer 5cf330106a ip6tables: test initial state
Tests that we have the correct initial (empty) state for ip6tables.

#3549

PiperOrigin-RevId: 327477657
2020-08-19 12:03:34 -07:00
Zach Koopmans 3331722291 Skip ECN test for native/linux tests.
Skip check for ECN bits in native/linux tests. General advice
for the ECN field is to leave the setting to the kernel, so
behavior of the test is undefined for different kernels.

http://www.masterraghu.com/subjects/np/introduction/unix_network_programming_v1.3/ch07lev1sec6.html

PiperOrigin-RevId: 327451414
2020-08-19 09:51:04 -07:00
Dean Deng 33c60b893f Return appropriate errors when file locking is unsuccessful.
test_eintr now passes in the Python runtime tests.

Updates #3515.

PiperOrigin-RevId: 327441081
2020-08-19 08:53:12 -07:00
Zach Koopmans f6d2490482 Fix return value in shm_test for opensource
Some machines return 128 + signal for failures. Accept that
as a valid result.

PiperOrigin-RevId: 327326113
2020-08-18 16:07:35 -07:00
Zach Koopmans 4141dc0d2c Fix timeval for Socket test
tv_usec field should be a multiple of 4K to pass
in open source on linux/native, so make it one.

PiperOrigin-RevId: 327288405
2020-08-18 12:56:44 -07:00
Zach Koopmans 673b6cc7fc Fix readahead test for opensource.
Skip InvalidOffset and InvalidLength for Linux as the test is invalid for
later Kernel versions.

Add UnsupportedFile test as this check is in all kernel versions.

PiperOrigin-RevId: 327248035
2020-08-18 10:02:27 -07:00
Zach Koopmans da5c2ea6dc Fix return value for MMap Tests in OpenSource
Some systems return 128 + errno instead of just errno, which is the case
here.

PiperOrigin-RevId: 327247836
2020-08-18 09:54:48 -07:00
Ian Lewis ac324f646e
Merge branch 'master' into ip-forwarding
- Merges aleksej-paschenko's with HEAD
- Adds vfs2 support for ip_forward
2020-08-17 21:44:31 -04:00
Zach Koopmans 988ab27058 Fix AllSocketPairTest for open source.
Setting timeouts for sockets on GCP images (debian) for usecs only
respects multiples of 4K. Set the test with a multiple of 4K with a comment.

PiperOrigin-RevId: 327093848
2020-08-17 14:04:20 -07:00
Ayush Ranjan e3e1b36896 [vfs] Do O_DIRECTORY check after resolving symlinks.
Fixes python runtime test test_glob.
Updates #3515

We were checking is the to-be-opened dentry is a dir or not before resolving
symlinks. We should check that after resolving symlinks.
This was preventing us from opening a symlink which pointed to a directory
with O_DIRECTORY.

Also added this check in tmpfs and removed a duplicate check.

PiperOrigin-RevId: 327085895
2020-08-17 13:26:31 -07:00
Nayana Bidari af433e159d Update README for packetimpact
PiperOrigin-RevId: 326733912
2020-08-14 14:49:14 -07:00
gVisor bot 3be8b49c70 Merge pull request #3375 from kevinGC:ipt-test-early-return
PiperOrigin-RevId: 326693922
2020-08-14 11:24:56 -07:00
Zach Koopmans e6ea59203b Skip UDPMulticast Tests when net interfaces aren't found.
PiperOrigin-RevId: 326686761
2020-08-14 10:53:04 -07:00
Julian Elischer 190634e0fc Give the ICMP Code its own type
This is  a preparatory commit for a larger commit working on
ICMP generation in error cases.
This is removal of technical debt and cleanup in the gvisor code
as part of gvisor issue 2211.

Updates #2211.

PiperOrigin-RevId: 326615389
2020-08-14 02:07:36 -07:00
Ayush Ranjan d6520e1d05 [vfs2][gofer] Fix file creation flags sent to gofer.
Fixes php runtime test ext/standard/tests/file/readfile_basic.phpt
Fixes #3516

fsgofers only want the access mode in the OpenFlags passed to Create(). If more
flags are supplied (like O_APPEND in this case), read/write from that fd will
fail with EBADF. See runsc/fsgofer/fsgofer.go:WriteAt()
VFS2 was providing more than just access modes. So filtering the flags using
p9.OpenFlagsModeMask == linux.O_ACCMODE fixes the issue.

Gofer in VFS1 also only extracts the access mode flags while making the create
RPC. See pkg/sentry/fs/gofer/path.go:Create()

Even in VFS2, when we open a handle, we extract out only the access mode flags
+ O_TRUNC.
See third_party/gvisor/pkg/sentry/fsimpl/gofer/handle.go:openHandle()

Added a test for this.

PiperOrigin-RevId: 326574829
2020-08-13 19:33:56 -07:00
Ayush Ranjan 5036f135e4 Disable vfs2 for socket_stress_test.
PiperOrigin-RevId: 326553620
2020-08-13 16:58:43 -07:00
Bhasker Hariharan b928d074b4 Ensure TCP TIME-WAIT is not terminated prematurely.
Netstack's TIME-WAIT state for a TCP socket could be terminated prematurely if
the socket entered TIME-WAIT using shutdown(..., SHUT_RDWR) and then was closed
using close(). This fixes that bug and updates the tests to verify that Netstack
correctly honors TIME-WAIT under such conditions.

Fixes #3106

PiperOrigin-RevId: 326456443
2020-08-13 09:04:31 -07:00
Ayush Ranjan 42b610d567 [vfs2][gofer] Return appropriate errors when opening and creating files.
Fixes php test ext/standard/tests/file/touch_variation5.phpt on vfs2.
Updates #3516

Also spotted a bug with O_EXCL, where we did not return EEXIST when we tried
to open the root of the filesystem with O_EXCL | O_CREAT.

Added some more tests for open() corner cases.

PiperOrigin-RevId: 326346863
2020-08-12 17:19:09 -07:00
gVisor bot e6df6222ac Merge pull request #3250 from craig08:fuse-getattr
PiperOrigin-RevId: 326313858
2020-08-12 14:36:04 -07:00
Fabricio Voznika 00b684ea7f Limit the scope when deleting test log directory on success
The code was deleting logs for all tests when a single test
passed. Change it to delete only the logs relevant to the
test at hand.

Also fixed the benchmark lookup code, which was always generating
a single empty benchmark entry if there were not benchmarks.

PiperOrigin-RevId: 326311477
2020-08-12 14:23:29 -07:00
Zach Koopmans 89f3197fc3 Mark integration tests as passing in VFS2 except CheckpointRestore.
Mark all tests passing for VFS2 in:
image_test
integration_test

There's no way to do negative look ahead/behind in golang test regex,
so check if the tests uses VFS2 and skip CheckPointRestore if it does.

PiperOrigin-RevId: 326050915
2020-08-11 10:37:32 -07:00
Craig Chi 51e64d2fc5 Implement FUSE_GETATTR
FUSE_GETATTR is called when a stat(2), fstat(2), or lstat(2) is issued
from VFS2 layer to a FUSE filesystem.

Fixes #3175
2020-08-10 18:15:32 -07:00
Kevin Krakauer 805a96d7ba Speed up iptables tests
//test/iptables:iptables_test runs 30 seconds faster on my machine.

* Using contexts instead of many smaller timeouts makes the tests less
  likely to flake and removes unnecessary complexity.
* We also use context to properly shut down concurrent goroutines and
  the test container.
* Container logs are always logged.
2020-08-10 17:50:01 -07:00
Ghanan Gowripalan 0a8ae4b32f Populate IPPacketInfo with destination address
IPPacketInfo.DestinationAddr should hold the destination of the IP
packet, not the source. This change fixes that bug.

PiperOrigin-RevId: 325910766
2020-08-10 16:22:31 -07:00
Ayush Ranjan a1af46c20a Enable VFS2 by default for all syscall tests.
Fixes #2923

PiperOrigin-RevId: 325904734
2020-08-10 15:50:22 -07:00
Zach Koopmans a88cf5a2e1 Add benchmarks to continuous build.
PiperOrigin-RevId: 325892974
2020-08-10 14:52:36 -07:00
Zach Koopmans 80c80a1410 Remove old benchmark tools.
Remove the old benchmark-tools directory, including
imports in the WORKSPACE file and associated bazel rules.

The new Golang benchmark-tools can be found at //test/benchmarks
and it is functionally equivalent, excepting syscall_test
which can be found in //test/perf/linux.

PiperOrigin-RevId: 325529075
2020-08-07 16:18:51 -07:00
Zach Koopmans 7b9bfc0ce0 Port Ruby benchmark.
PiperOrigin-RevId: 325500772
2020-08-07 13:49:07 -07:00
Zach Koopmans a7bd0a7012 Port Startup and Density Benchmarks.
PiperOrigin-RevId: 325497346
2020-08-07 13:30:39 -07:00
Andrei Vagin 10c13bccaf tcp: change the limit of TCP_LINGER2
It was changed in the Linux kernel:

commit f0628c524fd188c3f9418e12478dfdfadacba815
Date:   Fri Apr 24 16:06:16 2020 +0800
net: Replace the limit of TCP_LINGER2 with TCP_FIN_TIMEOUT_MAX
PiperOrigin-RevId: 325493859
2020-08-07 13:10:29 -07:00
Jamie Liu 93cb66825b Support separate read/write handles in fsimpl/gofer.dentry.
PiperOrigin-RevId: 325490674
2020-08-07 12:56:12 -07:00
Ayush Ranjan 293f11ca95 [runtime tests] Exclude flaky/failing tests
PiperOrigin-RevId: 325481011
2020-08-07 12:07:46 -07:00
Jamie Liu 8c1573ebab Tolerate EINTR from fallocate() in inotify test.
PiperOrigin-RevId: 325472312
2020-08-07 11:26:20 -07:00
Fabricio Voznika f20e63e31b Add LinkAt support to gofer
Updates #1198

PiperOrigin-RevId: 325350818
2020-08-06 18:16:21 -07:00
Adin Scannell 90021e775a Add bzl_library rules for .bzl files without one.
PiperOrigin-RevId: 325280924
2020-08-06 12:10:49 -07:00
gVisor bot 0d69bfa8aa Merge pull request #3511 from amscanne:packetimpact-tests
PiperOrigin-RevId: 325269275
2020-08-06 11:30:03 -07:00
Ayush Ranjan 72b528c840 [runtime tests] Exclude failing python and java tests
test_httplib was un-excluded in cl/325137657. Exclude it again.
test_httplib fails consistently when running in a kokoro job. Could not repro
with Docker.

There are some java tests that pass locally on Docker but fail when running
within a kokoro job.

Also make shard count a multiple of 8 to minimize idle cores and minimize test
time.

PiperOrigin-RevId: 325267071
2020-08-06 11:08:50 -07:00
Ghanan Gowripalan fc4dd3ef45 Join IPv4 all-systems group on NIC enable
Test:
- stack_test.TestJoinLeaveMulticastOnNICEnableDisable
- integration_test.TestIncomingMulticastAndBroadcast
PiperOrigin-RevId: 325185259
2020-08-06 01:32:21 -07:00
Nayana Bidari 35312a95c4 Add loss recovery option for TCP.
/proc/sys/net/ipv4/tcp_recovery is used to enable RACK loss
recovery in TCP.

PiperOrigin-RevId: 325157807
2020-08-05 20:50:06 -07:00
Ayush Ranjan ce463c027b [runtime tests] Update python tests.
- un-exclude passing tests to increase testing surface.
- create/update bugs for tests that fail on runsc but pass on runc.

PiperOrigin-RevId: 325137657
2020-08-05 17:48:07 -07:00
gVisor bot 34d302cb8a Merge pull request #3502 from craig08:fuse-integration-test-fix-connection-refused
PiperOrigin-RevId: 325080329
2020-08-05 12:47:55 -07:00
Ayush Ranjan d0127b23f2 [runtime tests] Update bugs and un-exclude passing tests.
PiperOrigin-RevId: 325045486
2020-08-05 10:23:12 -07:00
Adin Scannell c5f5806fe6 Enable "make packetimpact-tests" to work.
This required minor fixes to the bazel wrapper. The "dut_platform" is
also changed to "native" to line-up with the system call tests and
remove the hard-coded "linux" and "netstack" strings.
2020-08-04 20:49:00 -07:00
Ayush Ranjan 338f96b36c [runtime tests] Exclude flaky tests.
PiperOrigin-RevId: 324923599
2020-08-04 17:20:24 -07:00
Zach Koopmans be7079578e Port sysbench benchmark.
PiperOrigin-RevId: 324918229
2020-08-04 16:51:04 -07:00
Craig Chi 9094adfc27 Fix FUSE integration test failed with ECONNREFUSED
The newer version of FUSE_INIT checks the response from the FUSE server
if its major number is equal to 7. If it's not, then FUSE_INIT fails and
further filesystem operations will get ECONNREFUSED. To mitigate this
issue, we can send back a response with major version equals to 7 when
consuming the first FUSE_INIT request.

Fixes #3500
2020-08-04 14:48:37 -07:00
gVisor bot af2f456735 Merge pull request #3320 from craig08:fuse-integration-test
PiperOrigin-RevId: 324877577
2020-08-04 13:25:40 -07:00
Craig Chi 21d0334e7f Add FUSE integration test
This commit adds an integration test framework for FUSE support. Please
refer to the test example and test/fuse/README.md for further details.

Fixes #3098
2020-08-04 12:27:55 -07:00
Ayush Ranjan 7dfcf727a5 [runtime tests] Fix nodejs runtime tests.
- Exclude flaky tests.
- Bump timeout.
- Un-exclude passing tests to increase testing surface.
- Create/Update bugs for tests that pass on runc but fail on runsc.

PiperOrigin-RevId: 324830840
2020-08-04 09:51:13 -07:00
Bhasker Hariharan 1bdadbc4f8 Fix broken httpd_test.
PiperOrigin-RevId: 324822613
2020-08-04 09:07:09 -07:00
Dean Deng b5c9ff8192 Exclude flaky nodejs runtime test.
PiperOrigin-RevId: 324738840
2020-08-03 20:32:23 -07:00
Dean Deng 1fbbc795ef Add inotify events for fallocate and tests for fallocate/sendfile.
Updates #1479, #2923.

PiperOrigin-RevId: 324658826
2020-08-03 12:36:14 -07:00
gVisor bot 07267fc4c0 Merge pull request #3469 from craig08:fuse-fix-test-mount-failed
PiperOrigin-RevId: 324657612
2020-08-03 12:27:03 -07:00
Bhasker Hariharan 1a93a78d10 Add support for a reverse HTTPD test.
This change adds a new reverse HTTP test where the HTTPD server runs
in a native container but the client runs inside gVisor. It allows
us to test download performance under varying levels of concurrency.

Also tweaks the concurrent request numbers to test for high levels
of concurrency.

PiperOrigin-RevId: 324651203
2020-08-03 12:00:01 -07:00
Craig Chi e76c3c1064 Fix MountFuseFilesystem tests failing
Before kernel version 4.16-rc6, fuse mount is protected by
capable(CAP_SYS_ADMIN). After this version, it uses
ns_capable(CAP_SYS_ADMIN) to protect. Before the 4.16 kernel,
it was not allowed to mount fuse file systems without the
global CAP_SYS_ADMIN.

Fixes #3360
2020-07-31 16:18:40 -07:00
Andrei Vagin fd5f4ffed1 test/socket_netlink_route: check that there is a route on local or main tables
A new network namespace has only the local route table.

PiperOrigin-RevId: 324303629
2020-07-31 16:14:06 -07:00
Ayush Ranjan 12a6657d9c [runtime tests] Enhance java runtime test.
- Added a bunch of helpful options which help in speeding up the test and
  providing useful output.
- Unexcluded passing tests and updated bugs. Excluded tests which were failing.
- Increased the batch size for java tests so that we can take advantage of
  the shared JVMs.

The running time of the tests decreased from 3+ hours (I don't know the exact
running time because this test has always timed out after 3 hours) to 1 hour
15 minutes. We can reliably run this a CI kokoro job.

PiperOrigin-RevId: 324301503
2020-07-31 16:01:36 -07:00
gVisor bot b22c2ab1d7 Merge pull request #3348 from kevinGC:so-orig-dst
PiperOrigin-RevId: 324279280
2020-07-31 14:01:03 -07:00
Kevin Krakauer 5d2b09b71d s/github.dev/gvisor.dev
PiperOrigin-RevId: 324249991
2020-07-31 11:40:12 -07:00
Kevin Krakauer 2a7b2a61e3 iptables: support SO_ORIGINAL_DST
Envoy (#170) uses this to get the original destination of redirected
packets.
2020-07-31 10:47:26 -07:00
Zach Koopmans 98f9527c04 Port nginx and move parsers to own package.
This change:
- Ports the nginx benchmark.
- Switches the Httpd benchmark to use 'hey' as a client.
- Moves all parsers to their own package 'tools'.

Parsers are moved to their own package because 1) parsing output of a command
is often dependent on the format of the command (e.g. 'fio --json'), 2) to
enable easier reuse, and 3) clean up and simplify actual running benchmarks
(no TestParser functions and ugly sample output in benchmark files).

PiperOrigin-RevId: 324144165
2020-07-30 21:17:45 -07:00
Jamie Liu 1b11326ecd Call lseek(0, SEEK_CUR) unconditionally in runsc fsgofer's Readdir(offset=0).
9P2000.L is silent as to how readdir RPCs interact with directory mutation. The
most performant option is for Treaddir with offset=0 to restart iteration,
avoiding needing to walk+open+clunk a new directory fid between invocations of
getdents64(2), and the VFS2 gofer client assumes this is the case. Make this
actually true for the runsc fsgofer.

Fixes #3344, #3345, #3355

PiperOrigin-RevId: 324090384
2020-07-30 15:02:22 -07:00
Jamie Liu 3c70b4c986 Implement overlayfs_stale_read for vfs2.
PiperOrigin-RevId: 324080111
2020-07-30 14:18:11 -07:00
Zach Koopmans 78f1a18ab3 Add runsc build benchmark.
PiperOrigin-RevId: 324071377
2020-07-30 13:37:21 -07:00
Dean Deng c43305731e Fix SETOWN_EX return value.
Return on success should be 0, not size of the struct copied out.

PiperOrigin-RevId: 324029193
2020-07-30 10:27:44 -07:00
Ayush Ranjan f7281902f8 [runtime tests] go language test enhancement
- Unexported some passing tests. This will increase the testing surface and
  will be especially helpful when this is enabled for vfs2.
- Run tool tests with -v (verbose output). We only print the output when a test
  fails so this should not clutter the output.
- Run tool tests with "-no-rebuild" flag.
- Surround test name with appropriate regex, i.e. ^testname$. This will ensure
  that only that test is run. Earlier running go_test:os would also run
  go_test:os/exec, go_test:os/signal, go_test:os/user. This should help speed
  up the tests as we do not run the same test multiple times anymore.
- Updated bugs.

Updates #3191

PiperOrigin-RevId: 324028878
2020-07-30 10:26:09 -07:00
Zach Koopmans 2775ecd931 Update call in Node benchmark.
PiperOrigin-RevId: 324028183
2020-07-30 10:19:14 -07:00
Adin Scannell 84496b3a61 Disable consistently failing test.
PiperOrigin-RevId: 324017310
2020-07-30 09:25:58 -07:00
Jamie Liu 4cd4759238 Force registration for EPOLLHUP, not EPOLLRDHUP, in vfs2's epoll.
Compare Linux's fs/eventpoll.c:do_epoll_ctl(). I don't know where EPOLLRDHUP
came from.

PiperOrigin-RevId: 323874419
2020-07-29 14:57:48 -07:00
Zach Koopmans 1715896fc8 Port fio benchmark
PiperOrigin-RevId: 323810654
2020-07-29 10:15:53 -07:00
Zach Koopmans 6b4e11ab50 Port node benchmark.
PiperOrigin-RevId: 323810235
2020-07-29 10:06:38 -07:00
Jay Zhuang a6b4538ae0 Test UDP socket bound to ANY can receive unicast
PiperOrigin-RevId: 323773771
2020-07-29 06:23:23 -07:00
Fabricio Voznika f82dd8ddb4 Redirect TODO to GitHub issues
PiperOrigin-RevId: 323715260
2020-07-28 21:24:26 -07:00
gVisor bot 1e829a7c86 Merge pull request #3025 from kevinGC:ipv6-iptables-testing2
PiperOrigin-RevId: 323692144
2020-07-28 18:01:54 -07:00
Zach Koopmans 5873b0f43f Port tensorflow benchmark.
PiperOrigin-RevId: 323633737
2020-07-28 12:56:06 -07:00
Ayush Ranjan 15d13e3398 [Runtime Tests] Exclude flaky/failing tests
PiperOrigin-RevId: 323632510
2020-07-28 12:47:12 -07:00
Kevin Krakauer d9c9420335 ip6tables testing
We skip gVisor tests for now, as ip6tables aren't yet implemented.
2020-07-28 10:51:14 -07:00
Jay Zhuang 487b0905a4 More test cases on receiving UDP mcast/bcast
PiperOrigin-RevId: 323553832
2020-07-28 05:30:02 -07:00
Rahat Mahmood c8fa685cb6 Fix when FUSE tests need to be skipped due to sentry configuration.
PiperOrigin-RevId: 323426851
2020-07-27 13:26:23 -07:00
gVisor bot c40a3304e4 Merge pull request #3371 from kevinGC:ipt-tests-udp-faster
PiperOrigin-RevId: 323426155
2020-07-27 13:18:17 -07:00
gVisor bot 1876225fc8 Merge pull request #3377 from kevinGC:native-tags
PiperOrigin-RevId: 323398518
2020-07-27 11:10:24 -07:00
Zach Koopmans 77552f1c77 Port ffmpeg benchmark
PiperOrigin-RevId: 323383320
2020-07-27 10:10:14 -07:00
Zach Koopmans 29e5609b22 Port redis benchmark
PiperOrigin-RevId: 323381964
2020-07-27 10:01:45 -07:00
Jay Zhuang cf7141fb43 Ask for *testing.T instead of storing it
Storing *testing.T on test helper structs is problematic when
subtests are used, because it is possible for nested tests to call
Fatal on parent test, which incorrect terminates the parent test.

For example

  func TestOuter(t *testing.T) {
    dut := NewDUT(t)

    t.Run("first test", func(t *testing.T) {
      dut.FallibleCall()
    })

    t.Run("second test", func(t *testing.T) {
      dut.FallibleCall()
    }
  }

In the example above, assuming `FallibleCall` calls `t.Fatal` on the
`t` it holds, if `dut.FallibleCall` fails in "first test", it will
call `Fatal` on the parent `t`, quitting `TestOuter`. This is not a
behavior we want.

PiperOrigin-RevId: 323350241
2020-07-27 06:39:06 -07:00
Zach Koopmans 2ecf66903e Add profiling to dockerutil
Adds profiling with `runsc debug` or pprof to dockerutil. All
targets using dockerutil should now be able to use profiling.

In addition, modifies existing benchmarks to use profiling.

PiperOrigin-RevId: 323298634
2020-07-26 22:02:51 -07:00
Andrei Vagin d6b676ae6a test/syscall: run each test case in a separate network namespace
... when it is possible.

The guitar gVisorKernel*Workflow-s runs test with the local execution_method.
In this case, blaze runs test cases locally without sandboxes. This means
that all tests run in the same network namespace. We have a few tests which
use hard-coded network ports and they can fail if one of these port will be
used by someone else or by another test cases.

PiperOrigin-RevId: 323137254
2020-07-25 01:04:45 -07:00
Kevin Krakauer 91a47a40a8 Bugfix: non-native tests were tagged as native
Copy the list of tags when passing it to _syscall_test.
2020-07-24 17:27:11 -07:00
Kevin Krakauer da631a3ef2 Speed up some iptables tests
Sending UDP packets in a loop can be done in a separate goroutine. We
can't do this in ContainerAction because the container will terminate
early.

Locally, scripts/iptables_tests.sh runs ~40 seconds faster.
2020-07-24 15:06:07 -07:00
Ayush Ranjan 65b5e64802 Enable open test
Updates #2923

PiperOrigin-RevId: 322953552
2020-07-24 01:13:06 -07:00
Nicolas Lacasse 4ec3516332 Implement get/set_robust_list.
PiperOrigin-RevId: 322904430
2020-07-23 17:42:50 -07:00
gVisor bot 5e34ee68c9 Merge pull request #3024 from ridwanmsharif:ridwanmsharif/fuse-stub-impl
PiperOrigin-RevId: 322890087
2020-07-23 16:34:09 -07:00
Ridwan Sharif 3e0e3b9b11 Added stub FUSE filesystem
Allow FUSE filesystems to be mounted using libfuse.
The appropriate flags and mount options are parsed and
understood by fusefs.
2020-07-23 17:13:24 -04:00
gVisor bot 15da310efa Internal change.
PiperOrigin-RevId: 322859907
2020-07-23 13:58:42 -07:00
gVisor bot fc26b3764e Merge pull request #3207 from kevinGC:icmp-connect
PiperOrigin-RevId: 322853192
2020-07-23 13:25:33 -07:00
Bhasker Hariharan 20b556e625 Fix wildcard bind for raw socket.
Fixes #3334

PiperOrigin-RevId: 322846384
2020-07-23 12:54:12 -07:00
Nicolas Lacasse b396d3882c Port sendfile to vfs2.
And do some refactoring of the wait logic in sendfile/splice/tee.

Updates #1035 #2923

PiperOrigin-RevId: 322815521
2020-07-23 10:36:17 -07:00
Kevin Krakauer fb8be7e627 make connect(2) fail when dest is unreachable
Previously, ICMP destination unreachable datagrams were ignored by TCP
endpoints. This caused connect to hang when an intermediate router
couldn't find a route to the host.

This manifested as a Kokoro error when Docker IPv6 was enabled. The Ruby
image test would try to install the sinatra gem and hang indefinitely
attempting to use an IPv6 address.

Fixes #3079.
2020-07-22 16:51:42 -07:00
Kevin Krakauer 89bd71c942 iptables: don't NAT existing connections
Fixes a NAT bug that manifested as:
- A SYN was sent from gVisor to another host, unaffected by iptables.
- The corresponding SYN/ACK was NATted by a PREROUTING REDIRECT rule
  despite being part of the existing connection.
- The socket that sent the SYN never received the SYN/ACK and thus a
  connection could not be established.

We handle this (as Linux does) by tracking all connections, inserting a
no-op conntrack rule for new connections with no rules of their own.

Needed for istio support (#170).
2020-07-22 16:49:11 -07:00
Ayush Ranjan 39525d64cb Add O_APPEND support in vfs2 gofer.
Helps in fixing open syscall tests: AppendConcurrentWrite and AppendOnly.

We also now update the file size for seekable special files (regular files)
which we were not doing earlier.

Updates #2923

PiperOrigin-RevId: 322670843
2020-07-22 15:42:33 -07:00
Bhasker Hariharan 71bf90c55b Support for receiving outbound packets in AF_PACKET.
Updates #173

PiperOrigin-RevId: 322665518
2020-07-22 15:33:33 -07:00
Dean Deng 13c0cca50e Skip RawHDRINCL tests that are blocking presubmits/releases.
Temporarily skip these, on bhaskherh@'s advice.

PiperOrigin-RevId: 322664955
2020-07-22 15:13:03 -07:00
Adin Scannell e1a04f84e8 Add standard entrypoints for test targets.
PiperOrigin-RevId: 322265513
2020-07-20 18:05:05 -07:00
Ayush Ranjan 40acd22bc8 Runtime tests are enormous
PiperOrigin-RevId: 321885126
2020-07-17 17:19:34 -07:00
Zach Koopmans e3c2bd51a1 Move main methods for benchmark packages main package file.
PiperOrigin-RevId: 321875119
2020-07-17 16:23:10 -07:00
Jay Zhuang 40826b0557 DUT logs in test failure messages in packetimpact
DUT logs will include logs from the posix server and gVisor, which
provides a way to instrument the DUT during test failures.

PiperOrigin-RevId: 321816647
2020-07-17 11:18:40 -07:00
Ayush Ranjan c0ee95198a Automated rollback of changelist 321647645
PiperOrigin-RevId: 321808673
2020-07-17 10:45:25 -07:00
Jay Zhuang 7e226c8076 Test UDP packets with mcast source addr are discarded
PiperOrigin-RevId: 321790802
2020-07-17 09:14:17 -07:00
Bhasker Hariharan dcf6ddc277 Add support to return protocol in recvmsg for AF_PACKET.
Updates #173

PiperOrigin-RevId: 321690756
2020-07-16 18:40:32 -07:00
Ayush Ranjan e6894cb99f Port runtime tests to use go_test
PiperOrigin-RevId: 321647645
2020-07-16 14:37:13 -07:00
Zach Koopmans 5c8c0d65b9 Port httpd benchmark
PiperOrigin-RevId: 321478001
2020-07-15 18:21:51 -07:00