Commit Graph

3492 Commits

Author SHA1 Message Date
Bhasker Hariharan 07ff909e76 Support setsockopt SO_SNDBUF/SO_RCVBUF for raw/udp sockets.
Updates #173,#6
Fixes #2888

PiperOrigin-RevId: 317087652
2020-06-18 06:07:20 -07:00
Ghanan Gowripalan 09b2fca40c Cleanup tcp.timer and tcpip.Route
When a tcp.timer or tcpip.Route is no longer used, clean up its
resources so that unused memory may be released.

PiperOrigin-RevId: 317046582
2020-06-18 00:10:05 -07:00
Fabricio Voznika 6e0c170522 Implement Sync() to directories
Updates #1035, #1199

PiperOrigin-RevId: 317028108
2020-06-17 21:22:16 -07:00
Fabricio Voznika 22b0bb2138 Add TempTmpMount test
This currently doesn't work with VSF2. Add test to ensure
it's not missed.

Updates #1487

PiperOrigin-RevId: 317013792
2020-06-17 19:09:37 -07:00
Fabricio Voznika 97f6b20e89 Move mount configutation to RunOpts
Separate mount configuration from links and move it to
RunOpts, like the other options.

PiperOrigin-RevId: 317010158
2020-06-17 18:43:26 -07:00
Ghanan Gowripalan 57286eb642 Increase timeouts for NDP tests
... to help reduce flakes.

When waiting for an event to occur, use a timeout of 10s. When waiting
for an event to not occur, use a timeout of 1s.

Test: Ran test locally w/ run count of 1000 with and without gotsan.
PiperOrigin-RevId: 316998128
2020-06-17 17:22:43 -07:00
Ian Gudger 02072fd243 Add test for stat("/proc/net/snmp").
PiperOrigin-RevId: 316974863
2020-06-17 15:15:57 -07:00
gVisor bot a5f4deeca7 Internal change.
PiperOrigin-RevId: 316973783
2020-06-17 15:10:40 -07:00
Nicolas Lacasse 28a5c55bb6 Proc test: Allow root mount pathname to be non-root.
The test was expecting that the root mount pathname was "/", but it doesn't
need to be. Only the mount point actually should be "/" (otherwise it is not
the root).

PiperOrigin-RevId: 316968025
2020-06-17 14:42:41 -07:00
Bhasker Hariharan 505e8f4e3d Fix TtlDefault test on linux.
Different flavors of linux seem to use different defaults we accept 64
or 127 as the TtlDefault in the test.

PiperOrigin-RevId: 316961150
2020-06-17 14:08:48 -07:00
Michael Pratt 6d806ee719 Remove various uses of 'blacklist'
Updates #2972

PiperOrigin-RevId: 316942245
2020-06-17 12:34:33 -07:00
Dean Deng e5d97cbcc1 Refactor host.canMap.
Simplify the canMap check. We do not have plans to allow mmap for anything
beyond regular files, so we can just inline canMap() as a simple file mode
check.

Updates #1672.

PiperOrigin-RevId: 316929654
2020-06-17 11:34:06 -07:00
Mithun Iyer 50afec55c7 TCP stat fixes
Ensure that CurrentConnected stat is updated on any errors and cleanups
during connected state processing.

Fixes #2968

PiperOrigin-RevId: 316919426
2020-06-17 10:47:04 -07:00
Fabricio Voznika 96519e2c9d Implement POSIX locks
- Change FileDescriptionImpl Lock/UnlockPOSIX signature to
  take {start,length,whence}, so the correct offset can be
  calculated in the implementations.
- Create PosixLocker interface to make it possible to share
  the same locking code from different implementations.

Closes #1480

PiperOrigin-RevId: 316910286
2020-06-17 10:04:26 -07:00
Nicolas Lacasse 6d64028c94 Fix typos in test/README.md.
Closes #2996.

PiperOrigin-RevId: 316900535
2020-06-17 09:13:09 -07:00
gVisor bot dbf786c6b3 Add runsc options to set checksum offloading status
--tx-checksum-offload=<true|false>
  enable TX checksum offload (default: false)
--rx-checksum-offload=<true|false>
  enable RX checksum offload (default: true)

Fixes #2989

PiperOrigin-RevId: 316781309
2020-06-16 16:34:26 -07:00
Jamie Liu e61acfb5ea Correctly handle multiple resizings in pgalloc.findAvailableRange().
PiperOrigin-RevId: 316778032
2020-06-16 16:16:14 -07:00
Mithun Iyer 622f798689 Replace use of %v in tcp tests
PiperOrigin-RevId: 316767969
2020-06-16 15:18:05 -07:00
Fabricio Voznika bae1475603 Print spec as json when --debug is enabled
The previous format skipped many important structs that
are pointers, especially for cgroups. Change to print
as json, removing parts of the spec that are not relevant.

Also removed debug message from gofer that can be very
noisy when directories are large.

PiperOrigin-RevId: 316713267
2020-06-16 10:52:17 -07:00
Nicolas Lacasse 810748f5c9 Port aio to VFS2.
In order to make sure all aio goroutines have stopped during S/R, a new
WaitGroup was added to TaskSet, analagous to runningGoroutines. This WaitGroup
is incremented with each aio goroutine, and waited on during kernel.Pause.

The old VFS1 aio code was changed to use this new WaitGroup, rather than
fs.Async. The only uses of fs.Async are now inode and mount Release operations,
which do not call fs.Async recursively. This fixes a lock-ordering violation
that can cause deadlocks.

Updates #1035.

PiperOrigin-RevId: 316689380
2020-06-16 08:49:06 -07:00
Jamie Liu 3b0b1f104d Miscellaneous VFS2 fixes.
PiperOrigin-RevId: 316627764
2020-06-16 00:15:20 -07:00
Mithun Iyer 67f261a87d TCP to honor updated window size during handshake.
In passive open cases, we transition to Established state after
initializing endpoint's sender and receiver. With this we lose out
on any updates coming from the ACK that completes the handshake.
This change ensures that we uniformly transition to Established in all
cases and does minor cleanups.

Fixes #2938

PiperOrigin-RevId: 316567014
2020-06-15 16:19:53 -07:00
Michael Pratt 885605c5e4 Remove blacklist from //test/runtimes
Updates #2972

PiperOrigin-RevId: 316534165
2020-06-15 13:36:24 -07:00
Martijn Vels eb6d3d7710 Internal change.
PiperOrigin-RevId: 316492839
2020-06-15 10:27:16 -07:00
Rahat Mahmood f23f62c2c2 Correctly set the test VFS environment variable.
Also fix test bugs uncovered now that they aren't silently skipped on
VFS2.

Updates #1487.

PiperOrigin-RevId: 316415807
2020-06-15 01:09:38 -07:00
Ian Gudger 3b5eaad3c8 Allow reading IP_MULTICAST_LOOP and IP_MULTICAST_TTL on TCP sockets.
I am not really sure what the point of this is, but someone filed a bug about
it, so I assume something relies on it.

PiperOrigin-RevId: 316225127
2020-06-12 20:49:02 -07:00
Tony Gong 82313667ea Make GenerateRandomPayload available to all tests
Moved the function for generating a payload of random byets of a specified
length into the testbench package so that it's availbale for all tests to use.

Added a test case to the IPv4 ID uniqueness test which uses a payload length
of 512 bytes. This test case passes for gVisor currently, whereas the test case
with a small payload of 11 bytes fails because gVisor only assigns the ID field
if the IP payload is sufficiently large.

PiperOrigin-RevId: 316185097
2020-06-12 15:07:17 -07:00
Andrei Vagin 6ec9d60403 vfs2: implement fcntl(fd, F_SETFL, flags)
PiperOrigin-RevId: 316148074
2020-06-12 11:58:15 -07:00
Mithun Iyer 61d6c059ac Replace use of %v in packetimpact tests
PiperOrigin-RevId: 316027588
2020-06-11 19:46:49 -07:00
Ian Lewis 8ea99d58ff Set the HOME environment variable for sub-containers.
Fixes #701

PiperOrigin-RevId: 316025635
2020-06-11 19:31:24 -07:00
Adin Scannell 5a894e35a0 Remove generated logs when test succeeds.
PiperOrigin-RevId: 316022884
2020-06-11 19:05:18 -07:00
Jamie Liu 77c206e371 Add //pkg/sentry/fsimpl/overlay.
Major differences from existing overlay filesystems:

- Linux allows lower layers in an overlay to require revalidation, but not the
  upper layer. VFS1 allows the upper layer in an overlay to require
  revalidation, but not the lower layer. VFS2 does not allow any layers to
  require revalidation. (Now that vfs.MkdirOptions.ForSyntheticMountpoint
  exists, no uses of overlay in VFS1 are believed to require upper layer
  revalidation; in particular, the requirement that the upper layer support the
  creation of "trusted." extended attributes for whiteouts effectively required
  the upper filesystem to be tmpfs in most cases.)

- Like VFS1, but unlike Linux, VFS2 overlay does not attempt to make mutations
  of the upper layer atomic using a working directory and features like
  RENAME_WHITEOUT. (This may change in the future, since not having a working
  directory makes error recovery for some operations, e.g. rmdir, particularly
  painful.)

- Like Linux, but unlike VFS1, VFS2 represents whiteouts using character
  devices with rdev == 0; the equivalent of the whiteout attribute on
  directories is xattr trusted.overlay.opaque = "y"; and there is no equivalent
  to the whiteout attribute on non-directories since non-directories are never
  merged with lower layers.

- Device and inode numbers work as follows:

    - In Linux, modulo the xino feature and a special case for when all layers
      are the same filesystem:

        - Directories use the overlay filesystem's device number and an
          ephemeral inode number assigned by the overlay.

        - Non-directories that have been copied up use the device and inode
          number assigned by the upper filesystem.

        - Non-directories that have not been copied up use a per-(overlay,
          layer)-pair device number and the inode number assigned by the lower
          filesystem.

    - In VFS1, device and inode numbers always come from the lower layer unless
      "whited out"; this has the adverse effect of requiring interaction with
      the lower filesystem even for non-directory files that exist on the upper
      layer.

    - In VFS2, device and inode numbers are assigned as in Linux, except that
      xino and the samefs special case are not supported.

- Like Linux, but unlike VFS1, VFS2 does not attempt to maintain memory mapping
  coherence across copy-up. (This may have to change in the future, as users
  may be dependent on this property.)

- Like Linux, but unlike VFS1, VFS2 uses the overlayfs mounter's credentials
  when interacting with the overlay's layers, rather than the caller's.

- Like Linux, but unlike VFS1, VFS2 permits multiple lower layers in an
  overlay.

- Like Linux, but unlike VFS1, VFS2's overlay filesystem is
  application-mountable.

Updates #1199

PiperOrigin-RevId: 316019067
2020-06-11 18:34:53 -07:00
Ian Gudger dc4e0157ef Add test for reordering.
Tests the effect of reordering on retransmission and window size.

Test covers the expected behavior of both Linux and netstack, however, netstack
does not behave as expected. Further, the current expected behavior of netstack
is not ideal and should be adjusted in the future.

PiperOrigin-RevId: 316015184
2020-06-11 18:04:43 -07:00
Fabricio Voznika fbe41987c9 Enable nogo again
PiperOrigin-RevId: 316011323
2020-06-11 17:34:02 -07:00
Ghanan Gowripalan 4c0a8bdaf5 Do not use tentative addresses for routes
Tentative addresses should not be used when finding a route. This change
fixes a bug where a tentative address may have been used.

Test: stack_test.TestDADResolve
PiperOrigin-RevId: 315997624
2020-06-11 16:09:45 -07:00
gVisor bot 4f111b6384 Merge pull request #2863 from lubinszARM:pr_sndbuf
PiperOrigin-RevId: 315991648
2020-06-11 15:36:43 -07:00
Fabricio Voznika d58d57606a Don't copy structs with sync.Mutex during initialization
During inititalization inode struct was copied around, but
it isn't great pratice to copy it around since it contains
ref count and sync.Mutex.

Updates #1480

PiperOrigin-RevId: 315983788
2020-06-11 14:56:19 -07:00
gVisor bot 11dc95e6c5 Merge pull request #2705 from lubinszARM:pr_sigfp_nested
PiperOrigin-RevId: 315979564
2020-06-11 14:35:46 -07:00
gVisor bot 13f2664cfe Merge pull request #2946 from avagin:travis-pipefail
PiperOrigin-RevId: 315972822
2020-06-11 14:04:26 -07:00
gVisor bot 44575bf726 Refactor packetimpact Connection types
Reorganize the Connection types such that the defined types no longer expose
the lower-level functions SendFrame and CreateFrame. These methods are still
exported on the underlying Connection type, and thus can be accessed via a
type-cast. In future, defined types should have one or more type-safe versions
of the send() method on Connection, e.g. UDPIPv4 has Send() which allows the UDP
header to be overridden and SendIP() which allows both the IPv4 and UDP headers
to be modified.

testbench.Connection gets a SendFrameStateless method which sends frames
without updating the state of any of the layers. This should be used when
sending out-of-band control messages such as ICMP messages, as using the
normal Send method can result in errors when attempting to update the TCP
state using an ICMP packet.

Also remove the localAddr field of testbench.Connection and instead compute
it on the fly as needed for UDPIPv4 and TCPIPv4.

PiperOrigin-RevId: 315969714
2020-06-11 13:48:30 -07:00
gVisor bot af6ec7b734 Add Generate method in merkletree
A method is added to generate a merkle tree for data, and store the
generated tree in the output.

PiperOrigin-RevId: 315966571
2020-06-11 13:33:09 -07:00
gVisor bot d2cc9a888e Factor out flipcall mmap for internal use
PiperOrigin-RevId: 315959279
2020-06-11 12:57:56 -07:00
gVisor bot b39cc6a800 Add merkle tree size measure
This change creates a merkletree package which will be used in the future
for an implementation of file system API.

PiperOrigin-RevId: 315952451
2020-06-11 12:23:25 -07:00
Andrei Vagin c45420a3f5 travis: set the pipefail option
The travis job has to fail if make smoke-test fails.

Reported-by: Bin Lu <bin.lu@arm.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-06-11 11:26:22 -07:00
Michael Pratt 0c7a5bc69c Add nogo TODO.
PiperOrigin-RevId: 315911025
2020-06-11 09:13:01 -07:00
Ian Gudger a085e562d0 Add support for SO_REUSEADDR to UDP sockets/endpoints.
On UDP sockets, SO_REUSEADDR allows multiple sockets to bind to the same
address, but only delivers packets to the most recently bound socket. This
differs from the behavior of SO_REUSEADDR on TCP sockets. SO_REUSEADDR for TCP
sockets will likely need an almost completely independent implementation.

SO_REUSEADDR has some odd interactions with the similar SO_REUSEPORT. These
interactions are tested fairly extensively and all but one particularly odd
one (that honestly seems like a bug) behave the same on gVisor and Linux.

PiperOrigin-RevId: 315844832
2020-06-10 23:49:26 -07:00
Nicolas Lacasse a87c74bc54 Remove duplicate colon from warning log.
doAction()->log.TracebackAll() will append a colon.

PiperOrigin-RevId: 315842611
2020-06-10 23:23:07 -07:00
Bin Lu cbfb537eef Deleting the maxSendBufferSize from fs/host
When I do high-performance networking,
the value of wmem_max is often set very high,
specially for 10/25/50 Gigabit NIC.

I think maybe this restriction is not suitable.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-06-10 21:53:46 -04:00
gVisor bot b436b9717e Merge pull request #2711 from lubinszARM:pr_mmio
PiperOrigin-RevId: 315812219
2020-06-10 18:51:41 -07:00
gVisor bot 508e7c3a79 Merge pull request #2763 from gaurav1086:sentry_kernel_timekeeper_use_buffered_channel
PiperOrigin-RevId: 315803553
2020-06-10 17:43:16 -07:00