Commit Graph

1089 Commits

Author SHA1 Message Date
Boyuan He b50c03b571 Implement FUSE_SYMLINK
Fixes #3452
2020-09-16 12:19:30 -07:00
Boyuan He b53e10f391 Implement FUSE_MKNOD
Fixes #3492
2020-09-16 12:19:30 -07:00
Boyuan He 947088e10a Implement FUSE_RELEASE/RELEASEDIR
Fixes #3314
2020-09-16 12:19:30 -07:00
Boyuan He 32044f94e9 Implement FUSE_OPEN/OPENDIR
Fixes #3174
2020-09-16 12:19:30 -07:00
Craig Chi 717b661c45 Add function to create a fake inode in FUSE integration test
Adds a function for the testing thread to set up a fake inode with a
specific path under mount point. After this function is called, each
subsequent FUSE_LOOKUP request with the same path will be served with
the fixed stub response.

Fixes #3539
2020-09-16 12:19:30 -07:00
Craig Chi d928d3c00a Add function generating array of iovec with different FUSE structs
This commit adds a function in the newly created fuse_util library,
which accepts a variable number of arguments and data structures.

Fixes #3609
2020-09-16 12:19:30 -07:00
Craig Chi a289c38626 Add functions in FUSE integration test to get metrics from FUSE server
This commit adds 3 utility functions to ensure all received requests
and preset responses are consumed.

1. Get number of unconsumed requests (received by the FUSE server but
   not consumed by the testing thread).
2. Get number of unsent responses (set by the testing thread but not
   processed by the FUSE server).
3. Get total bytes of the received requests (to ensure some operations
   don't trigger FUSE requests).

Fixes #3607
2020-09-16 12:19:30 -07:00
Craig Chi 15ff2893d9 Extend integration test to test sequence of FUSE operation
Original FUSE integration test has limited capabilities. To test more
situations, the new integration test framework introduces a protocol
to communicate between testing thread and the FUSE server. In summary,
this change includes:

1. Remove CompareResult() and break SetExpected() into
   SetServerResponse() and GetServerActualRequest(). We no longer set
   up an expected request because we want to retrieve the actual FUSE
   request made to the FUSE server and check in the testing thread.

2. Declare a serial buffer data structure to save the received requests
   and expected responses sequentially. The data structure contains a
   cursor to indicate the progress of accessing. This change makes
   sequential SetServerResponse() and GetServerActualRequest() possible.

3. Replace 2 single directional pipes with 1 bi-directional socketpair.
   A protocol which starts with FuseTestCmd is used between the testing
   thread and the FUSE server to provide various functionality.

Fixes #3405
2020-09-16 12:19:30 -07:00
Rahat Mahmood d201feb8c5 Enable automated marshalling for the syscall package.
PiperOrigin-RevId: 331940975
2020-09-15 23:38:57 -07:00
Dean Deng a004f0d082 Support setting STATX_SIZE for kernfs.InodeAttrs.
Make setting STATX_SIZE a no-op, if it is valid for the given permissions and
file type.

Also update proc tests, which were overfitted before.

Fixes #3842.
Updates #1193.

PiperOrigin-RevId: 331861087
2020-09-15 14:55:28 -07:00
gVisor bot 84d48c0fdd Merge pull request #3895 from btw616:fix/issue-3894
PiperOrigin-RevId: 331824411
2020-09-15 12:12:28 -07:00
Tiwei Bie 1adedad81c Fix proc.(*fdDir).IterDirents for VFS2
Currently the returned offset is an index, and we can't
use it to find the next fd to serialize, because getdents
should iterate correctly despite mutation of fds. Instead,
we can return the next fd to serialize plus 2 (which
accounts for "." and "..") as the offset.

Fixes: #3894

Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
2020-09-15 11:12:29 +08:00
Mithun Iyer 05d2ebee5e Test RST handling in TIME_WAIT.
gVisor stack ignores RSTs when in TIME_WAIT which is not the default
Linux behavior. Add a packetimpact test to test the same.
Also update code comments to reflect the rationale for the current
gVisor behavior.

PiperOrigin-RevId: 331629879
2020-09-14 14:33:53 -07:00
Nicolas Lacasse 1f4fb817c8 Check that we have access to the trusted.* xattr namespace directly.
These operations require CAP_SYS_ADMIN in the root user namespace. There's no
easy way to check that other than trying the operation and seeing what happens.

PiperOrigin-RevId: 331242256
2020-09-11 16:10:12 -07:00
Amanda Tait 325f7036b0 Use correct test device name in Fuchsia packetimpact
Packetimpact on Fuchsia was formerly using the Linux test device name. This
change fixes that.

PiperOrigin-RevId: 331211518
2020-09-11 13:28:57 -07:00
Ayush Ranjan 365545855f [vfs] Disable inode number equality check for overlayfs.
Overlayfs does not persist a directory's inode number even while it is mounted.
See fs/overlayfs/inode.c:ovl_map_dev_ino(). VFS2 generates a new inode number
for directories everytime in lookup.

PiperOrigin-RevId: 331045037
2020-09-10 16:50:18 -07:00
Ayush Ranjan 50c99a86d1 [vfs] Disable nlink tests for overlayfs.
Overlayfs intentionally does not compute nlink for directories (because it can
be really expensive). Linux returns 1, VFS2 returns 2 and VFS1 actually
calculates the correct value.

PiperOrigin-RevId: 330967139
2020-09-10 10:40:35 -07:00
Ayush Ranjan bca4d99a4b [vfs] overlayfs: Fix socket tests.
- BindSocketThenOpen test was expecting the incorrect error when opening
  a socket. Fixed that.
- VirtualFilesystem.BindEndpointAt should not require pop.Path.Begin.Ok()
  because the filesystem implementations do not need to walk to the parent
  dentry. This check also exists for MknodAt, MkdirAt, RmdirAt, SymlinkAt and
  UnlinkAt but those filesystem implementations also need to walk to the parent
  denty. So that check is valid. Added some syscall tests to test this.

PiperOrigin-RevId: 330625220
2020-09-08 17:56:22 -07:00
Ghanan Gowripalan d35f07b36a Improve type safety for transport protocol options
The existing implementation for TransportProtocol.{Set}Option take
arguments of an empty interface type which all types (implicitly)
implement; any type may be passed to the functions.

This change introduces marker interfaces for transport protocol options
that may be set or queried which transport protocol option types
implement to ensure that invalid types are caught at compile time.
Different interfaces are used to allow the compiler to enforce read-only
or set-only socket options.

RELNOTES: n/a
PiperOrigin-RevId: 330559811
2020-09-08 12:17:39 -07:00
Ayush Ranjan d84ec6c42b [vfs] Capitalize x in the {Get/Set/Remove/List}xattr functions.
PiperOrigin-RevId: 330554450
2020-09-08 11:51:39 -07:00
Nicolas Lacasse 30c20df76f Run gentdents_benchmark with fewer files.
This test regularly times out when "shared" filesystem is enabled.

PiperOrigin-RevId: 329950622
2020-09-03 10:54:01 -07:00
Tamir Duberstein 319ce67369 Avoid grpc_impl
PiperOrigin-RevId: 329902747
2020-09-03 05:52:17 -07:00
Zeling Feng 86c1ae095a Add support to run packetimpact tests against Fuchsia
blaze test <test_name>_fuchsia_test will run the corresponding packetimpact
test against fuchsia.

PiperOrigin-RevId: 329835290
2020-09-02 19:19:40 -07:00
Bhasker Hariharan b69352245a Fix Accept to not return error for sockets in accept queue.
Accept on gVisor will return an error if a socket in the accept queue was closed
before Accept() was called. Linux will return the new fd even if the returned
socket is already closed by the peer say due to a RST being sent by the peer.

This seems to be intentional in linux more details on the github issue.

Fixes #3780

PiperOrigin-RevId: 329828404
2020-09-02 18:21:47 -07:00
Zach Koopmans b9b6660dc4 Add Docs to nginx benchmark.
Adds docs to nginx and refactors both Httpd and Nginx benchmarks.

Key changes:
- Add docs and make nginx tests the same as httpd (reverse, all docs, etc.).
- Make requests scale on c * b.N -> a request per thread. This works well
with both --test.benchtime=10m (do a run that lasts at least 10m) and
--test.benchtime=10x (do b.N = 10).
-- Remove a doc from both tests (1000Kb) as 1024Kb exists.

PiperOrigin-RevId: 329751091
2020-09-02 11:22:17 -07:00
Ayush Ranjan 8ab08cdc01 [runtime tests] Exclude flaky nodejs test
PiperOrigin-RevId: 329749191
2020-09-02 11:13:02 -07:00
Zach Koopmans 563f28b7d5 Fix statfs test for opensource.
PiperOrigin-RevId: 329638946
2020-09-01 21:03:48 -07:00
Fabricio Voznika 37a217aca4 Implement setattr+clunk in 9P
This is to cover the common pattern: open->read/write->close,
where SetAttr needs to be called to update atime/mtime before
the file is closed.

Benchmark results:

BM_OpenReadClose/10240 CPU
setattr+clunk: 63783 ns
VFS2:          68109 ns
VFS1:          72507 ns

Updates #1198

PiperOrigin-RevId: 329628461
2020-09-01 19:22:12 -07:00
Mithun Iyer 40faeaa180 Fix handling of unacceptable ACKs during close.
On receiving an ACK with unacceptable ACK number, in a closing state,
TCP, needs to reply back with an ACK with correct seq and ack numbers and
remain in same state. This change is as per RFC793 page 37, but with a
difference that it does not apply to ESTABLISHED state, just as in Linux.
Also add more tests to check for OTW sequence number and unacceptable
ack numbers in these states.

Fixes #3785

PiperOrigin-RevId: 329616283
2020-09-01 17:45:04 -07:00
Dean Deng c67d8ece09 Test opening file handles with different permissions.
These were problematic for vfs2 gofers before correctly implementing separate
read/write handles.

PiperOrigin-RevId: 329613261
2020-09-01 17:21:22 -07:00
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