Commit Graph

183 Commits

Author SHA1 Message Date
Zach Koopmans 8a2f7e716d [syserror] Split usermem package
Split usermem package to help remove syserror dependency in go_marshal.
New hostarch package contains code not dependent on syserror.

PiperOrigin-RevId: 365651233
2021-03-29 13:30:21 -07:00
Zeling Feng 9e86dfc9c5 Fix logs for packetimpact tests cleanup
- Don't cleanup containers in Network.Cleanup, otherwise containers will
  be killed and removed several times.
- Don't set AutoRemove for containers. This will prevent the confusing
  'removal already in progress' messages.

Fixes #3795

PiperOrigin-RevId: 364404414
2021-03-22 14:10:00 -07:00
Zeling Feng cbac2d9f97 Fix and merge tcp_{outside_the_window,tcp_unacc_seq_ack}_closing
The tests were not using the correct windowSize so the testing segments were
actually within the window for seqNumOffset=0 tests. The issue is already fixed
by #5674.

PiperOrigin-RevId: 364252630
2021-03-22 00:06:18 -07:00
Zeling Feng 3dd7ad13b4 Fix tcp_fin_retransmission_netstack_test
Netstack does not check ACK number for FIN-ACK packets and goes into TIMEWAIT
unconditionally. Fixing the state machine will give us back the retransmission
of FIN.

PiperOrigin-RevId: 363301883
2021-03-16 16:59:26 -07:00
Zeling Feng 06b047a5a8 Packetimpact test for ACK to OTW Seq segments behavior in CLOSING
TCP, in CLOSING state, MUST send an ACK with next expected SEQ number after
receiving any segment with OTW SEQ number and remain in the same state.
While I am here, I also changed shutdown to behave the same as other calls
in posix_server.

PiperOrigin-RevId: 362976955
2021-03-15 10:47:58 -07:00
Mithun Iyer b9c2174b08 Fix race in tcp_retransmits_test
The test queries for RTO via TCP_INFO and applies that to the
rest of the test. The RTO is estimated by processing incoming ACK.
There is a race in the test where we may query for RTO before the
incoming ACK was processed. Fix the race in the test by letting the
DUT complete a payload receive, thus estimating RTO before proceeding
to query the RTO. Bump up the time correction to reduce flakes.

PiperOrigin-RevId: 362865904
2021-03-14 22:30:25 -07:00
Zeling Feng ab488702a6 Support ICMP echo sockets on Linux DUT
By default net.ipv4.ping_group_range is set to "1 0" and no one (even the root)
can create an ICMP socket. Setting it to "0 0" allows root, which we are inside
the container, to create ICMP sockets for packetimpact tests.

PiperOrigin-RevId: 362454201
2021-03-11 22:37:10 -08:00
Zeling Feng 2a888a106d Give TCP flags a dedicated type
- Implement Stringer for it so that we can improve error messages.
- Use TCPFlags through the code base. There used to be a mixed usage of byte,
  uint8 and int as TCP flags.

PiperOrigin-RevId: 361940150
2021-03-09 18:00:03 -08:00
Mithun Iyer 5a75a93202 Avoid a race with test peer advert and DUT send
Fix a race where the DUT could send out test data before it received the
peer window advertisement. Such a race results in the DUT taking longer
time to retransmit zero window probe, thus causing the test to fail
receiving the last expected probe.

To ensure this ordering, piggyback a non-zero payload with the zero
window advertisement and let the DUT receive that, before continuing
with the test.

PiperOrigin-RevId: 361640241
2021-03-08 13:18:01 -08:00
Ayush Ranjan 0a909ba75a [op] Replace syscall package usage with golang.org/x/sys/unix in test/.
The syscall package has been deprecated in favor of golang.org/x/sys.

Note that syscall is still used in some places because the following don't seem
to have an equivalent in unix package:
- syscall.SysProcIDMap
- syscall.Credential

Updates #214

PiperOrigin-RevId: 361332034
2021-03-06 09:54:09 -08:00
Zeling Feng 2f0b82a802 Gather uname information from DUT
Some OSs behave slightly differently, but still within the RFC. It can be useful
to have access to uname information from the testbench.

PiperOrigin-RevId: 361193766
2021-03-05 11:56:31 -08:00
Ting-Yu Wang 1cd76d958a Make dedicated methods for data operations in PacketBuffer
One of the preparation to decouple underlying buffer implementation.
There are still some methods that tie to VectorisedView, and they will be
changed gradually in later CLs.

This CL also introduce a new ICMPv6ChecksumParams to replace long list of
parameters when calling ICMPv6Checksum, aiming to be more descriptive.

PiperOrigin-RevId: 360778149
2021-03-03 16:05:16 -08:00
Zeling Feng 32578a591c Use struct embedding to avoid casts and reuse methods
- Removed (*testbench.Connection)(&conn) like casts
- Removed redundant definition of Drain, Close and ExpectFrame

PiperOrigin-RevId: 360727788
2021-03-03 12:13:41 -08:00
Tamir Duberstein 8e78d0eda6 Emit the error
Without this change, the error produced is quite useless:

  --- FAIL: TestZeroWindowProbeRetransmit (11.44s)
      tcp_zero_window_probe_retransmit_test.go:81: expected a probe with sequence number 824638527212: loop 5
  FAIL

PiperOrigin-RevId: 359796370
2021-02-26 11:11:33 -08:00
Zeling Feng 67761345c8 Move SetNonblocking into posix_server
- open flags can be different on different OSs, by putting SetNonblocking into
the posix_server rather than the testbench, we can always get the right value
for O_NONBLOCK
- merged the tcp_queue_{send,receive}_in_syn_sent into a single file

PiperOrigin-RevId: 359620630
2021-02-25 15:01:14 -08:00
Tamir Duberstein 26eada5dea Use standard want/got syntax in test errors
Remove unused argument while I'm here and avoid returning
syscall.Errno(0) which should rather be a nil error.

PiperOrigin-RevId: 358227396
2021-02-18 11:46:00 -08:00
Zeling Feng f4d694693c Deflake tcp_network_unreachable test
Previously, we make two connect attempts. If the first attempt is still on
going when the second attempt is made, the test will fail. This change deflakes
the situation by not making the second attempt, instead, we poll for the first
attempt's completion and read the errno from SO_ERROR.

PiperOrigin-RevId: 358104769
2021-02-17 22:07:06 -08:00
Nayana Bidari 3145fe1d1e Use TCP_INFO to get RTO in tcp_retransmits_test
- TCP_INFO is used to get the RTO instead of calculating it manually.

PiperOrigin-RevId: 358032487
2021-02-17 14:25:29 -08:00
Tamir Duberstein 0e0bc35879 Clean up test style
- Wrap comments at 80 columns
- Avoid duplicating the number of retries (5)
- Reduce indentation
- Use (*testing.T).Fatal rather than (*testing.T).Fatalf

PiperOrigin-RevId: 358017412
2021-02-17 13:17:06 -08:00
Nayana Bidari 33c617cae3 Remove packetimpact test tcp_reordering
Remove flaky tcp_reordering_test as it does not check reordering. We have
added new reorder tests in tcp_rack_test.go

PiperOrigin-RevId: 357278769
2021-02-12 15:27:29 -08:00
Mithun Iyer 380ede9b73 Retry RST expectation in tcp_synrcvd_reset_test
Deflake this test by retransmitting the ACK and retrying RST
expectation after the supposed state transition to CLOSED.
This gives time for the state transition to complete.

Without such a retransmit from the test, the ACK could get silently
dropped by the listener when the passively connecting endpoint
has not yet completely updated the state (in gVisor this would be
endpoint state and decrement of synRcvdCount).

PiperOrigin-RevId: 356825562
2021-02-10 14:22:16 -08:00
Zeling Feng 2de36e44ed Make RPCTimeout for udp_send_recv_dgram to be 500 milliseconds.
The test will sometimes fail on Bind calls using the old RPCTimeout.

PiperOrigin-RevId: 356646668
2021-02-09 19:32:47 -08:00
Nayana Bidari eaba5bc7ef Fix flaky packetimpact test
PiperOrigin-RevId: 355645297
2021-02-04 09:38:35 -08:00
Bhasker Hariharan 8c7c5abafb Add support for rate limiting out of window ACKs.
Netstack today will send dupACK's with no rate limit for incoming out of
window segments. This can result in ACK loops for example if a TCP socket
connects to itself (actually permitted by TCP). Where the ACK sent in
response to packets being out of order itself gets considered as an out
of window segment resulting in another ACK being generated.

PiperOrigin-RevId: 355206877
2021-02-02 11:05:28 -08:00
Nayana Bidari d3855ad6bd Add RACK reorder tests.
PiperOrigin-RevId: 355067082
2021-02-01 18:00:38 -08:00
Tamir Duberstein 726100f8eb Assert expected size before unmarshalling
...to prevent panicking in case of failure.

PiperOrigin-RevId: 354970257
2021-02-01 10:29:39 -08:00
Arthur Sfez b4357939c0 Re-enable ipv4 reassembly packetimpact tests
When these specific tests were first added, they would fail when ran by
kokoro during the presubmit tests (but they always passed locally).
These tests are now passing, so they can be re-enabled. Unclear what
changed, one hypothesis is the move from kokoro to buildkite.

Fixes #4971

PiperOrigin-RevId: 354425395
2021-01-28 16:54:24 -08:00
Zeling Feng bc4039353d Make tcp_noaccept_close_rst more robust
There used to be a race condition where we may call Close before the connection
is established. Adding poll support so that we can eliminate this kind of race.

Startblock:
  has LGTM from iyerm
  and then
  add reviewer tamird
PiperOrigin-RevId: 354369130
2021-01-28 12:31:56 -08:00
Marina Ciocea 6012fe9b59 Respect SO_BINDTODEVICE in unconnected UDP writes
Previously, sending on an unconnected UDP socket would ignore the
SO_BINDTODEVICE option. Send on the configured interface when an UDP socket
is bound to an interface through setsockop SO_BINDTODEVICE.

Add packetimpact tests exercising UDP reads and writes with every combination
of bound/unbound, broadcast/multicast/unicast destination, and bound/not-bound
to device.

PiperOrigin-RevId: 354299670
2021-01-28 06:24:46 -08:00
Nayana Bidari 99988e45ed Add support for more fields in netstack for TCP_INFO
This CL adds support for the following fields:
- RTT, RTTVar, RTO
- send congestion window (sndCwnd) and send slow start threshold (sndSsthresh)
- congestion control state(CaState)
- ReorderSeen

PiperOrigin-RevId: 354195361
2021-01-27 16:14:50 -08:00
Mithun Iyer de3c63cd9d Deflake tcp_zero_window_probe_retransmit_test
Fix the test to rely on more deterministic retransmission interval
computations by skipping the initial probe transmission time as that
can be non-deterministic given arbitrary time taken for the DUT to
receive a send command and initiate a send.

Fixes #5080

PiperOrigin-RevId: 354146256
2021-01-27 12:27:18 -08:00
Nayana Bidari 527ef5fc03 Add tests for RACK
- Added packetimpact tests for RACK.

PiperOrigin-RevId: 353282342
2021-01-22 11:38:46 -08:00
Adin Scannell 4e03e87547 Fix simple mistakes identified by goreportcard.
These are primarily simplification and lint mistakes. However, minor
fixes are also included and tests added where appropriate.

PiperOrigin-RevId: 351425971
2021-01-12 12:38:22 -08:00
Adin Scannell b06e5bc5b0 Add benchmarks targets to BuildKite.
This includes minor fix-ups:

* Handle SIGTERM in runsc debug, to exit gracefully.
* Fix cmd.debug.go opening all profiles as RDONLY.
* Fix the test name in fio_test.go, and encode the block size in the test.

PiperOrigin-RevId: 350205718
2021-01-05 13:21:54 -08:00
Mithun Iyer b645fcd241 Ensure correctness of saved receive window
When the scaled receive window size > 65535 (max uint16), we advertise
the scaled value as 65535, but are not adjusting the saved receive
window value when doing so. This would keep our current window
calculation logic to be incorrect, as the saved receive window value
is different from what was advertised.

Fixes #4903

PiperOrigin-RevId: 347771340
2020-12-16 00:24:28 -08:00
Bruno Dal Bo 4aef908c92 Introduce IPv6 extension header serialization facilities
Adds IPv6 extension header serializer and Hop by Hop options serializer.
Add RouterAlert option serializer and use it in MLD.

Fixed #4996

Startblock:
  has LGTM from marinaciocea
  and then
  add reviewer ghanan
PiperOrigin-RevId: 347174537
2020-12-12 09:07:44 -08:00
Tamir Duberstein 01126d47fc Log window size
Without this change, this test produces quite opaque errors as valid TCP
segments are not logged; what we see in the end is any random traffic that
happened *after* the final TCP segment.

PiperOrigin-RevId: 346864169
2020-12-10 14:23:10 -08:00
Tamir Duberstein 7fa0a57fc9 Uncomment payload generation
PiperOrigin-RevId: 346852543
2020-12-10 13:27:43 -08:00
Tamir Duberstein 205015687b Correctly align non-matching layers
PiperOrigin-RevId: 346840424
2020-12-10 12:27:46 -08:00
Tamir Duberstein a177bfdbc4 Correctly print non-matching layers
PiperOrigin-RevId: 346818310
2020-12-10 10:52:13 -08:00
Adin Scannell a855a814d6 Refactor the Makefile to avoid recursive Make.
Recursive make is difficult to follow and debug. Drop this by using
internal functions, which, while difficult, are easier than trying to
following recursive invokations.

Further simplify the Makefile by collapsing the image bits and removing
the tools/vm directory, which is effectively unused.

Fixes #4952

PiperOrigin-RevId: 346569133
2020-12-09 15:53:23 -08:00
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
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
Tamir Duberstein 432964d035 Avoid shadowing `testbench` package
PiperOrigin-RevId: 346109185
2020-12-07 09:28:38 -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
Bruno Dal Bo fd28ccfaa4 Introduce IPv4 options serializer and add RouterAlert to IGMP
PiperOrigin-RevId: 345701623
2020-12-04 10:10:56 -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
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