68 Commits
Author SHA1 Message Date
f1f3dbd6c2 Handle zero time correctly in gonet.deadlineTimer.
After setDeadline(ch, timer, time.Time{}), the timer pointer is not reset and
may point to an already expired timer. So the next call to setDeadline() will
close the cancel channel, even though the timer did not expire. This was fixed
by setting timer to nil if time.Time.IsZero().

Fixes #9885

Co-authored-by: snyh <snyh@snyh.org>
PiperOrigin-RevId: 598940274
2024-01-16 13:32:33 -08:00
Ayush RanjanandgVisor bot 3406ebbb75 Remove unused gonet.UDPConn.stack field.
Fixes #7894

PiperOrigin-RevId: 591533496
2023-12-16 09:48:13 -08:00
Ghanan GowripalanandgVisor bot a055645a79 Don't hold link address in tcpip.Address
All tcpip.Endpoints use a tcpip.FullAddress to hold addresses associated
with an outgoing or incoming packet, but the struct only had a field for
a tcpip.Address. This field was overloaded to also hold a link address
(which is normally held in a tcpip.LinkAddress). This worked relatively
fine until the change to make addresses opaque types.

commit 64268c8483 required the use of a
workaround to continue passing around link addresses through the
tcpip.Address field. This workaround requires assumptions about the
size of the hardware address and unncessary jumping-through-hoops.

This change just introduces a new field to tcpip.FullAddress with type
tcpip.LinkAddress that can hold link addresses and this new field will
be used by packet endpoints.

The change referenced above is cl/532284732.

PiperOrigin-RevId: 536561363
2023-05-30 18:14:32 -07:00
Kevin KrakauerandgVisor bot 64268c8483 netstack: make tcpip.Address an opaque type
The important change here is in tcpip/tcpip.go, where tcpip.Address is defined.
The rest is updating uses of tcpip.Address.

This is preparation for netip.Addr or []byte based addresses, which should save
us a bunch of allocations. Currently, we allocate every time we want to, say,
get a tcpip.Address from a header. This is because the header is a byte slice,
but Address is a string. Strings are immutable, so Go allocates and copies.

PiperOrigin-RevId: 532284732
2023-05-15 18:07:03 -07:00
Nicolas LacasseandgVisor bot df1f4cbd9f Automated rollback of changelist 495354937
PiperOrigin-RevId: 526143434
2023-04-21 14:56:47 -07:00
Kevin KrakauerandgVisor bot 70da408248 gonet: fix test flaking
It's valid for Read() to return one of two errors. The test really just wants
to ensure we unblock.

Tested via:
$ bazel test //pkg/tcpip/adapters/gonet:gonet_test \
        --test_filter TestCloseStack --runs_per_test=10000

Fixes #8748.

PiperOrigin-RevId: 525798649
2023-04-20 11:17:11 -07:00
gVisor bot 1b703f1ff0 Merge pull request #8801 from AmitKatyal1980:bugfix/close_endpoints_on_stack_close
PiperOrigin-RevId: 522647681
2023-04-07 11:46:01 -07:00
Amit Katyal 45e8e41620 On net stack close, wake up all the waiters 2023-04-04 17:33:49 +00:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
gVisor bot 9a81e89544 Merge pull request #8168 from Code-Hex:patch-1
PiperOrigin-RevId: 503522236
2023-01-20 14:30:39 -08:00
Nicolas LacasseandgVisor bot 92e25882bc gonet: Log an error if GetRemoteAddress() fails.
We eat the error, but we should at least log it first.

PiperOrigin-RevId: 495354937
2022-12-14 10:41:01 -08:00
Kei KamikawaandGitHub bdf8b3ca03 fixed to use NewUDPConn instead of NewTCPConn 2022-11-08 19:37:00 +09:00
Bruno Dal BoandgVisor bot c40f8e3651 Rename ErrNoRoute to ErrHostUnreachable
ErrNoRoute gets translated to EHOSTUNREACH which causes some code paths to
produce different errors unexpectedly. Rename the error so we can clean up some
sites to return ENETUNREACH more clearly where needed.

Updates #8105

PiperOrigin-RevId: 482355099
2022-10-19 18:29:13 -07:00
Ian Gudger ec66002f34 Fix double gonet.(*TCPListener).Shutdown panic.
* Fix a panic that would occur when calling gonet.(*TCPListener).Shutdown twice.
* Add test for gonet.(*TCPListener).Shutdown and gonet.(*TCPListener).Close
  unblocking gonet.(*TCPListener).Accept.
2022-08-20 11:54:43 -07:00
Lucas ManningandgVisor bot e64458ff08 Remove VectorisedView everywhere.
PiperOrigin-RevId: 453471156
2022-06-07 10:36:23 -07:00
Bhasker HariharanandgVisor bot e89e736f16 Deflake TestCloseRead.
The test needs to wait for CreateEndpoint to return before
cleaning up the stack, otherwise if the netstack is slow to
process the final ACK to the handshake the active side of the
connection can race ahead to the end and start tearing down the
stack.

This results in CreateEndpoint failing with a connection
aborted error.

PiperOrigin-RevId: 446515200
2022-05-04 11:55:10 -07:00
Bhasker HariharanandgVisor bot 19e9ee104a Bump default gonet.ListenTCP backlog to 4096.
Fixes #7379

PiperOrigin-RevId: 445541836
2022-04-29 17:40:17 -07:00
Adin ScannellandgVisor bot 91f58d2cc8 Update Waitable API.
Instead of passing the event mask at registratrion time, pass the mask as part
of the waiter. This makes the mask immutable and simplifies the architecture of
waiters. This is also necessary for a future fix that will allow the fdnotifier
to keep persistent entries, as opposed to requiring constant updates.

This change is intended to be a no-op in terms of function. The only exception
is signalfd, where this mask was abused. To handle this case, the operation of
signalfd changed to allow one layer of indirection.

PiperOrigin-RevId: 409702998
2021-11-13 12:54:39 -08:00
Bhasker HariharanandgVisor bot 207221ffb2 Add an integration test for istio like redirect.
Updates #6441,#6317

PiperOrigin-RevId: 404872327
2021-10-21 13:53:04 -07:00
Ghanan GowripalanandgVisor bot 706f6f35f4 Satisfy nogo
PiperOrigin-RevId: 403479257
2021-10-15 15:19:11 -07:00
Tony GongandgVisor bot 8b56b6b83b Pass address properties in a single struct
Replaced the current AddAddressWithOptions method with
AddAddressWithProperties which passes all address properties in
a single AddressProperties type. More properties that need to be
configured in the future are expected, so adding a type makes adding
them easier.

PiperOrigin-RevId: 396930729
2021-09-15 15:00:01 -07:00
Bhasker HariharanandgVisor bot e7ca2a51a8 Add POLLRDNORM/POLLWRNORM support.
On Linux these are meant to be equivalent to POLLIN/POLLOUT. Rather
than hack these on in sys_poll etc it felt cleaner to just cleanup
the call sites to notify for both events. This is what linux does
as well.

Fixes #5544

PiperOrigin-RevId: 364859977
2021-03-24 12:11:44 -07:00
Tamir DubersteinandgVisor bot 8d1afb4185 Change tcpip.Error to an interface
This makes it possible to add data to types that implement tcpip.Error.
ErrBadLinkEndpoint is removed as it is unused.

PiperOrigin-RevId: 354437314
2021-01-28 17:59:58 -08:00
Tamir DubersteinandgVisor bot 6c0e1d9cfe Define tcpip.Payloader in terms of io.Reader
Fixes #1509.

PiperOrigin-RevId: 353295589
2021-01-22 12:26:09 -08:00
Tamir DubersteinandgVisor bot 12d9790833 Remove count argument from tcpip.Endpoint.Read
The same intent can be specified via the io.Writer.

PiperOrigin-RevId: 352098747
2021-01-15 15:49:15 -08:00