Commit Graph

64 Commits

Author SHA1 Message Date
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
Mithun Iyer 61d6c059ac Replace use of %v in packetimpact tests
PiperOrigin-RevId: 316027588
2020-06-11 19:46:49 -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
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
Mithun Iyer f766366091 Handle TCP segment split cases as per MSS.
- Always split segments larger than MSS.
  Currently, we base the segment split decision as a function of the
  send congestion window and MSS, which could be greater than the MSS
  advertised by remote.
- While splitting segments, ensure the PSH flag is reset when there
  are segments that are queued to be sent.
- With TCP_CORK, hold up segments up until MSS. Fix a bug in computing
  available send space before attempting to coalesce segments.

Fixes #2832

PiperOrigin-RevId: 314802928
2020-06-05 11:28:24 -07:00
Mithun Iyer 162848e129 Avoid TCP segment split when out of sender window.
If the entire segment cannot be accommodated in the receiver advertised
window and if there are still unacknowledged pending segments, skip
splitting the segment. The segment transmit would get retried by the
retransmit handler.

PiperOrigin-RevId: 314538523
2020-06-03 08:49:49 -07:00
gVisor bot 474d9b2609 Internal change.
PiperOrigin-RevId: 314157710
2020-06-01 10:41:57 -07:00
Zeling Feng a9b47390c8 Test TCP should queue RECEIVE request in SYN-SENT
PiperOrigin-RevId: 313878910
2020-05-29 17:24:20 -07:00
Mithun Iyer 089c88f2e8 Move TCP to CLOSED from SYN-RCVD on RST.
RST handling is broken when the TCP state transitions
from SYN-SENT to SYN-RCVD in case of simultaneous open.
An incoming RST should trigger cleanup of the endpoint.
RFC793, section 3.9, page 70.

Fixes #2814

PiperOrigin-RevId: 313828777
2020-05-29 12:33:28 -07:00
gVisor bot 0baba92ad9 Internal change.
PiperOrigin-RevId: 313821986
2020-05-29 11:52:22 -07:00
Ian Gudger 7b79370c10 Add pcap logging to pcaketimpact.
This makes debugging packetimpact tests much easier.

PiperOrigin-RevId: 313662654
2020-05-28 14:43:48 -07:00
gVisor bot 92bafd7929 Automated rollback of changelist 311424257
PiperOrigin-RevId: 313300554
2020-05-26 17:40:57 -07:00
Zeling Feng 5f3eeb4728 Test that we have PAWS mechanism
If there is a Timestamps option in the arriving segment and SEG.TSval
< TS.Recent and if TS.Recent is valid, then treat the arriving segment
as not acceptable: Send an acknowledgement in reply as specified in
RFC-793 page 69 and drop the segment.

https://tools.ietf.org/html/rfc1323#page-19

PiperOrigin-RevId: 312590678
2020-05-20 17:53:35 -07:00
gVisor bot a338eed1d8 Internal change.
PiperOrigin-RevId: 312559963
2020-05-20 14:57:59 -07:00
Zeling Feng 99a18ec8b4 Support TCP options for packetimpact
PiperOrigin-RevId: 312119730
2020-05-18 11:31:38 -07:00
gVisor bot 326abf5e36 Internal change.
PiperOrigin-RevId: 311645222
2020-05-14 18:17:33 -07:00
Mithun Iyer f1ad2d54ab Fix TCP segment retransmit timeout handling.
As per RFC 1122 and Linux retransmit timeout handling:
- The segment retransmit timeout needs to exponentially increase and
  cap at a predefined value.
- TCP connection needs to timeout after a predefined number of
  segment retransmissions.
- TCP connection should not timeout when the retranmission timeout
  exceeds MaxRTO, predefined upper bound.

Fixes #2673

PiperOrigin-RevId: 311463961
2020-05-13 21:26:54 -07:00
Bhasker Hariharan 8605c97136 Automated rollback of changelist 311285868
PiperOrigin-RevId: 311424257
2020-05-13 16:13:37 -07:00
Ian Gudger e4058c0355 Replace test_runner.sh bash script with Go.
PiperOrigin-RevId: 311285868
2020-05-13 01:22:42 -07:00
gVisor bot 633e1b89bb Internal change.
PiperOrigin-RevId: 311011004
2020-05-11 15:54:08 -07:00
gVisor bot c5ab21b048 Internal change.
PiperOrigin-RevId: 310949277
2020-05-11 11:04:31 -07:00
Bhasker Hariharan e4d2d21f6b Add UDP send/recv packetimpact tests.
Fixes #2654

PiperOrigin-RevId: 310642216
2020-05-08 15:40:27 -07:00
Zeling Feng 5d7d5ed7d6 Send ACK to OTW SEQs/unacc ACKs in CLOSE_WAIT
This fixed the corresponding packetimpact test.

PiperOrigin-RevId: 310593470
2020-05-08 11:23:24 -07:00
gVisor bot 92cab8e2c3 Internal change.
PiperOrigin-RevId: 310409922
2020-05-07 12:10:02 -07:00
gVisor bot 4631de620a Internal change.
PiperOrigin-RevId: 310213705
2020-05-06 13:13:48 -07:00
Mithun Iyer e590314fec Support TCP zero window probes.
As per RFC 1122 4.2.2.17, when the remote advertizes zero receive window,
the sender needs to probe for the window-size to become non-zero starting
from the next retransmission interval. The TCP connection needs to be kept
open as long as the remote is acknowledging the zero window probes.
We reuse the retransmission timers to support this.

Fixes #1644

PiperOrigin-RevId: 310021575
2020-05-05 14:30:52 -07:00
gVisor bot e7ed68d225 Internal change.
PiperOrigin-RevId: 309832671
2020-05-04 15:48:45 -07:00
Adin Scannell 56c64e4bb9 Fix include type.
PiperOrigin-RevId: 309506957
2020-05-01 18:03:09 -07:00
gVisor bot e7b8a71156 Internal change.
PiperOrigin-RevId: 309467878
2020-05-01 13:52:21 -07:00
Zeling Feng 4875cda8d1 Make tcp_close_wait_ack_test more accurate
Previously the test used an out-dated window size which is advertised
during the handshake to generate testing packets, but the window size
has changed since the handshake; currently it is using the most recent
one which is advertised in DUT's ACK to our FIN packet to generate the
testing outside-the-window packets.

PiperOrigin-RevId: 309222921
2020-04-30 07:40:34 -07:00
gVisor bot 24abccbc1c Internal change.
PiperOrigin-RevId: 308940886
2020-04-28 18:50:44 -07:00
Eyal Soha dfff265fe4 Add ICMP6 param problem test
Tested:
  When run on Linux, a correct ICMPv6 response is received.  On netstack, no
  ICMPv6 response is received.
PiperOrigin-RevId: 308343113
2020-04-24 15:56:27 -07:00
Eyal Soha 3d860530a9 Better error message from ExpectFrame
Display the errors as diffs between the expected and wanted frame.

PiperOrigin-RevId: 308333271
2020-04-24 15:04:03 -07:00
Eyal Soha d5776be3fb Improve and update packetimpact README.md
PiperOrigin-RevId: 308328860
2020-04-24 14:43:02 -07:00
Adin Scannell c60613475c Standardize all Docker images.
This change moves all Docker images to a standard location, and abstracts the
build process so that they can be maintained in an automated fashion. This also
allows the images to be architecture-independent.

All images will now be referred to by the test framework via the canonical
`gvisor.dev/images/<name>`, where `<name>` is a function of the path within the
source tree.

In a subsequent change, continuous integration will be added so that the images
will always be correct and available locally.

In the end, using `bazel` for Docker containers is simply not possible. Given
that we already have the need to use `make` with the base container (for
Docker), we extend this approach to get more flexibility.

This change also adds a self-documenting and powerful Makefile that is intended
to replace the collection of scripts in scripts. Canonical (self-documenting)
targets can be added here for targets that understand which images need to be
loaded and/or built.

PiperOrigin-RevId: 308322438
2020-04-24 14:11:42 -07:00
Eyal Soha 79542417fe Fix Layer merge and add unit tests
mergo was improperly merging nil and empty strings

PiperOrigin-RevId: 308170862
2020-04-23 18:24:31 -07:00
Eyal Soha cc5de905e6 Fix test output so that filenames have the correct path.
Tested:
  Intentionally introduce an error and then run:
  blaze test --test_output=streamed //third_party/gvisor/test/packetimpact/tests:tcp_outside_the_window_linux_test
PiperOrigin-RevId: 308114194
2020-04-23 13:18:59 -07:00
Adin Scannell 1481499fe2 Simplify Docker test infrastructure.
This change adds a layer of abstraction around the internal Docker APIs,
and eliminates all direct dependencies on Dockerfiles in the infrastructure.

A subsequent change will automated the generation of local images (with
efficient caching). Note that this change drops the use of bazel container
rules, as that experiment does not seem to be viable.

PiperOrigin-RevId: 308095430
2020-04-23 11:33:30 -07:00
Eyal Soha a2925a079f Run failing packetimpact test and expect failure.
This will make it easier to notice if a code change causes an existing test to
pass.

PiperOrigin-RevId: 308057978
2020-04-23 08:36:19 -07:00
Eyal Soha 6d23673e10 Add comments about deepcopy in Layer.incoming()
PiperOrigin-RevId: 307812340
2020-04-22 07:28:39 -07:00
gVisor bot 0e013d8b00 Don't ignore override if it is longer than layerStates
PiperOrigin-RevId: 307708653
2020-04-21 16:55:28 -07:00
Eyal Soha db2a60be67 Don't accept segments outside the receive window
Fixed to match RFC 793 page 69.

Fixes #1607

PiperOrigin-RevId: 307334892
2020-04-19 22:16:14 -07:00
Eyal Soha 08b2fd9bc2 Convert tcp_user_timeout test from packetdrill to packetimpact.
PiperOrigin-RevId: 307328289
2020-04-19 20:49:06 -07:00
Eyal Soha 75e864fc75 Use multierr in packetimpact Connection.Close()
PiperOrigin-RevId: 306930652
2020-04-16 15:15:50 -07:00
gVisor bot eb7b1903e0 Test TCP behavior when receiving unacceptable segment in CLOSE_WAIT
TCP, in CLOSE-WAIT state, MUST return ACK with proper SEQ and ACK numbers after
recv a seg with OTW SEQ or unacc ACK number, and remain in same state. If the
connection is in a synchronized state, any unacceptable segment (out of window
sequence number or unacceptable acknowledgment number) must elicit only an empty
acknowledgment segment containing the current send-sequence number and an
acknowledgment indicating the next sequence number expected to be received, and
the connection remains in the same state.

PiperOrigin-RevId: 306897984
2020-04-16 12:22:17 -07:00
Eyal Soha 09c7e3f6e4 Add tests for segments outside the receive window.
The tests are based on RFC 793 page 69.

Updates #1607

PiperOrigin-RevId: 306768847
2020-04-15 19:37:00 -07:00
Eyal Soha 3d3bf9603d Use hex.Dump for Layer.String() of byte slices.
PiperOrigin-RevId: 306726587
2020-04-15 14:59:15 -07:00
Eyal Soha 1bcc2bf17f Refactor connections.go to make it easier to add new connection types.
Rather than have a struct for the state of each type of connection, such as
TCP/IPv4, UDP/IPv4, TCP/IPv6, etc, have a state for each layer, such as UDP,
TCP, IPv4, IPv6.  Those states can be composed into connections.

Tested:
  Existing unit tests still pass/fail as expected.
PiperOrigin-RevId: 306703180
2020-04-15 13:01:11 -07:00
Mithun Iyer 9c918340e4 Reset pending connections on listener close
Attempt to redeliver TCP segments that are enqueued into a closing
TCP endpoint. This was being done for Established endpoints but not
for those that are listening or performing connection handshake.

Fixes #2417

PiperOrigin-RevId: 306598155
2020-04-15 01:11:44 -07:00
gVisor bot 81c44c4cd7 Test TCP should piggyback ACK in ESTAB state
TCP, in ESTABLISHED state, SHOULD piggyback acknowledgement with a segment being
transmitted (whenever possible) without incurring undue delay

PiperOrigin-RevId: 306474550
2020-04-14 11:05:38 -07:00