summaryrefslogtreecommitdiffhomepage
path: root/test/packetimpact/tests
AgeCommit message (Collapse)Author
2020-12-09Refactor the Makefile to avoid recursive Make.Adin Scannell
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-05Fix zero receive window advertisements.Mithun Iyer
With the recent changes db36d948fa63ce950d94a5e8e9ebc37956543661, 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-02Abandon reassembly of a packet if fragments overlapArthur Sfez
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-11-25[3/3] Support isolated containers for parallel packetimpact testsZeling Feng
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-24[2/3] Support isolated containers for parallel packetimpact testsZeling Feng
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-23[1/3] Support isolated containers for parallel packetimpact testsZeling Feng
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-16Add packetimpact tests for ICMPv6 Error message for fragmentToshi Kikuchi
Updates #4427 PiperOrigin-RevId: 342703931
2020-11-09Additions to ICMP and IPv4 parsersJulian Elischer
Teach ICMP.Parser/ToBytes to handle some non echo ICMP packets. Teach IPv4.Parser that fragments only have a payload, not an upper layer. Fix IPv4 and IPv6 reassembly tests to handle the change. Fixes #4758 PiperOrigin-RevId: 341549665
2020-10-29Add IPv4 reassembly packetimpact testArthur Sfez
The IPv6 reassembly test was also refactored to be easily extended with more cases. PiperOrigin-RevId: 339768605
2020-10-28Add the payload directly to the ICMPv4 typeArthur Sfez
This makes handling inbound fragmented packets easier, because a fragmented packet might not have an actual ICMP header but only a payload. After this change, the ICMPv4 is the last layer you can get because the payload is embedded in it. Note that this makes it consistent with the ICMPv6 implementation. While I'm here, I've also added the Ident and Sequence fields on the ICMPv4 type. Defaults are still zero. PiperOrigin-RevId: 339577094
2020-10-15Syncing packetimpact tests in different directoriesZeling Feng
By exposing an ALL_TESTS list in defs.bzl we can make sure all packetimpact users get to agree on the list of all tests. A defect in this approach is that we have to keep a list of packetimpact_testbench rules in the BUILD file. An helper validate_all_tests has been added to help keep BUILD and .bzl files in sync. PiperOrigin-RevId: 337411839
2020-10-09Set expect_failure flags on tests that currently fails on fuchsiaZeling Feng
PiperOrigin-RevId: 336350318
2020-10-06Add support for IPv6 fragmentationArthur Sfez
Most of the IPv4 fragmentation code was moved in the fragmentation package and it is reused by IPv6 fragmentation. Test: - pkg/tcpip/network/ipv4:ipv4_test - pkg/tcpip/network/ipv6:ipv6_test - pkg/tcpip/network/fragmentation:fragmentation_test Fixes #4389 PiperOrigin-RevId: 335714280
2020-09-28Fix lingering of TCP socket in the initial state.Nayana Bidari
When the socket is set with SO_LINGER and close()'d in the initial state, it should not linger and return immediately. PiperOrigin-RevId: 334263149
2020-09-24Change segment/pending queue to use receive buffer limits.Bhasker Hariharan
segment_queue today has its own standalone limit of MaxUnprocessedSegments but this can be a problem in UnlockUser() we do not release the lock till there are segments to be processed. What can happen is as handleSegments dequeues packets more keep getting queued and we will never release the lock. This can keep happening even if the receive buffer is full because nothing can read() till we release the lock. Further having a separate limit for pending segments makes it harder to track memory usage etc. Unifying the limits makes it easier to reason about memory in use and makes the overall buffer behaviour more consistent. PiperOrigin-RevId: 333508122
2020-09-18Enqueue TCP sends arriving in SYN_SENT state.Mithun Iyer
TCP needs to enqueue any send requests arriving when the connection is in SYN_SENT state. The data should be sent out soon after completion of the connection handshake. Fixes #3995 PiperOrigin-RevId: 332482041
2020-09-16Automated rollback of changelist 329526153Nayana Bidari
PiperOrigin-RevId: 332097286
2020-09-14Test RST handling in TIME_WAIT.Mithun Iyer
gVisor stack ignores RSTs when in TIME_WAIT which is not the default Linux behavior. Add a packetimpact test to test the same. Also update code comments to reflect the rationale for the current gVisor behavior. PiperOrigin-RevId: 331629879
2020-09-01Fix handling of unacceptable ACKs during close.Mithun Iyer
On receiving an ACK with unacceptable ACK number, in a closing state, TCP, needs to reply back with an ACK with correct seq and ack numbers and remain in same state. This change is as per RFC793 page 37, but with a difference that it does not apply to ESTABLISHED state, just as in Linux. Also add more tests to check for OTW sequence number and unacceptable ack numbers in these states. Fixes #3785 PiperOrigin-RevId: 329616283
2020-09-01Automated rollback of changelist 328350576Nayana Bidari
PiperOrigin-RevId: 329526153
2020-08-31Set errno on response when syscall actually failsJay Zhuang
This prevents setting stale errno on responses. Also fixes TestDiscardsUDPPacketsWithMcastSourceAddressV6 to use correct multicast addresses in test. Fixes #3793 PiperOrigin-RevId: 329391155
2020-08-25Support SO_LINGER socket option.Nayana Bidari
When SO_LINGER option is enabled, the close will not return until all the queued messages are sent and acknowledged for the socket or linger timeout is reached. If the option is not set, close will return immediately. This option is mainly supported for connection oriented protocols such as TCP. PiperOrigin-RevId: 328350576
2020-08-14Give the ICMP Code its own typeJulian Elischer
This is a preparatory commit for a larger commit working on ICMP generation in error cases. This is removal of technical debt and cleanup in the gvisor code as part of gvisor issue 2211. Updates #2211. PiperOrigin-RevId: 326615389
2020-08-06Merge pull request #3511 from amscanne:packetimpact-testsgVisor bot
PiperOrigin-RevId: 325269275
2020-08-06Join IPv4 all-systems group on NIC enableGhanan Gowripalan
Test: - stack_test.TestJoinLeaveMulticastOnNICEnableDisable - integration_test.TestIncomingMulticastAndBroadcast PiperOrigin-RevId: 325185259
2020-08-04Enable "make packetimpact-tests" to work.Adin Scannell
This required minor fixes to the bazel wrapper. The "dut_platform" is also changed to "native" to line-up with the system call tests and remove the hard-coded "linux" and "netstack" strings.
2020-07-29Test UDP socket bound to ANY can receive unicastJay Zhuang
PiperOrigin-RevId: 323773771
2020-07-28More test cases on receiving UDP mcast/bcastJay Zhuang
PiperOrigin-RevId: 323553832
2020-07-27Ask for *testing.T instead of storing itJay Zhuang
Storing *testing.T on test helper structs is problematic when subtests are used, because it is possible for nested tests to call Fatal on parent test, which incorrect terminates the parent test. For example func TestOuter(t *testing.T) { dut := NewDUT(t) t.Run("first test", func(t *testing.T) { dut.FallibleCall() }) t.Run("second test", func(t *testing.T) { dut.FallibleCall() } } In the example above, assuming `FallibleCall` calls `t.Fatal` on the `t` it holds, if `dut.FallibleCall` fails in "first test", it will call `Fatal` on the parent `t`, quitting `TestOuter`. This is not a behavior we want. PiperOrigin-RevId: 323350241
2020-07-22make connect(2) fail when dest is unreachableKevin Krakauer
Previously, ICMP destination unreachable datagrams were ignored by TCP endpoints. This caused connect to hang when an intermediate router couldn't find a route to the host. This manifested as a Kokoro error when Docker IPv6 was enabled. The Ruby image test would try to install the sinatra gem and hang indefinitely attempting to use an IPv6 address. Fixes #3079.
2020-07-17Test UDP packets with mcast source addr are discardedJay Zhuang
PiperOrigin-RevId: 321790802
2020-07-14Test IPv6 fragment reassemblyZeling Feng
A packetimpact test for: "A node must be able to accept a fragmented packet that, after reassembly, is as large as 1500 octets." PiperOrigin-RevId: 321210729
2020-07-14Add support for UDP IPv6Jay Zhuang
Also ironed out all the bugs found on the IPv6 code path that affects socket bind, send and receive. PiperOrigin-RevId: 321202653
2020-07-13Create packetimpact test for UDP broadcastJay Zhuang
PiperOrigin-RevId: 321000340
2020-07-07Set IPv4 ID on all non-atomic datagramsTony Gong
RFC 6864 imposes various restrictions on the uniqueness of the IPv4 Identification field for non-atomic datagrams, defined as an IP datagram that either can be fragmented (DF=0) or is already a fragment (MF=1 or positive fragment offset). In order to be compliant, the ID field is assigned for all non-atomic datagrams. Add a TCP unit test that induces retransmissions and checks that the IPv4 ID field is unique every time. Add basic handling of the IP_MTU_DISCOVER socket option so that the option can be used to disable PMTU discovery, effectively setting DF=0. Attempting to set the sockopt to anything other than disabled will fail because PMTU discovery is currently not implemented, and the default behavior matches that of disabled. PiperOrigin-RevId: 320081842
2020-07-03Improve failure messageTamir Duberstein
Currently this test produces an error resembling tcp_zero_window_probe_retransmit_test.go:92: zero probe came sooner interval 3200179405 probe 4 which is approximately useless. PiperOrigin-RevId: 319572263
2020-07-01TCP receive should block when in SYN-SENT state.Mithun Iyer
The application can choose to initiate a non-blocking connect and later block on a read, when the endpoint is still in SYN-SENT state. PiperOrigin-RevId: 319311016
2020-06-30Fix two bugs in TCP sender.Bhasker Hariharan
a) When GSO is in use we should not cap the segment to maxPayloadSize in sender.maybeSendSegment as the GSO logic will cap the segment to the correct size. Without this the host GSO is not used as we end up breaking up large segments into small MSS sized segments before writing the packets to the host. b) The check to not split a segment due to it not fitting in the receiver window when there are pending segments is incorrect as segments in writeList can be really large as we just take the write call's buffer size and create a single large segment. So a write of say 128KB will just be 1 segment in the writeList. The linux code checks if 1 MSS sized segments fits in the receiver's window and if not then does not split the current segment. gVisor's check was incorrect that it was checking if the whole segment which could be >>> 1 MSS would fit in the receiver's window. This was causing us to prematurely stop sending and falling back to retransmit timer/probe from the other end to send data. This was seen when running HTTPD benchmarks where @ HEAD when sending large files the benchmark was taking forever to run. The tcp_splitseg_mss_test.go is being deleted as the test as written doesn't test what is intended correctly. This is because GSO is enabled by default and the reason the MSS+1 sized segment is sent is because GSO is in use. A proper test will require disabling GSO on linux and netstack which is going to take a bit of work in packetimpact to do it correctly. Separately a new test probably should be written that verifies that a segment > availableWindow is not split if the availableWindow is < 1 MSS. Fixes #3107 PiperOrigin-RevId: 319172089
2020-06-26Packetimpact test for IPv6 unknown options actionZeling Feng
The Option Type identifiers are internally encoded such that their highest-order two bits specify the action that must be taken if the processing IPv6 node does not recognize the Option Type: 00 - skip over this option and continue processing the header. 01 - discard the packet. 10 - discard the packet and, regardless of whether or not the packet's Destination Address was a multicast address, send an ICMP Parameter Problem, Code 2, message to the packet's Source Address, pointing to the unrecognized Option Type. 11 - discard the packet and, only if the packet's Destination Address was not a multicast address, send an ICMP Parameter Problem, Code 2, message to the packet's Source Address, pointing to the unrecognized Option Type. PiperOrigin-RevId: 318566613
2020-06-15TCP to honor updated window size during handshake.Mithun Iyer
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-12Make GenerateRandomPayload available to all testsTony Gong
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-11Replace use of %v in packetimpact testsMithun Iyer
PiperOrigin-RevId: 316027588
2020-06-11Add test for reordering.Ian Gudger
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-11Refactor packetimpact Connection typesgVisor bot
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-05Handle TCP segment split cases as per MSS.Mithun Iyer
- 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-03Avoid TCP segment split when out of sender window.Mithun Iyer
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-05-29Test TCP should queue RECEIVE request in SYN-SENTZeling Feng
PiperOrigin-RevId: 313878910
2020-05-29Move TCP to CLOSED from SYN-RCVD on RST.Mithun Iyer
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-29Internal change.gVisor bot
PiperOrigin-RevId: 313821986
2020-05-26Automated rollback of changelist 311424257gVisor bot
PiperOrigin-RevId: 313300554