Commit Graph

1227 Commits

Author SHA1 Message Date
Zeling Feng 96d14de0fa export MountTempDirectory
PiperOrigin-RevId: 346487763
2020-12-09 15:50:35 -08:00
Tamir Duberstein cc522a9cfb Run tcpdump as root
Prior to this change tcpdump would fail to create its output file
because the destination directory was owned by root. This would later
cause killall to fail, as tcpdump was not running. Check exit code of
tcpdump/tshark to produce better error messages should this regress.

PiperOrigin-RevId: 346353911
2020-12-08 10:20:38 -08:00
Tamir Duberstein 5ea6419478 Consolidate sniffer program logic
Avoid action at a distance where both `snifferArgs` and `snifferProg`
must stay in sync.

PiperOrigin-RevId: 346341231
2020-12-08 09:24:02 -08:00
Rahat Mahmood 9c198e5df4 Fix error handling on fusefs mount.
Don't propagate arbitrary golang errors up from fusefs because errors
that don't map to an errno result in a sentry panic.

Reported-by: syzbot+697cb635346e456fddfc@syzkaller.appspotmail.com
PiperOrigin-RevId: 346220306
2020-12-07 18:00:54 -08:00
Tamir Duberstein 1aeca3bfb7 Remove detritus
- Remove unused constants
- Correct function doc comment
- Remove useless cast
- Restore comment removed in an earlier change

PiperOrigin-RevId: 346205943
2020-12-07 16:34:39 -08:00
Zach Koopmans 6d30688bd7 Fix tags on benchmark targets.
PiperOrigin-RevId: 346203209
2020-12-07 16:20:12 -08:00
Tamir Duberstein 432964d035 Avoid shadowing `testbench` package
PiperOrigin-RevId: 346109185
2020-12-07 09:28:38 -08:00
Peter Johnston eeb23531eb Support icmpv6 transport protocol
PiperOrigin-RevId: 346101076
2020-12-07 08:44:44 -08:00
gVisor bot a97ceec01b Merge pull request #4932 from lubinszARM:pr_test_exceptions
PiperOrigin-RevId: 345976554
2020-12-06 13:06:37 -08:00
Mithun Iyer 3075ede86e Fix zero receive window advertisements.
With the recent changes db36d948fa, we try
to balance the receive window advertisements between payload lengths vs
segment overhead length. This works fine when segment size are much
higher than the overhead, but not otherwise. In cases where the segment
length is smaller than the segment overhead, we may end up not
advertising zero receive window for long time and end up tail-dropping
segments. This is especially pronounced when application socket reads
are slow or stopped. In this change we do not grow the right edge of
the receive window for smaller segment sizes similar to Linux.
Also, we keep track of the socket buffer usage and let the window grow
if the application is actively reading data.

Fixes #4903

PiperOrigin-RevId: 345832012
2020-12-05 01:48:00 -08:00
Adin Scannell 7a1de8583d Remove invalid test case.
The next test case is perfectly valid, which creates a test directory
with appropriate permissions and ensures that you can't create a file.

This test case assumes that the root directory has certain permissions.
In this case, we may have EROFS instead of a permission error, but it's
perfectly plausible that no error occurs at all. The test is not valid.

PiperOrigin-RevId: 345764412
2020-12-04 15:11:55 -08:00
Adin Scannell 1371b73b4b Initialize has_tid for correctness.
PiperOrigin-RevId: 345763209
2020-12-04 14:59:54 -08:00
Bruno Dal Bo fd28ccfaa4 Introduce IPv4 options serializer and add RouterAlert to IGMP
PiperOrigin-RevId: 345701623
2020-12-04 10:10:56 -08:00
Jing Chen a78cef0ed7 Implement command IPC_INFO for semctl.
PiperOrigin-RevId: 345589628
2020-12-03 19:57:51 -08:00
Etienne Perot 6f60a2b0a2 Implement `fcntl` options `F_GETSIG` and `F_SETSIG`.
These options allow overriding the signal that gets sent to the process when
I/O operations are available on the file descriptor, rather than the default
`SIGIO` signal. Doing so also populates `siginfo` to contain extra information
about which file descriptor caused the event (`si_fd`) and what events happened
on it (`si_band`). The logic around which FD is populated within `si_fd`
matches Linux's, which means it has some weird edge cases where that value may
not actually refer to a file descriptor that is still valid.

This CL also ports extra S/R logic regarding async handler in VFS2.
Without this, async I/O handlers aren't properly re-registered after S/R.

PiperOrigin-RevId: 345436598
2020-12-03 06:20:29 -08:00
Adin Scannell 80552b936d Support partitions for other tests.
PiperOrigin-RevId: 345399936
2020-12-03 01:00:21 -08:00
Arthur Sfez 6a26930eeb Abandon reassembly of a packet if fragments overlap
However, receiving duplicated fragments will not cause reassembly to
fail. This is what Linux does too:
https://github.com/torvalds/linux/blob/38525c6/net/ipv4/inet_fragment.c#L355

PiperOrigin-RevId: 345309546
2020-12-02 14:12:01 -08:00
Adin Scannell 24d6eb58e5 Skip generating an empty (broken) test case.
It's possible that all the cases in a given batch are excluded if
the offsets line up just right, which will cause the test to fail.
Don't generate an invalid test in this case.

PiperOrigin-RevId: 345276588
2020-12-02 11:40:27 -08:00
Adin Scannell 7ccb0b6a7c Fix chown test.
PiperOrigin-RevId: 345265342
2020-12-02 10:53:52 -08:00
Adin Scannell 496851d27b Skip CanKillAllPIDs when running natively.
This is quite disruptive to run in some environments.

PiperOrigin-RevId: 345247206
2020-12-02 09:28:14 -08:00
Jing Chen b26dd6d9b7 Add /proc/sys/kernel/sem.
PiperOrigin-RevId: 345178956
2020-12-02 00:13:24 -08:00
Zeling Feng aa419cef4b Avoid wrong error messages
Stop showing wrong timeout values in packetimpact test error messages. e.g.
"got frames ... want ... during -123ms"

PiperOrigin-RevId: 345144938
2020-12-01 18:53:57 -08:00
Etienne Perot c140b0c493 Typo fix.
PiperOrigin-RevId: 345062676
2020-12-01 11:31:25 -08:00
Bhasker Hariharan 79e2364933 Fix deadlock in UDP handleControlPacket path.
Fixing the sendto deadlock exposed yet another deadlock where a lock inversion
occurs on the handleControlPacket path where e.mu and demuxer.epsByNIC.mu are
acquired in reverse order from say when RegisterTransportEndpoint is called
in endpoint.Connect().

This fix sidesteps the issue by just making endpoint.state an atomic and gets rid
of the need to acquire e.mu in e.HandleControlPacket.

PiperOrigin-RevId: 344939895
2020-11-30 20:13:26 -08:00
Jamie Liu 786f32c2b1 Do not os.Exit() from test/benchmarks/harness.Harness.Init with no args.
PiperOrigin-RevId: 344896991
2020-11-30 15:09:28 -08:00
Ghanan Gowripalan bc81fcceda Support listener-side MLDv1
...as defined by RFC 2710. Querier (router)-side MLDv1 is not yet
supported.

The core state machine is shared with IGMPv2.

This is guarded behind a flag (ipv6.Options.MLDEnabled).

Tests: ip_test.TestMGP*

Bug #4861

PiperOrigin-RevId: 344344095
2020-11-25 18:00:41 -08:00
Zeling Feng 4d59a5a622 [3/3] Support isolated containers for parallel packetimpact tests
To create DUTs in parallel, we need to create goroutines to do the setup. The
old code base has a lot of t.Fatal(f) usage in those setup functions which is
not great for this change: "FailNow must be called from the goroutine running
the test or benchmark function, not from other goroutines created during the
test" (https://golang.org/pkg/testing/#T.FailNow).

- Cleanup all t.Fatal(f) usage in DUT.Prepare()
- use goroutines to create DUTs in parallel

PiperOrigin-RevId: 344275809
2020-11-25 10:24:37 -08:00
Zeling Feng d04144fbb7 [2/3] Support isolated containers for parallel packetimpact tests
Added a new flag num_duts to the test runner to create multiple DUTs for the
testbench can connect to.

PiperOrigin-RevId: 344195435
2020-11-24 23:22:05 -08:00
Robin Luk be71d3569c arm64 test: add exceptions related test cases
For now, I only added a halt test case for Arm64.

Signed-off-by: Robin Luk <lubin.lu@antgroup.com>
2020-11-25 13:43:11 +08:00
Julian Elischer 4da63dc82e Report correct pointer value for "bad next header" ICMP error
Because the code handles a bad header as "payload" right up to the last moment
we need to make sure payload handling does not remove the error information.

Fixes #4909

PiperOrigin-RevId: 344141690
2020-11-24 15:25:40 -08:00
Zeling Feng d492b21319 Fix a potential indefinite blocking in packetimpact testbench
1. setsockopt(SO_RCVTIMEO, 0) == never timeout
2. float64(time.Microsecond/time.Second) == 0
3. packetimpact tests use a lot of 1s timeouts

This becomes a more significant problem because of a recent change that binds
the sniffer only on the specific testNet interface so now the traffic on the
ctrlNet cannot wake up the blocking call anymore.

PiperOrigin-RevId: 344123465
2020-11-24 13:42:07 -08:00
Zeling Feng d4951e05a0 [1/3] Support isolated containers for parallel packetimpact tests
Summary of the approach: the test runner will set up a few DUTs according to
a flag and pass all the test networks to the testbench. The testbench will only
reside in a single container. The testbench will put all the test networks into
a buffered channel which served as a semaphore and now the user can freely use
t.Parallel() in (sub)tests and the true parallelism will be determined by how
many DUTs are configured. Creating DUTs on demand is not supported yet, the
test author should determine the number of DUTs to be used statically.

Specifically in this change:
- Don't export any global variables about the test network in testbench.
- Sniffer only binds on the local interface because it will be possible to have
  multiple interfaces to multiple DUTs in a single testbench container.
- Migrate existing tests to stop using global variables.

PiperOrigin-RevId: 343965962
2020-11-23 18:13:07 -08:00
Adin Scannell 2320ce5b7d Fail gracefully if Docker is not configured with ipv6.
PiperOrigin-RevId: 343927315
2020-11-23 14:24:27 -08:00
Adin Scannell b6c00520d3 Omit sandbox from chown test.
This test fails because it must include additional UIDs. Omit
the bazel sandbox to ensure that it can function correctly.

PiperOrigin-RevId: 343927190
2020-11-23 14:18:20 -08:00
Adin Scannell 5d5af88110 Ignore permission failures in CheckDuplicatesRecursively.
Not all files are always accessible by the process itself. This
was specifically seen with map_files, but there's no rule that
every entry must be accessible by the process itself.

PiperOrigin-RevId: 343919117
2020-11-23 13:38:41 -08:00
gVisor bot ed8185fc75 Internal change.
PiperOrigin-RevId: 343419851
2020-11-19 20:03:53 -08:00
Fabricio Voznika 209a95a35a Propagate IP address prefix from host to netstack
Closes #4022

PiperOrigin-RevId: 343378647
2020-11-19 15:11:17 -08:00
Ghanan Gowripalan 27ee4fe76a Don't hold AddressEndpoints for multicast addresses
Group addressable endpoints can simply check if it has joined the
multicast group without maintaining address endpoints. This also
helps remove the dependency on AddressableEndpoint from
GroupAddressableEndpoint.

Now that group addresses are not tracked with address endpoints, we can
avoid accidentally obtaining a route with a multicast local address.

PiperOrigin-RevId: 343336912
2020-11-19 11:48:15 -08:00
Ayush Ranjan e5650d1240 [netstack] Move SO_KEEPALIVE and SO_ACCEPTCONN option to SocketOptions.
PiperOrigin-RevId: 343217712
2020-11-18 21:24:55 -08:00
Ayush Ranjan df37babd57 [netstack] Move SO_REUSEPORT and SO_REUSEADDR option to SocketOptions.
This changes also introduces:
- `SocketOptionsHandler` interface which can be implemented by endpoints to
  handle endpoint specific behavior on SetSockOpt. This is analogous to what
  Linux does.
- `DefaultSocketOptionsHandler` which is a default implementation of the above.
  This is embedded in all endpoints so that we don't have to uselessly
  implement empty functions. Endpoints with specific behavior can override the
  embedded method by manually defining its own implementation.

PiperOrigin-RevId: 343158301
2020-11-18 14:36:41 -08:00
Ayush Ranjan 3e73c519a5 [netstack] Move SO_NO_CHECK option to SocketOptions.
PiperOrigin-RevId: 343146856
2020-11-18 13:42:27 -08:00
Zeling Feng d2b701758d Remove the redundant containerIP parameter
PiperOrigin-RevId: 343144023
2020-11-18 13:29:03 -08:00
Ayush Ranjan fc342fb439 [netstack] Move SO_PASSCRED option to SocketOptions.
This change also makes the following fixes:
- Make SocketOptions use atomic operations instead of having to acquire/drop
  locks upon each get/set option.
- Make documentation more consistent.
- Remove tcpip.SocketOptions from socketOpsCommon because it already exists
  in transport.Endpoint.
- Refactors get/set socket options tests to be easily extendable.

PiperOrigin-RevId: 343103780
2020-11-18 10:19:33 -08:00
Fabricio Voznika e2d9a68eef Add support for TTY in multi-container
Fixes #2714

PiperOrigin-RevId: 342950412
2020-11-17 14:51:24 -08:00
Bhasker Hariharan 05d2a26f7a Fix possible deadlock in UDP.Write().
In UDP endpoint.Write() sendUDP is called with e.mu Rlocked. But if this happens
to send a datagram over loopback which ends up generating an ICMP response of
say ErrNoPortReachable, the handling of the response in HandleControlPacket also
acquires e.mu using RLock. This is mostly fine unless there is a competing
caller trying to acquire e.mu in exclusive mode using Lock(). This will deadlock
as a caller waiting in Lock() disallows an new RLocks() to ensure it can
actually acquire the Lock.

This is documented here https://golang.org/pkg/sync/#RWMutex.

This change releases the endpoint mutex before calling sendUDP to resolve the
possibility of the deadlock.

Reported-by: syzbot+537989797548c66e8ee3@syzkaller.appspotmail.com
Reported-by: syzbot+eb0b73b4ab486f7673ba@syzkaller.appspotmail.com
PiperOrigin-RevId: 342894148
2020-11-17 10:36:29 -08:00
Bhasker Hariharan fb9a649f39 Fix SO_ERROR behavior for TCP in gVisor.
Fixes the behaviour of SO_ERROR for tcp sockets where in linux it returns
sk->sk_err and if sk->sk_err is 0 then it returns sk->sk_soft_err. In gVisor TCP
we endpoint.HardError is the equivalent of sk->sk_err and endpoint.LastError
holds soft errors. This change brings this into alignment with Linux such that
both hard/soft errors are cleared when retrieved using getsockopt(.. SO_ERROR)
is called on a socket.

Fixes #3812

PiperOrigin-RevId: 342868552
2020-11-17 08:33:03 -08:00
Jamie Liu 267560d159 Reset watchdog timer between sendfile() iterations.
As part of this, change Task.interrupted() to not drain Task.interruptChan, and
do so explicitly using new function Task.unsetInterrupted() instead.

PiperOrigin-RevId: 342768365
2020-11-16 18:55:24 -08:00
Ghanan Gowripalan cc5cfce4c6 Remove ARP address workaround
- Make AddressableEndpoint optional for NetworkEndpoint.
Not all NetworkEndpoints need to support addressing (e.g. ARP), so
AddressableEndpoint should only be implemented for protocols that
support addressing such as IPv4 and IPv6.

With this change, tcpip.ErrNotSupported will be returned by the stack
when attempting to modify addresses on a network endpoint that does
not support addressing.

Now that packets are fully handled at the network layer, and (with this
change) addresses are optional for network endpoints, we no longer need
the workaround for ARP where a fake ARP address was added to each NIC
that performs ARP so that packets would be delivered to the ARP layer.

PiperOrigin-RevId: 342722547
2020-11-16 14:36:10 -08:00
Toshi Kikuchi 373fd83100 Add packetimpact tests for ICMPv6 Error message for fragment
Updates #4427

PiperOrigin-RevId: 342703931
2020-11-16 13:13:47 -08:00
Julian Elischer 0fee59c8c8 Requested Comment/Message wording changes
PiperOrigin-RevId: 342366891
2020-11-13 17:13:11 -08:00