Commit Graph

957 Commits

Author SHA1 Message Date
Bhasker Hariharan efe5e737d7 Do not drop packets w/ missing TCP timestamps.
RFC7323 recommends that if the timestamp option was negotiated
then all packets should carry a TCP Timestamp and any packets that
do not should be dropped.

Netstack implemented this behaviour. Linux OTOH does not and will
accept such packets. This change makes Netstack behaviour compatible
with Linux.

Also now that we allow such packets, we do need to update RTO calculations
based on these packets even if timestamp option is enabled.

PiperOrigin-RevId: 233432268
Change-Id: I9f4742ae6b63930ac3b5e37d8c238761e6a4b29f
2019-02-11 10:23:43 -08:00
Ian Gudger 85d53d81d9 Use socket address functions in unbound IPv4 UDP tests.
Also switch to the correct casing style for local address variables.

PiperOrigin-RevId: 233161128
Change-Id: Ibc4a10a5d3ab04c40907aa885e8237b255c65a79
2019-02-08 18:23:38 -08:00
Nicolas Lacasse f17692d807 Add fs.AsyncWithContext and call it in fs/gofer/inodeOperations.Release.
fs/gofer/inodeOperations.Release does some asynchronous work.  Previously it
was calling fs.Async with an anonymous function, which caused the function to
be allocated on the heap.  Because Release is relatively hot, this results in a
lot of small allocations and increased GC pressure, noticeable in perf profiles.

This CL adds a new function, AsyncWithContext, which is just like Async, but
passes a context to the async function.  It avoids the need for an extra
anonymous function in fs/gofer/inodeOperations.Release.  The Async function
itself still requires a single anonymous function.

PiperOrigin-RevId: 233141763
Change-Id: I1dce4a883a7be9a8a5b884db01e654655f16d19c
2019-02-08 15:54:15 -08:00
Nicolas Lacasse e884168e1e Encode stat to bytes manually, instead of calling CopyObjectOut.
CopyObjectOut grows its destination byte slice incrementally, causing
many small slice allocations on the heap. This leads to increased GC and
noticeably slower stat calls.

PiperOrigin-RevId: 233140904
Change-Id: Ieb90295dd8dd45b3e56506fef9d7f86c92e97d97
2019-02-08 15:48:23 -08:00
Ian Gudger 967326131a Fix build error.
PiperOrigin-RevId: 233139020
Change-Id: I2e7089fa25d20e5662eb941054a684d41f5d3e12
2019-02-08 15:37:20 -08:00
Christopher Koch b2aa213dd2 Internal change.
PiperOrigin-RevId: 233124342
Change-Id: Id4b4857af89815ffb9254cc30df4244b2768d9f2
2019-02-08 14:14:14 -08:00
Nicolas Lacasse 9c9386d2a8 CopyObjectOut should allocate a byte slice the size of the encoded object.
This adds an extra Reflection call to CopyObjectOut, but avoids many small
slice allocations if the object is large, since without this we grow the
backing slice incrementally as we encode more data.

PiperOrigin-RevId: 233110960
Change-Id: I93569af55912391e5471277f779139c23f040147
2019-02-08 13:00:00 -08:00
Christopher Koch 5079b38a9a Keep FilePayloads open on server side until after RPC completed.
Prevents URPC FDs from being closed mid-call, especially if they
are used as raw FDs.

PiperOrigin-RevId: 233087955
Change-Id: I815a2ff32cc5f03774605aef0b35a32862f8e633
2019-02-08 10:51:24 -08:00
Ian Gudger 80f901b16b Plumb IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP to netstack.
Also includes a few fixes for IPv4 multicast support. IPv6 support is coming in
a followup CL.

PiperOrigin-RevId: 233008638
Change-Id: If7dae6222fef43fda48033f0292af77832d95e82
2019-02-07 23:15:23 -08:00
Andrei Vagin fda4d1f4f1 gvisor/tests: save runsc logs for each container in a separate directory
PiperOrigin-RevId: 232990964
Change-Id: Icfa426d5e83c7d3e56b0b92e6a9e1229bcb8361b
2019-02-07 19:32:51 -08:00
Rahat Mahmood 2ba74f84be Implement /proc/net/unix.
PiperOrigin-RevId: 232948478
Change-Id: Ib830121e5e79afaf5d38d17aeef5a1ef97913d23
2019-02-07 14:44:21 -08:00
Nicolas Lacasse fcae058a14 Make context.Background return a global background context.
It currently allocates a new context on the heap each time it is called. Some
of these are in relatively hot paths like signal delivery and releasing gofer
inodes.  It is also called very commonly in afterLoad.  All of these should
benefit from fewer heap allocations.

PiperOrigin-RevId: 232938873
Change-Id: I53cec0ca299f56dcd4866b0b4fd2ec4938526849
2019-02-07 13:55:23 -08:00
Googler e0afa87899 Internal change.
PiperOrigin-RevId: 232937200
Change-Id: I5c3709cc8f1313313ff618a45e48c14a3a111cb4
2019-02-07 13:46:26 -08:00
Fabricio Voznika 9ef3427ac1 Implement semctl(2) SETALL and GETALL
PiperOrigin-RevId: 232914984
Change-Id: Id2643d7ad8e986ca9be76d860788a71db2674cda
2019-02-07 11:41:44 -08:00
Googler 3c71e025e8 Internal change.
PiperOrigin-RevId: 232776481
Change-Id: Ic19d4aa6322fef71621bad0e9fb8bdedf6694114
2019-02-06 17:00:24 -08:00
Zach Koopmans 0cf7fc4e11 Change /proc/PID/cmdline to read environment vector.
- Change proc to return envp on overwrite of argv with limitations from
upstream.
- Add unit tests
- Change layout of argv/envp on the stack so that end of argv is contiguous with
beginning of envp.

PiperOrigin-RevId: 232506107
Change-Id: I993880499ab2c1220f6dc456a922235c49304dec
2019-02-05 10:02:06 -08:00
Kevin Krakauer 3eae03fe4f Deflake unlink test.
Multiple tests were creating the same directory before removing it, making it
possible for concurrent tests to fail because the directory already exists.

PiperOrigin-RevId: 232389814
Change-Id: I35d409fff4b3fd864b30fee742cb587b14975c23
2019-02-04 16:35:37 -08:00
Michael Pratt a9fe9afd63 Note //third_party in coding guidelines
PiperOrigin-RevId: 232375745
Change-Id: I26146ad65fac1dcdc5fcb4b11a1580133f9ca46d
2019-02-04 15:13:51 -08:00
Andrei Vagin 4f5fd311dc gvisor/test: Remove gtest shard env variables
PiperOrigin-RevId: 232071420
Change-Id: I5aa57f3dc4aac637d6f467445b4b3110fc08ac80
2019-02-01 18:13:27 -08:00
Fabricio Voznika 2d20b121d7 CachingInodeOperations was over-dirtying cached attributes
Dirty should be set only when the attribute is changed in the cache
only. Instances where the change was also sent to the backing file
doesn't need to dirty the attribute.

Also remove size update during WriteOut as writing dirty page would
naturaly grow the file if needed.

RELNOTES: relnotes is needed for the parent CL.
PiperOrigin-RevId: 232068978
Change-Id: I00ba54693a2c7adc06efa9e030faf8f2e8e7f188
2019-02-01 17:51:48 -08:00
Nicolas Lacasse 92e85623a0 Factor the subtargets method into a helper method with tests.
PiperOrigin-RevId: 232047515
Change-Id: I00f036816e320356219be7b2f2e6d5fe57583a60
2019-02-01 15:23:43 -08:00
Michael Pratt fe1369ac98 Move package sync to third_party
PiperOrigin-RevId: 231889261
Change-Id: I482f1df055bcedf4edb9fe3fe9b8e9c80085f1a0
2019-01-31 17:49:14 -08:00
Andrei Vagin 4e695adcd0 gvisor/gofer: Use pivot_root instead of chroot
PiperOrigin-RevId: 231864273
Change-Id: I8545b72b615f5c2945df374b801b80be64ec3e13
2019-01-31 15:19:04 -08:00
Michael Pratt 88b4ce8cac Fix comment
PiperOrigin-RevId: 231861005
Change-Id: I134d4e20cc898d44844219db0a8aacda87e11ef0
2019-01-31 15:03:12 -08:00
Fabricio Voznika aec5b67c81 Add syscall test dimension for --file_access=shared
PiperOrigin-RevId: 231856279
Change-Id: I175db87374890a62a3a3c2ddef727668ff854ce4
2019-01-31 14:38:12 -08:00
Fabricio Voznika a497f5ed5f Invalidate COW mappings when file is truncated
This changed required making fsutil.HostMappable use
a backing file to ensure the correct FD would be used
for read/write operations.

RELNOTES: relnotes is needed for the parent CL.
PiperOrigin-RevId: 231836164
Change-Id: I8ae9639715529874ea7d80a65e2c711a5b4ce254
2019-01-31 12:54:00 -08:00
Fabricio Voznika f1c1ee8a8e Don't mask out sticky bit to/from gofer
RELNOTES: sticky bit propagates to gofers now.
PiperOrigin-RevId: 231822453
Change-Id: I73426170b9457350480a3b144a2baf937e7cb477
2019-01-31 11:30:56 -08:00
Michael Pratt 2a0c69b19f Remove license comments
Nothing reads them and they can simply get stale.

Generated with:
$ sed -i "s/licenses(\(.*\)).*/licenses(\1)/" **/BUILD

PiperOrigin-RevId: 231818945
Change-Id: Ibc3f9838546b7e94f13f217060d31f4ada9d4bf0
2019-01-31 11:12:53 -08:00
Andrei Vagin 7e8a56087b runsc: check whether a container is deleted or not before setupContainerFS
PiperOrigin-RevId: 231811387
Change-Id: Ib143fb9a4d0fa1f105d1a3a3bd533dfc44e792af
2019-01-31 10:34:15 -08:00
Haibo Xu cedff8d3ae Add muldiv/rd_tsc support for arm64 platform.
Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: If35459be78e023346a140184401172f8e023c7f9
PiperOrigin-RevId: 231638020
2019-01-30 11:49:08 -08:00
Bhasker Hariharan f03c7e48e7 Fix IsLost check to match the description in RFC6675.
quoting what "rscheff@gmx.at" pointed out over email.
"IsLost in RFC3517 is defined as  >=  (DupThresh * SMSS) while
RFC6675 improves upon this, and defines IsLost as  >
((DupThresh - 1) * SMSS + 1).

The latter addresses situations where partial segments (size < MSS)
are sent (eg. last segment of a http protocol message sent with PSH
being less than MSS is common)."

PiperOrigin-RevId: 231512331
Change-Id: I1addd4a92e3e7baeb0bdda46463ebfae435da958
2019-01-29 18:13:48 -08:00
Nicolas Lacasse 53afa68988 Bump rules_go to v0.17.0, and go toolchain to v1.11.5.
PiperOrigin-RevId: 231506385
Change-Id: I739ca24a152b32130ab4c6cdd200242d2fb37e31
2019-01-29 17:32:20 -08:00
Andrei Vagin dd577f5410 runsc: reap a sandbox process only in sandbox.Wait()
PiperOrigin-RevId: 231504064
Change-Id: I585b769aef04a3ad7e7936027958910a6eed9c8d
2019-01-29 17:15:56 -08:00
Ian Gudger ff1c3bb0b5 Fix NIC endpoint forwarding.
Also adds a test for regular NIC forwarding.

PiperOrigin-RevId: 231495279
Change-Id: Ic7edec249568e9ad0280cea77eac14478c9073e1
2019-01-29 16:23:30 -08:00
Jamie Liu 3c5f8dfd4b Don't assume that stdout is always writable in PollTest.Nfds.
stdout can be (and, in automated testing, often is) a host pipe or
similar resource shared between multiple parallel tests, such that it
can become transiently full during testing.

PiperOrigin-RevId: 231413569
Change-Id: Id14991b5f71e53c894695899e65e1be4dd228cc6
2019-01-29 09:06:59 -08:00
Jamie Liu 57c202ead2 Refactor out NewEventFD to a test utility.
PiperOrigin-RevId: 231404512
Change-Id: I31efcc23a0c4a48ef6fbba3ca07415d79290f55c
2019-01-29 08:01:48 -08:00
Bhasker Hariharan 24cb2c0a72 Use recvmmsg() instead of readv() to read packets from NIC.
This should reduce the number of syscalls required to process packets
significantly and improve throughputs.

PiperOrigin-RevId: 231366886
Change-Id: I8b38077262bf9c53176bc4a94b530188d3d7c0ca
2019-01-29 01:39:01 -08:00
Shijiang Wei b44699c529 check isRootNS by ns inode
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
Change-Id: I032f834edae5c716fb2d3538285eec07aa11a902
PiperOrigin-RevId: 231318438
2019-01-28 17:20:20 -08:00
Zhaozhong Ni ae6e37df2a Convert TODO into FIXME.
PiperOrigin-RevId: 231301228
Change-Id: I3e18f3a12a35fb89a22a8c981188268d5887dc61
2019-01-28 15:34:18 -08:00
Nicolas Lacasse 09cf3b40a8 Fix data race in InodeSimpleAttributes.Unstable.
We were modifying InodeSimpleAttributes.Unstable.AccessTime without holding
the necessary lock.  Luckily for us, InodeSimpleAttributes already has a
NotifyAccess method that will do the update while holding the lock.

In addition, we were holding dfo.dir.mu.Lock while setting AccessTime, which
is unnecessary, so that lock has been removed.

PiperOrigin-RevId: 231278447
Change-Id: I81ed6d3dbc0b18e3f90c1df5e5a9c06132761769
2019-01-28 13:26:28 -08:00
Jamie Liu 9114471a5a Remove obsolete gVisor-specific test condition.
PiperOrigin-RevId: 231274510
Change-Id: I8f65157dbe18dae1c6235147fc4d27e0c844c833
2019-01-28 13:03:07 -08:00
Zhaozhong Ni 196e9f9d82 Convert outdated TODO to NOTE.
PiperOrigin-RevId: 231263193
Change-Id: Ib732c9639462f7994d473050495d88c2855434af
2019-01-28 11:59:43 -08:00
Lantao Liu 52b3cd873d runsc: Only uninstall cgroup for sandbox stop.
PiperOrigin-RevId: 231263114
Change-Id: I57467a34fe94e395fdd3685462c4fe9776d040a3
2019-01-28 11:58:25 -08:00
Jamie Liu 1cedccf8e9 Drop the one-page limit for /proc/[pid]/{cmdline,environ}.
It never actually should have applied to environ (the relevant change in
Linux 4.2 is c2c0bb44620d "proc: fix PAGE_SIZE limit of
/proc/$PID/cmdline"), and we claim to be Linux 4.4 now anyway.

PiperOrigin-RevId: 231250661
Change-Id: I37f9c4280a533d1bcb3eebb7803373ac3c7b9f15
2019-01-28 11:00:23 -08:00
Jamie Liu a8b8e13154 Deflake socket_stream_blocking tests.
PiperOrigin-RevId: 231020482
Change-Id: Idd9168678b18d03aac473adcc40902e27e06d0a1
2019-01-25 22:38:48 -08:00
Fabricio Voznika 55e8eb775b Make cacheRemoteRevalidating detect changes to file size
When file size changes outside the sandbox, page cache was not
refreshing file size which is required for cacheRemoteRevalidating.
In fact, cacheRemoteRevalidating should be skipping the cache
completely since it's not really benefiting from it. The cache is
cache is already bypassed for unstable attributes (see
cachePolicy.cacheUAttrs). And althought the cache is called to
map pages, they will always miss the cache and map directly from
the host.

Created a HostMappable struct that maps directly to the host and
use it for files with cacheRemoteRevalidating.

Closes #124

PiperOrigin-RevId: 230998440
Change-Id: Ic5f632eabe33b47241e05e98c95e9b2090ae08fc
2019-01-25 17:23:07 -08:00
ShiruRen c6facd0358 Fix a nil pointer dereference bug in Container.Destroy()
In Container.Destroy(), we call c.stop() before calling
executeHooksBestEffort(), therefore, when we call
executeHooksBestEffort(c.Spec.Hooks.Poststop, c.State()) to execute
the poststop hook, it results in a nil pointer dereference since it
reads c.Sandbox.Pid in c.State() after the sandbox has been destroyed.
To fix this bug, we can change container's status to "stopped" before
executing the poststop hook.

Signed-off-by: ShiruRen <renshiru2000@gmail.com>
Change-Id: I4d835e430066fab7e599e188f945291adfc521ef
PiperOrigin-RevId: 230975505
2019-01-25 15:03:17 -08:00
Fabricio Voznika c28f886c0b Execute statically linked binary
Mounting lib and lib64 are not necessary anymore and simplifies the test.

PiperOrigin-RevId: 230971195
Change-Id: Ib91a3ffcec4b322cd3687c337eedbde9641685ed
2019-01-25 14:39:20 -08:00
Jamie Liu 876b241fac Remove O_CLOEXEC from socket test configurations where irrelevant.
The implementation of O_CLOEXEC is orthogonal to every property tested
by these tests; removing it significantly reduces the number of
redundant tests we run.

Also remove no-op calls to VecCat (calls with a single argument).

PiperOrigin-RevId: 230959537
Change-Id: I83fe7db24e481ef67ca1f1992228af423f640b5c
2019-01-25 13:35:32 -08:00
Fabricio Voznika cc99520753 Add runsc logs to test results
PiperOrigin-RevId: 230850177
Change-Id: I34eb24e8ff8dd9ce3e7f5eb2dc2ee58eeac49f07
2019-01-24 22:42:39 -08:00