Commit Graph

12 Commits

Author SHA1 Message Date
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 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
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
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
Jay Zhuang a6b4538ae0 Test UDP socket bound to ANY can receive unicast
PiperOrigin-RevId: 323773771
2020-07-29 06:23:23 -07:00
Jay Zhuang cf7141fb43 Ask for *testing.T instead of storing it
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-27 06:39:06 -07:00
Jay Zhuang 822fc99ecd Add support for UDP IPv6
Also ironed out all the bugs found on the IPv6 code path that affects socket
bind, send and receive.

PiperOrigin-RevId: 321202653
2020-07-14 11:49:51 -07:00
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
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
gVisor bot 633e1b89bb Internal change.
PiperOrigin-RevId: 311011004
2020-05-11 15:54:08 -07:00
Bhasker Hariharan e4d2d21f6b Add UDP send/recv packetimpact tests.
Fixes #2654

PiperOrigin-RevId: 310642216
2020-05-08 15:40:27 -07:00