The reconnect for UDP sockets was failing because we were not removing the old
registration before attempting to register again. Fix this issue by
removing the old registration and then registering the endpoint.
Updates #8998
PiperOrigin-RevId: 582007411
Add a test that validates that when a UDP packet is received with a source port
value of 0, it is delivered to a listening socket.
PiperOrigin-RevId: 536773375
- Enables the test to set/get SO_NO_CHECK option on hostinet as this option is
already supported on hostinet.
- Enables all the other UDP hostinet tests except the flaky test to set/get
IP_RECVTOS option.
PiperOrigin-RevId: 525792961
The `ConnectAndSendNoReceiver` test tries to setup a scenario in which a socket
sends to an address with no listener, asserting on the returned ICMP error.
In the existing code, this is done by closing a socket and then
connecting/sending to its bound address with another socket. This is flaky
because sometimes the system will coincidentally bind the sender to the bound
address of the receiver, in which case we won't get the ICMP error. The fix is
to connect before the socket is closed (that way the sender will get a
different port than the boudn address).
PiperOrigin-RevId: 518612786
Set the ICMP poll timeout to a negative value so the poll will block
indefinitely. This effectively delegates the timeout to the overall test
timeout imposed by Fuchsia's CI/CQ.
PiperOrigin-RevId: 516863038
We are still hitting the occasional flake in Fuchsia's CQ when polling for an
ICMP error. Increase the timeout from 2s => 5s.
PiperOrigin-RevId: 509655650
In the ConnectWriteToInvalidPort test case, the target socket is closed before
the source socket sends data to generate and then verify reception of an ICMP
error packet. If the target socket is closed before an outgoing port number is
picked for the source socket, the source socket might be assigned the same
port number for sending as its destination. The result is that the source
socket receives the packet it sends and so no error is generated. This results
in test flakiness, though with very low probability.
Fixes#8338
PiperOrigin-RevId: 499244574
Some of the UDP tests bind a socket with port 0, read the bound port number,
then connect using 1+bound port as the port number. This can roll over if the
originally bound port is 2^16-1, which makes for test cases that are very
infrequently flaky on systems with an ephemeral port range that includes
2^16-1. Fix this by using bound port-1, which should never underflow since the
bound port isn't 0, and should always be in a usable range, even if it is
below the ephemeral port range.
PiperOrigin-RevId: 496996446
The existing logic constructs a loopback address for binding by incrementing
the port number of an existing address. This can lead to failures in the event
that the original address had port=65535 (the maximum port). Resolve this
failure case by using the same port number instead of incrementing.
PiperOrigin-RevId: 488934780
The existing logic constructs a loopback address for binding by incrementing
the port number of an existing address. This can lead to failures in the event
that the original address had port=65535 (the maximum port). Resolve this
failure case by just binding to a new loopback address and letting the system
pick the port.
Also, fix a bug in `ReceiveFromNotConnected` in which the test was asserting on
the wrong socket.
PiperOrigin-RevId: 482260609
Includes the following diffs:
- Use timeouts when reading immediately after sending.
- Poll for POLLIN before operations that assume data has arrived.
- Expect`SendMsgTooLarge` passes with Fast UDP (error code is correct now).
- Skip `RecvBufLimits` on Fast UDP (limits not enforced due to zircon socket).
Fuchsia Bug: 101888
PiperOrigin-RevId: 459857293
Previously, SO_SNDBUF was effectively a no-op. The stack should make
sure that only SO_SNDBUF bytes are ever in-flight for any given
socket/endpoint.
Fuchsia Bug: https://fxbug.dev/99070
PiperOrigin-RevId: 446792223
test/syscalls/linux/futex.cc:
In member function 'virtual void gvisor::testing::
{anonymous}::PrivateAndSharedFutexTest_PIWaiters_Test::TestBody()':
test/syscalls/linux/futex.cc:697:19:
warning: comparison of integer expressions of different signedness:
'std::__atomic_base<int>::__int_type' {aka 'int'} and 'unsigned int'
[-Wsign-compare]
697 | while (a.load() != (FUTEX_WAITERS | gettid())) {
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test/syscalls/linux/proc_pid_uid_gid_map.cc:207:64:
warning: comparison of integer expressions of different signedness: 'size_t'
{aka 'long unsigned int'} and 'int' [-Wsign-compare]
207 | TEST_PCHECK((n = write(fd, line.c_str(), line.size())) != -1);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
test/syscalls/linux/socket_inet_loopback.cc:964:21:
warning: comparison of integer expressions of different signedness: 'int' and
'std::array<gvisor::testing::FileDescriptor, 1>::size_type' {aka 'long
unsigned int'} [-Wsign-compare]
964 | for (int i = 0; i < std::size(established_clients); i++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test/syscalls/linux/socket_inet_loopback.cc:974:21:
warning: comparison of integer expressions of different signedness: 'int' and
'std::array<gvisor::testing::FileDescriptor, 1>::size_type' {aka 'long
unsigned int'} [-Wsign-compare]
974 | for (int i = 0; i < std::size(waiting_clients); i++) {
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
test/syscalls/linux/udp_socket.cc:869:6:
warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
869 |if (!IsRunningWithHostinet() || GvisorPlatform() == Platform::kPtrace ||
| ^
test/syscalls/linux/socket_unix_unbound_abstract.cc:93:9:
warning: variable 'orig_opts' set but not used [-Wunused-but-set-variable]
93 | int orig_opts;
| ^~~~~~~~~
test/syscalls/linux/socket_unix_unbound_abstract.cc:107:9:
warning: variable 'orig_opts' set but not used [-Wunused-but-set-variable]
107 | int orig_opts;
| ^~~~~~~~~
PiperOrigin-RevId: 445545240
This adds helpers to send both of these control messages via sendmsg,
and most of the initialization is moved into the SetUp body.
The parametrization is now more meaningful. The kDualStack is actually
impactful, which means DifferentTOSAndTClass test has been removed. The
IPv4-mapped IPv6 scenario is now tested in the SetAndReceiveTOSOrTClass.
PiperOrigin-RevId: 426313619
The variant kDualStack is never used by any test. It just duplicates
kIpv6 case. Because the parameters are now just kIpv4 and kIpv6, use
an int to encode the address family, instead of the enum.
PiperOrigin-RevId: 426224701